});
-test( "Width", function() {
- expect( 8 );
+test( "width", function() {
+ expect( 9 );
var button, menu,
element = $( "#speed" );
equal( button.outerWidth(), element.outerWidth(), "button width with long option" );
element.selectmenu( "open" );
ok( menu.outerWidth() >= element.outerWidth(), "menu width with long option" );
+
+ element.parent().outerWidth( 300 );
+ element
+ .selectmenu( "destroy" )
+ .css( "width", "100%" )
+ .selectmenu();
+ button = element.selectmenu( "widget" );
+ equal( button.outerWidth(), 300, "button width fills container" );
});
})( jQuery );
.appendTo( this.button );
this._setText( this.buttonText, this.element.find( "option:selected" ).text() );
- this._setOption( "width", this.options.width );
+ this._resizeButton();
this._on( this.button, this._buttonEvents );
this.button.one( "focusin", function() {
refresh: function() {
this._refreshMenu();
this._setText( this.buttonText, this._getSelectedItem().text() );
- this._setOption( "width", this.options.width );
+ if ( !this.options.width ) {
+ this._resizeButton();
+ }
},
_refreshMenu: function() {
}
if ( key === "width" ) {
- if ( !value ) {
- value = this.element.outerWidth();
- }
- this.button.outerWidth( value );
+ this._resizeButton();
}
},
this.menu.attr( "aria-hidden", !this.isOpen );
},
+ _resizeButton: function() {
+ var width = this.options.width;
+
+ if ( !width ) {
+ width = this.element.show().outerWidth();
+ this.element.hide();
+ }
+
+ this.button.outerWidth( width );
+ },
+
_resizeMenu: function() {
this.menu.outerWidth( Math.max(
this.button.outerWidth(),