From: Felix Nagel Date: Tue, 24 May 2011 21:24:30 +0000 (+0200) Subject: improved: width handling for list and newelement X-Git-Tag: selectmenu_v1.1.0~8 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ed77e04dc192e53ad4437a45e4a8c4d841b27c8f;p=jquery-ui.git improved: width handling for list and newelement --- diff --git a/ui/jquery.ui.selectmenu.js b/ui/jquery.ui.selectmenu.js index 5974f85a5..2068535ec 100644 --- a/ui/jquery.ui.selectmenu.js +++ b/ui/jquery.ui.selectmenu.js @@ -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