summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Nagel <info@felixnagel.com>2012-11-23 23:10:26 +0100
committerFelix Nagel <info@felixnagel.com>2012-11-23 23:10:26 +0100
commitd347aa58c67ed157d894a29aa417f6bab109195d (patch)
tree6576600dd48ecec9c7589c3b65eeb357a502b9af
parent56a7e613adf150e80136f29b9cd5e123dd2c350f (diff)
downloadjquery-ui-d347aa58c67ed157d894a29aa417f6bab109195d.tar.gz
jquery-ui-d347aa58c67ed157d894a29aa417f6bab109195d.zip
improved: disable optgroups
-rw-r--r--ui/jquery.ui.selectmenu.js28
1 files changed, 12 insertions, 16 deletions
diff --git a/ui/jquery.ui.selectmenu.js b/ui/jquery.ui.selectmenu.js
index 65eadc5ec..041832744 100644
--- a/ui/jquery.ui.selectmenu.js
+++ b/ui/jquery.ui.selectmenu.js
@@ -721,7 +721,7 @@ $.widget("ui.selectmenu", {
this._setOption( 'disabled', true );
} else {
if ( type == "optgroup" ) {
- this._disableOptgroup( index );
+ this._toggleOptgroup( index, false );
} else {
this._disableOption( index );
}
@@ -734,7 +734,7 @@ $.widget("ui.selectmenu", {
this._setOption( 'disabled', false );
} else {
if ( type == "optgroup" ) {
- this._enableOptgroup( index );
+ this._toggleOptgroup( index, true );
} else {
this._enableOption( index );
}
@@ -764,22 +764,18 @@ $.widget("ui.selectmenu", {
}
},
- _disableOptgroup: function( index ) {
+ // true = enabled, false = disabled
+ _toggleOptgroup: function( index, flag ) {
var optGroupElem = this.list.find( 'li.ui-selectmenu-group-' + index );
- if ( optGroupElem ) {
+ if ( optGroupElem ) {
optGroupElem
- .addClass( this.namespace + '-state-disabled' )
- .attr( "aria-disabled", true );
- this.element.find( "optgroup" ).eq( index ).attr( "disabled", "disabled" );
- }
- },
-
- _enableOptgroup: function( index ) {
- var optGroupElem = this.list.find( 'li.ui-selectmenu-group-' + index );
- if ( optGroupElem ) {
- optGroupElem.removeClass( this.namespace + '-state-disabled' )
- .attr( "aria-disabled", false);
- this.element.find( "optgroup" ).eq( index ).removeAttr( "disabled" );
+ .toggleClass( this.namespace + '-state-disabled', flag )
+ .attr( "aria-disabled", !flag );
+ if ( flag ) {
+ this.element.find( "optgroup" ).eq( index ).attr( "disabled", "disabled" );
+ } else {
+ this.element.find( "optgroup" ).eq( index ).removeAttr( "disabled" );
+ }
}
},