]> source.dussan.org Git - jquery-ui.git/commitdiff
fixed: positioning issue
authorFelix Nagel <info@felixnagel.com>
Sat, 13 Nov 2010 00:41:51 +0000 (01:41 +0100)
committerFelix Nagel <info@felixnagel.com>
Sat, 13 Nov 2010 00:41:51 +0000 (01:41 +0100)
added: default max height based upon the viewport height

ui/jquery.ui.selectmenu.js

index b58f8045b259455c774c3302a5af169162d3b388..9254a8141b2b36c11772293c79bbe9401d64bb6d 100644 (file)
@@ -241,9 +241,16 @@ $.widget("ui.selectmenu", {
                if(o.style == 'dropdown'){ this.list.width( (o.menuWidth) ? o.menuWidth : ((o.width) ? o.width : selectWidth)); }
                else { this.list.width( (o.menuWidth) ? o.menuWidth : ((o.width) ? o.width - o.handleWidth : selectWidth - o.handleWidth)); }   
                
-               //set max height from option 
-               if(o.maxHeight && o.maxHeight < this.list.height()){ this.list.height(o.maxHeight); }   
-               
+               // calculate default max height
+               if(o.maxHeight) {
+                       //set max height from option 
+                        if (o.maxHeight < this.list.height()){ this.list.height(o.maxHeight); }        
+               } else {
+                       if (($(window).height() / 3) < this.list.height()) {
+                               o.maxHeight = $(window).height() / 3
+                               this.list.height(o.maxHeight);
+                       }
+               }
                //save reference to actionable li's (not group label li's)
                this._optionLis = this.list.find('li:not(.'+ self.widgetBaseClass +'-group)');
                                
@@ -381,7 +388,6 @@ $.widget("ui.selectmenu", {
                var self = this;
                var disabledStatus = this.newelement.attr("aria-disabled");
                if(disabledStatus != 'true'){
-                       this._refreshPosition();
                        this._closeOthers(event);
                        this.newelement
                                .addClass('ui-state-active');
@@ -392,6 +398,7 @@ $.widget("ui.selectmenu", {
                                .attr('aria-hidden', false)
                                .find('li:not(.'+ self.widgetBaseClass +'-group):eq('+ this._selectedIndex() +') a')[0].focus();        
                        if(this.options.style == "dropdown"){ this.newelement.removeClass('ui-corner-all').addClass('ui-corner-top'); } 
+                       this._refreshPosition();
                        this._trigger("open", event, this._uiHash());
                }
        },