at: "left bottom",
collision: "none"
},
+ widthButton: null,
+ widthMenu: null,
// callbacks
change: null,
"class": "ui-selectmenu-button ui-widget ui-state-default ui-corner-all",
tabindex: tabindex || this.options.disabled ? -1 : 0,
id: this.ids.button,
- width: this.element.outerWidth(),
role: "combobox",
"aria-expanded": "false",
"aria-autocomplete": "list",
"class": "ui-selectmenu-text"
})
.appendTo( this.button );
+
this._setText( this.buttonText, this.element.find( "option:selected" ).text() );
+ this._setOption( "widthButton", this.options.widthButton );
this._on( this.button, this._buttonEvents );
this._hoverable( this.button );
// Wrap menu
this.menuWrap = $( "<div>", {
- "class": "ui-selectmenu-menu ui-front",
- outerWidth: this.button.outerWidth()
+ "class": "ui-selectmenu-menu ui-front"
})
.append( this.menu )
.appendTo( this._appendTo() );
this.isOpen = true;
this._toggleAttr();
+ this._resizeMenu();
this._position();
this._on( this.document, this._documentClick );
this.button.attr( "tabindex", 0 );
}
}
+ if ( key === "widthButton" ) {
+ if ( !value ) {
+ value = this.element.outerWidth();
+ }
+ this.button.outerWidth( value );
+ }
},
_appendTo: function() {
this.button.attr( "aria-expanded", this.isOpen );
},
+ _resizeMenu: function() {
+ this.menu.outerWidth( this.options.widthMenu || Math.max(
+ this.button.outerWidth(),
+ this.menu.width( "" ).outerWidth()
+ ) );
+ },
+
_getCreateOptions: function() {
return { disabled: this.element.prop( "disabled" ) };
},