diff options
author | Felix Nagel <info@felixnagel.com> | 2011-08-02 01:40:31 +0200 |
---|---|---|
committer | Felix Nagel <info@felixnagel.com> | 2011-08-02 01:40:31 +0200 |
commit | eaef46805aec411f80ff58c720e3766309997815 (patch) | |
tree | 5163be72f7a2068a3122781f98aaaed5aead41fd | |
parent | 9c9425ac48378d7357caebdf52fb2ec98e069b8b (diff) | |
download | jquery-ui-eaef46805aec411f80ff58c720e3766309997815.tar.gz jquery-ui-eaef46805aec411f80ff58c720e3766309997815.zip |
fixed: hopefully some issues with positioning and jumping, see: https://github.com/fnagel/jquery-ui/issues/147
-rw-r--r-- | themes/base/jquery.ui.selectmenu.css | 2 | ||||
-rw-r--r-- | ui/jquery.ui.selectmenu.js | 44 |
2 files changed, 27 insertions, 19 deletions
diff --git a/themes/base/jquery.ui.selectmenu.css b/themes/base/jquery.ui.selectmenu.css index 829401939..8e2d2e068 100644 --- a/themes/base/jquery.ui.selectmenu.css +++ b/themes/base/jquery.ui.selectmenu.css @@ -2,7 +2,7 @@ ----------------------------------*/ .ui-selectmenu { display: block; display: inline-block; position: relative; height: 2.2em; vertical-align: middle; text-decoration: none; overflow: hidden; zoom: 1; } .ui-selectmenu-icon { position:absolute; right:6px; margin-top:-8px; top: 50%; } -.ui-selectmenu-menu { padding:0; margin:0; position:absolute; display: none; z-index: 1005;} /* z-index: 1005 to make selectmenu work with dialog */ +.ui-selectmenu-menu { padding:0; margin:0; position:absolute; top: 0; display: none; z-index: 1005;} /* z-index: 1005 to make selectmenu work with dialog */ .ui-selectmenu-menu ul { padding:0; margin:0; list-style:none; position: relative; overflow: auto; overflow-y: auto ; overflow-x: hidden; } .ui-selectmenu-open { display: block; } .ui-selectmenu-menu-popup { margin-top: -1px; } diff --git a/ui/jquery.ui.selectmenu.js b/ui/jquery.ui.selectmenu.js index 58d480a08..87305d59a 100644 --- a/ui/jquery.ui.selectmenu.js +++ b/ui/jquery.ui.selectmenu.js @@ -253,9 +253,10 @@ $.widget("ui.selectmenu", { // this allows for using the scrollbar in an overflowed list .bind( 'mousedown.selectmenu mouseup.selectmenu', function() { return false; }); - // needed when window is resized - $(window).bind( "resize.selectmenu", $.proxy( self._refreshPosition, this ) ); + // TODO seems to be useless, but causes errors (fnagel 01.08.11) + // see: https://github.com/fnagel/jquery-ui/issues/147 + // $(window).bind( "resize.selectmenu", $.proxy( self._refreshPosition, this ) ); }, _init: function() { @@ -424,7 +425,8 @@ $.widget("ui.selectmenu", { .removeAttr( 'aria-disabled' ) .unbind( ".selectmenu" ); - $( window ).unbind( ".selectmenu" ); + // TODO unneded as event binding has been disabled + // $( window ).unbind( ".selectmenu" ); $( document ).unbind( ".selectmenu" ); // unbind click on label, reset its for attr @@ -513,21 +515,26 @@ $.widget("ui.selectmenu", { var self = this, o = this.options; if ( self.newelement.attr("aria-disabled") != 'true' ) { self._closeOthers(event); - self.newelement - .addClass('ui-state-active'); + self.newelement.addClass('ui-state-active'); self.listWrap.appendTo( o.appendTo ); - - self.listWrap.addClass( self.widgetBaseClass + '-open' ); - - selected = self.list.attr('aria-hidden', false).find('li:not(.' + self.widgetBaseClass + '-group):eq(' + self._selectedIndex() + ') a'); - if (selected.length) selected[0].focus(); + self.list.attr('aria-hidden', false) if ( o.style == "dropdown" ) { self.newelement.removeClass('ui-corner-all').addClass('ui-corner-top'); } - self._refreshPosition(); + self.listWrap.addClass( self.widgetBaseClass + '-open' ); + // positioning needed for IE7 (tested 01.08.11 on MS VPC Image) + // see https://github.com/fnagel/jquery-ui/issues/147 + if ( $.browser.msie && $.browser.version.substr( 0,1 ) == 7 ) { + self._refreshPosition(); + } + selected = self.list.attr('aria-hidden', false).find('li:not(.' + self.widgetBaseClass + '-group):eq(' + self._selectedIndex() + ') a'); + if (selected.length) selected[0].focus(); + // positioning needed for FF, Chrome, IE8, IE7, IE6 (tested 01.08.11 on MS VPC Image) + self._refreshPosition(); + self._trigger("open", event, self._uiHash()); } }, @@ -794,6 +801,7 @@ $.widget("ui.selectmenu", { _refreshPosition: function() { var o = this.options; + // if its a native pop-up we need to calculate the position of the selected li if (o.style == "popup" && !o.positionOptions.offset) { var selected = this._selectedOptionLi(); @@ -807,13 +815,13 @@ $.widget("ui.selectmenu", { }); } this.listWrap.position({ - // set options for position plugin - of: o.positionOptions.of || this.newelement, - my: o.positionOptions.my, - at: o.positionOptions.at, - offset: o.positionOptions.offset || _offset, - collision: o.positionOptions.collision || 'flip' - }); + // set options for position plugin + of: o.positionOptions.of || this.newelement, + my: o.positionOptions.my, + at: o.positionOptions.at, + offset: o.positionOptions.offset || _offset, + collision: o.positionOptions.collision || 'flip' + }); } }); |