Change placement of header menu so it always fits on screen horizontally

Fixed the problem that if the header menu is opened close to the right border of the browser screen, the menu would not fit on screen.

This patch places the menu as before it if fits, otherwise, it places it to the left of the menu button.

Steps for testing:
- Open example Plugin: Column header menu 
- Resize browser window to have its right border right next to a menu button
- Click menu button
- Menu should fit on screen