소스 검색

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

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@2785 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 12 년 전
부모
커밋
bd408e2c61
1개의 변경된 파일8개의 추가작업 그리고 0개의 파일을 삭제
  1. 8 0
      js/icon_select.js

+ 8 - 0
js/icon_select.js

@@ -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