Cleanup the position function
Show the menu correctly if it goes off-screen
Defined rtlElement properly

Unbreaks the previous commit.
Merge pull request #272 from amire80/bug-52154

Clean up the position function and move the menu into the screen if it goes away