diff options
author | Felix Nagel <info@felixnagel.com> | 2012-11-29 00:58:28 +0100 |
---|---|---|
committer | Felix Nagel <info@felixnagel.com> | 2012-11-29 00:58:28 +0100 |
commit | 7328333773ad20d11230b3173e0a71ac39cfaa90 (patch) | |
tree | 4ba998bca1260e455747dc52913dd90a6a0bcf76 /ui/jquery.ui.selectmenu.js | |
parent | 36533a718da41d4dc82286d2b7ff52a34481dbbb (diff) | |
download | jquery-ui-7328333773ad20d11230b3173e0a71ac39cfaa90.tar.gz jquery-ui-7328333773ad20d11230b3173e0a71ac39cfaa90.zip |
Selectmenu: better position handling, fixes issue with wrong styles when using custom positioning
Diffstat (limited to 'ui/jquery.ui.selectmenu.js')
-rw-r--r-- | ui/jquery.ui.selectmenu.js | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/ui/jquery.ui.selectmenu.js b/ui/jquery.ui.selectmenu.js index 768e7fb8a..1929c8789 100644 --- a/ui/jquery.ui.selectmenu.js +++ b/ui/jquery.ui.selectmenu.js @@ -198,6 +198,10 @@ $.widget( "ui.selectmenu", { open: function( event ) { if ( !this.options.disabled ) { + var _position = { + of: this.button + }; + // make sure menu is refreshed on first init (needed at least for IE9) if ( this.isOpen === undefined ) { this.button.trigger( "focus" ); @@ -207,7 +211,7 @@ $.widget( "ui.selectmenu", { this._toggleAttr(); this.menu.menu( "focus", event, this._getSelectedItem() ); - if ( this.items && !this.options.dropdown ) { + if ( this.items && !this.options.dropdown && this.options.position.my == "left top" && this.options.position.at == "left bottom" ) { var currentItem = this._getSelectedItem(); // center current item if ( this.menu.outerHeight() < this.menu.prop( "scrollHeight" ) ) { @@ -215,17 +219,13 @@ $.widget( "ui.selectmenu", { this.menu.scrollTop( this.menu.scrollTop() + currentItem.position().top - this.menu.outerHeight() / 2 + currentItem.outerHeight() / 2 ); this.menuWrap.css( "left" , "auto" ); } - - $.extend( this.options.position, { - my: "left top" + ( this.menu.offset().top - currentItem.offset().top + ( this.button.outerHeight() - currentItem.outerHeight() ) / 2 ), - at: "left top" - }); + _position.my = "left top" + ( this.menu.offset().top - currentItem.offset().top + ( this.button.outerHeight() - currentItem.outerHeight() ) / 2 ); + _position.at = "left top"; } - this.options.position.of = this.button; this.menuWrap .zIndex( this.element.zIndex() + 1 ) - .position( this.options.position ); + .position( $.extend( {}, this.options.position, _position ) ); this._trigger( "open", event ); } |