Re-position the popup menu each time the button is clicked, in case the button was moved...

SVN:trunk[2785]
This commit is contained in:
Denis Flaven
2013-06-28 09:39:57 +00:00
parent 5e3a34d425
commit 24ab96769a

View File

@@ -29,6 +29,7 @@ $(function()
this.oLabel = $('<span>'+sLabel+'</span>');
this.oButton = $('<button><div style="display: inline-block;vertical-align: middle;"><span class="ui-icon ui-icon-triangle-1-s"/></div></button>');
this.oButton.prepend(this.oLabel).prepend(this.oImg);
this.oButton.click(function(event, ui) { me._on_button_clicked(event, ui); });
this.element.after(this.oButton);
this.element.addClass( "itop-icon-select" ).button();
this.element.bind( "reverted.itop-icon-select", function(ev, data) {
@@ -72,6 +73,13 @@ $(function()
var iWidth = Math.max(250, this.oButton.width());
this.oMenu = this.oButton.menu({ content: sMenu, callback: function(data) {me._on_icon_selection(data);}, showSpeed: 0, maxHeight: 300, flyOut: true, width: iWidth, positionOpts: {posX: 'left', posY: 'top', offsetX: 0, offsetY: 0} });
},
_on_button_clicked: function(event, ui)
{
// Adjust the position of the menu, in case the button was moved...
// The simpler is to kill and rebuild the menu !!!
KillAllMenus();
this._create_menu();
},
// events bound via _bind are removed automatically
// revert other modifications here