]> source.dussan.org Git - jquery-ui.git/commitdiff
Tabs: Adjust handling of disabled option, using _setOptionDisabled
authorJörn Zaefferer <joern.zaefferer@gmail.com>
Tue, 22 Sep 2015 11:14:25 +0000 (13:14 +0200)
committerScott González <scott.gonzalez@gmail.com>
Fri, 25 Sep 2015 17:47:27 +0000 (13:47 -0400)
Tabs support multiple values to disable individual tabs. Only add the
ui-tabs-disabled class when all tabs are disabled.

Ref #9151
Closes gh-1599

tests/unit/tabs/options.js
ui/widgets/tabs.js

index f9d9857b12a1d105b2f3088efb3948e5993fa00c..4092cfcf8fc1775c4b4f9708afc0112a8b7dbec3 100644 (file)
@@ -185,7 +185,7 @@ test( "disabled", function( assert ) {
        disabled( element, true );
 
        assert.lacksClasses( element.tabs( "widget" ), "ui-state-disabled" );
-       assert.lacksClasses( element.tabs( "widget" ), "ui-tabs-disabled" );
+       assert.hasClasses( element.tabs( "widget" ), "ui-tabs-disabled" );
        ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" );
 
        event = $.Event( "click" );
index ff3a64ec8c0e4b461edc28be9062b1c3ddbad483..baece431d7a5c04ae0169651a299faacdd47906d 100644 (file)
@@ -291,13 +291,6 @@ $.widget( "ui.tabs", {
                        return;
                }
 
-               if ( key === "disabled" ) {
-
-                       // don't use the widget factory's disabled handling
-                       this._setupDisabled( value );
-                       return;
-               }
-
                this._super( key, value );
 
                if ( key === "collapsible" ) {
@@ -363,7 +356,7 @@ $.widget( "ui.tabs", {
        },
 
        _refresh: function() {
-               this._setupDisabled( this.options.disabled );
+               this._setOptionDisabled( this.options.disabled );
                this._setupEvents( this.options.event );
                this._setupHeightStyle( this.options.heightStyle );
 
@@ -507,7 +500,7 @@ $.widget( "ui.tabs", {
                        .data( "ui-tabs-destroy", true );
        },
 
-       _setupDisabled: function( disabled ) {
+       _setOptionDisabled: function( disabled ) {
                var currentItem, li, i;
 
                if ( $.isArray( disabled ) ) {
@@ -531,6 +524,9 @@ $.widget( "ui.tabs", {
                }
 
                this.options.disabled = disabled;
+
+               this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null,
+                       disabled === true );
        },
 
        _setupEvents: function( event ) {
@@ -804,7 +800,7 @@ $.widget( "ui.tabs", {
                                } );
                        }
                }
-               this._setupDisabled( disabled );
+               this._setOptionDisabled( disabled );
        },
 
        disable: function( index ) {
@@ -826,7 +822,7 @@ $.widget( "ui.tabs", {
                                disabled = [ index ];
                        }
                }
-               this._setupDisabled( disabled );
+               this._setOptionDisabled( disabled );
        },
 
        load: function( index, event ) {