]> source.dussan.org Git - jquery-ui.git/commitdiff
improved: width handling for list and newelement
authorFelix Nagel <info@felixnagel.com>
Tue, 24 May 2011 21:24:30 +0000 (23:24 +0200)
committerFelix Nagel <info@felixnagel.com>
Tue, 24 May 2011 21:24:30 +0000 (23:24 +0200)
ui/jquery.ui.selectmenu.js

index 5974f85a5a76844eb4920d328809ba840b107972..2068535ec7e6ff4bcb95f2d2bfe3f2f8dc3b87ce 100644 (file)
@@ -157,11 +157,12 @@ $.widget("ui.selectmenu", {
                                }
                        });
 
-               // original selectmenu width
-               var selectWidth = this.element.width();
-
+               // set width when not set via options
+               if (!o.width) {
+                       o.width = this.element.outerWidth();
+               }               
                // set menu button width
-               this.newelement.width(o.width ? o.width : selectWidth);
+               this.newelement.width(o.width);
 
                // hide original selectmenu element
                this.element.hide();            
@@ -354,14 +355,11 @@ $.widget("ui.selectmenu", {
                        this.newelement.add(this.list).addClass(transferClasses);
                }
 
-               // original selectmenu width
-               var selectWidth = this.element.width();
-
                // set menu width to either menuWidth option value, width option value, or select width 
                if (o.style == 'dropdown') { 
-                       this.list.width(o.menuWidth ? o.menuWidth : (o.width ? o.width : selectWidth)); 
+                       this.list.width(o.menuWidth ? o.menuWidth : o.width); 
                } else { 
-                       this.list.width(o.menuWidth ? o.menuWidth : (o.width ? o.width - o.handleWidth : selectWidth - o.handleWidth)); 
+                       this.list.width(o.menuWidth ? o.menuWidth : o.width - o.handleWidth); 
                }
 
                // calculate default max height