Flip the menu to right if there is not enough space in the left

See https://bugzilla.wikimedia.org/41738
Merge branch 'master' of github.com:wikimedia/jquery.ime