aboutsummaryrefslogtreecommitdiffstats
path: root/ui/selectmenu.js
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2015-03-04 14:27:10 -0500
committerScott González <scott.gonzalez@gmail.com>2015-03-05 11:42:49 -0500
commitaf4c35df9d1cf4c15d57b3789711026360785831 (patch)
tree150083ab0fedf1494c5cbc409995d3513eb01578 /ui/selectmenu.js
parent47a32fb5b3c190123937e0178900ef754c3e220d (diff)
downloadjquery-ui-af4c35df9d1cf4c15d57b3789711026360785831.tar.gz
jquery-ui-af4c35df9d1cf4c15d57b3789711026360785831.zip
Selectmenu: Support `width: false` and default to 14em
`width: null` still matches the width of the original element. `width: false` prevents an inline style from being set for the width. This makes it easy to set the width via a stylesheet and allows the use of any unit for setting the width, such as the new default of `14em`. Fixes #11198 Closes gh-1467
Diffstat (limited to 'ui/selectmenu.js')
-rw-r--r--ui/selectmenu.js17
1 files changed, 13 insertions, 4 deletions
diff --git a/ui/selectmenu.js b/ui/selectmenu.js
index 68cbbbfbf..9bd2d1016 100644
--- a/ui/selectmenu.js
+++ b/ui/selectmenu.js
@@ -48,7 +48,7 @@ return $.widget( "ui.selectmenu", {
at: "left bottom",
collision: "none"
},
- width: null,
+ width: false,
// callbacks
change: null,
@@ -118,7 +118,9 @@ return $.widget( "ui.selectmenu", {
this.buttonItem = this._renderButtonItem( item )
.appendTo( this.button );
- this._resizeButton();
+ if ( this.options.width !== false ) {
+ this._resizeButton();
+ }
this._on( this.button, this._buttonEvents );
this.button.one( "focusin", function() {
@@ -210,7 +212,7 @@ return $.widget( "ui.selectmenu", {
this._getSelectedItem().data( "ui-selectmenu-item" ) || {}
)
);
- if ( !this.options.width ) {
+ if ( this.options.width === null ) {
this._resizeButton();
}
},
@@ -603,7 +605,14 @@ return $.widget( "ui.selectmenu", {
_resizeButton: function() {
var width = this.options.width;
- if ( !width ) {
+ // For `width: false`, just remove inline style and stop
+ if ( width === false ) {
+ this.button.css( "width", "" );
+ return;
+ }
+
+ // For `width: null`, match the width of the original element
+ if ( width === null ) {
width = this.element.show().outerWidth();
this.element.hide();
}