Skip to content

Commit 367cb5e

Browse files
committed
Tabs: Implement new _addClass api
1 parent 1efca9c commit 367cb5e

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed

ui/tabs.js

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ return $.widget( "ui.tabs", {
7979

8080
this.running = false;
8181

82-
this._addClass( "ui-tabs", "ui-widget ui-widget-content" );
82+
this._addClass( "ui-tabs ui-widget ui-widget-content" );
8383
this[ ( options.collapsible ? "_add" : "_remove" ) + "Class" ]( "ui-tabs-collapsible" );
8484

8585
this._processTabs();
@@ -369,7 +369,7 @@ return $.widget( "ui.tabs", {
369369
tabIndex: 0
370370
});
371371

372-
this._addClass( this.active, "ui-tabs-active", "ui-state-active" );
372+
this._addClass( this.active, "ui-tabs-active ui-state-active" );
373373
this._getPanelForTab( this.active )
374374
.show()
375375
.attr({
@@ -386,8 +386,8 @@ return $.widget( "ui.tabs", {
386386

387387
this.tablist = this._getList().attr( "role", "tablist" );
388388

389-
this._addClass( this.tablist, "ui-tabs-nav",
390-
"ui-helper-reset ui-helper-clearfix ui-widget-header" );
389+
this._addClass( this.tablist,
390+
"ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header" );
391391

392392
// Prevent users from focusing disabled tabs via click
393393
this.tablist.delegate( "> li", "mousedown" + this.eventNamespace, function( event ) {
@@ -413,7 +413,7 @@ return $.widget( "ui.tabs", {
413413
role: "tab",
414414
tabIndex: -1
415415
});
416-
this._addClass( this.tabs, "ui-tab", "ui-state-default" );
416+
this._addClass( this.tabs, "ui-tab ui-state-default" );
417417

418418
this.anchors = this.tabs.map(function() {
419419
return $( "a", this )[ 0 ];
@@ -464,7 +464,7 @@ return $.widget( "ui.tabs", {
464464
});
465465

466466
this.panels.attr( "role", "tabpanel" );
467-
this._addClass( this.panels, "ui-tabs-panel", "ui-widget-content" );
467+
this._addClass( this.panels, "ui-tabs-panel ui-widget-content" );
468468

469469
// Avoid memory leaks (#10056)
470470
if ( prevTabs ) {
@@ -495,13 +495,9 @@ return $.widget( "ui.tabs", {
495495
// disable tabs
496496
for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) {
497497
if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
498-
$( li )
499-
.addClass( "ui-state-disabled" )
500-
.attr( "aria-disabled", "true" );
498+
this._addClass( $( li ).attr( "aria-disabled", "true" ), "ui-state-disabled" );
501499
} else {
502-
$( li )
503-
.removeClass( "ui-state-disabled" )
504-
.removeAttr( "aria-disabled" );
500+
this._removeClass( $( li ).removeAttr( "aria-disabled" ), "ui-state-disabled" );
505501
}
506502
}
507503

@@ -627,7 +623,7 @@ return $.widget( "ui.tabs", {
627623
}
628624

629625
function show() {
630-
that._addClass( eventData.newTab.closest( "li" ), "ui-tabs-active", "ui-state-active" );
626+
that._addClass( eventData.newTab.closest( "li" ), "ui-tabs-active ui-state-active" );
631627

632628
if ( toShow.length && that.options.show ) {
633629
that._show( toShow, that.options.show, complete );
@@ -641,12 +637,12 @@ return $.widget( "ui.tabs", {
641637
if ( toHide.length && this.options.hide ) {
642638
this._hide( toHide, this.options.hide, function() {
643639
that._removeClass( eventData.oldTab.closest( "li" ),
644-
"ui-tabs-active", "ui-state-active" );
640+
"ui-tabs-active ui-state-active" );
645641
show();
646642
});
647643
} else {
648644
this._removeClass( eventData.oldTab.closest( "li" ),
649-
"ui-tabs-active", "ui-state-active" );
645+
"ui-tabs-active ui-state-active" );
650646
toHide.hide();
651647
show();
652648
}
@@ -712,15 +708,10 @@ return $.widget( "ui.tabs", {
712708
},
713709

714710
_destroy: function() {
715-
var that = this;
716711
if ( this.xhr ) {
717712
this.xhr.abort();
718713
}
719714

720-
this._removeClass( "ui-tabs ui-tabs-collapsible", "ui-widget ui-widget-content" );
721-
this._removeClass( this.tablist, "ui-tabs-nav",
722-
"ui-helper-reset ui-helper-clearfix ui-widget-header" );
723-
this._removeClass( this.anchors, "ui-tabs-anchor" );
724715

725716
this.tablist.removeAttr( "role" ).unbind( this.eventNamespace );
726717

@@ -739,8 +730,6 @@ return $.widget( "ui.tabs", {
739730
.removeAttr( "aria-hidden" )
740731
.removeAttr( "aria-expanded" )
741732
.removeAttr( "role" );
742-
that._removeClass( $( this ), "ui-tabs-active ui-tab ui-tabs-panel",
743-
"ui-state-default ui-state-active ui-state-disabled ui-widget-content" );
744733
}
745734
});
746735

0 commit comments

Comments
 (0)