Selectmenu: merged _toggleButtonStyle with _toggleAttr method, removed incomplete dropdown _setOptions functionality

This commit is contained in:
Felix Nagel 2012-02-25 03:17:20 +01:00
parent a4eeddd330
commit 85d6acb899

View File

@ -161,7 +161,9 @@ $.widget( "ui.selectmenu", {
.attr( 'role', 'listbox' ); .attr( 'role', 'listbox' );
// change menu styles? // change menu styles?
this._setOption( "dropdown", this.options.dropdown ); if ( this.options.dropdown ) {
this.menu.addClass( 'ui-corner-bottom' ).removeClass( 'ui-corner-all' );
}
// unbind Menu document event // unbind Menu document event
$( document ).unbind( "click.menu" ); $( document ).unbind( "click.menu" );
@ -193,8 +195,6 @@ $.widget( "ui.selectmenu", {
open: function( event ) { open: function( event ) {
if ( !this.options.disabled ) { if ( !this.options.disabled ) {
this._toggleButtonStyle();
// make sure menu is refreshed on first init (needed at least for IE9) // make sure menu is refreshed on first init (needed at least for IE9)
if ( this.isOpen === undefined ) { if ( this.isOpen === undefined ) {
this.button.trigger( "focus" ); this.button.trigger( "focus" );
@ -232,7 +232,6 @@ $.widget( "ui.selectmenu", {
close: function( event ) { close: function( event ) {
if ( this.isOpen ) { if ( this.isOpen ) {
this._toggleButtonStyle();
this._toggleAttr(); this._toggleAttr();
this.isOpen = false; this.isOpen = false;
this._trigger( "close", event ); this._trigger( "close", event );
@ -389,9 +388,6 @@ $.widget( "ui.selectmenu", {
if ( key === "appendTo" ) { if ( key === "appendTo" ) {
this.menuWrap.appendTo( $( value || "body", this.element[0].ownerDocument )[0] ); this.menuWrap.appendTo( $( value || "body", this.element[0].ownerDocument )[0] );
} }
if ( key === "dropdown" ) {
this.menu.toggleClass( 'ui-corner-bottom', value ).toggleClass( 'ui-corner-all', !value );
}
if ( key === "disabled" ) { if ( key === "disabled" ) {
this.menu.menu( "option", "disabled", value ); this.menu.menu( "option", "disabled", value );
if ( value ) { if ( value ) {
@ -406,15 +402,12 @@ $.widget( "ui.selectmenu", {
}, },
_toggleAttr: function(){ _toggleAttr: function(){
this.menuWrap.toggleClass( 'ui-selectmenu-open', !this.isOpen );
this.menu.attr("aria-hidden", this.isOpen);
this.button.attr("aria-expanded", !this.isOpen);
},
_toggleButtonStyle: function() {
if ( this.options.dropdown ) { if ( this.options.dropdown ) {
this.button.toggleClass( 'ui-corner-top', !this.isOpen ).toggleClass( 'ui-corner-all', this.isOpen ); this.button.toggleClass( 'ui-corner-top', !this.isOpen ).toggleClass( 'ui-corner-all', this.isOpen );
} }
this.menuWrap.toggleClass( 'ui-selectmenu-open', !this.isOpen );
this.menu.attr("aria-hidden", this.isOpen);
this.button.attr("aria-expanded", !this.isOpen);
}, },
_getCreateOptions: function() { _getCreateOptions: function() {