diff options
author | Xavi <xavi.rmz@gmail.com> | 2010-12-19 16:52:22 -0500 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2010-12-19 16:52:22 -0500 |
commit | 956697bfca1b386ae20eb27ccfd8c1df3234f1f2 (patch) | |
tree | f246a4e7ea861a3bbc1939f758489e9febfbdb9d /ui | |
parent | d6edba5a89ab5e84044666bb9d50a4663c1412c8 (diff) | |
download | jquery-ui-956697bfca1b386ae20eb27ccfd8c1df3234f1f2.tar.gz jquery-ui-956697bfca1b386ae20eb27ccfd8c1df3234f1f2.zip |
All: Use .toggleClass() instead of conditionally using .addClass() and .removeClass(). Fixes #6764 - Use toggleClass instead of [ bool ? 'addClass' : 'removeClass' ].
Diffstat (limited to 'ui')
-rw-r--r-- | ui/jquery.ui.accordion.js | 3 | ||||
-rw-r--r-- | ui/jquery.ui.sortable.js | 3 | ||||
-rw-r--r-- | ui/jquery.ui.tabs.js | 9 | ||||
-rw-r--r-- | ui/jquery.ui.widget.js | 4 |
4 files changed, 6 insertions, 13 deletions
diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index 76be0095f..955030ccc 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -187,8 +187,7 @@ $.widget( "ui.accordion", { // so we need to add the disabled class to the headers and panels if ( key == "disabled" ) { this.headers.add(this.headers.next()) - [ value ? "addClass" : "removeClass" ]( - "ui-accordion-disabled ui-state-disabled" ); + .toggleClass( "ui-accordion-disabled ui-state-disabled", !!value ); } }, diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index d2d3228ee..32757d41c 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -77,8 +77,7 @@ $.widget("ui.sortable", $.ui.mouse, { if ( key === "disabled" ) { this.options[ key ] = value; - this.widget() - [ value ? "addClass" : "removeClass"]( "ui-sortable-disabled" ); + this.widget().toggleClass( "ui-sortable-disabled", !!value ); } else { // Don't call widget base _setOption for disable as it adds ui-state-disabled class $.Widget.prototype._setOption.apply(this, arguments); diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index 7d73bf10b..13e1c25c8 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -233,9 +233,7 @@ $.widget( "ui.tabs", { o.selected = this.lis.index( this.lis.filter( ".ui-tabs-selected" ) ); } - // update collapsible - // TODO: use .toggleClass() - this.element[ o.collapsible ? "addClass" : "removeClass" ]( "ui-tabs-collapsible" ); + this.element.toggleClass( "ui-tabs-collapsible", o.collapsible ); // set or update cookie after init and add/remove respectively if ( o.cookie ) { @@ -244,9 +242,8 @@ $.widget( "ui.tabs", { // disable tabs for ( var i = 0, li; ( li = this.lis[ i ] ); i++ ) { - $( li )[ $.inArray( i, o.disabled ) != -1 && - // TODO: use .toggleClass() - !$( li ).hasClass( "ui-tabs-selected" ) ? "addClass" : "removeClass" ]( "ui-state-disabled" ); + $( li ).toggleClass( "ui-state-disabled", + $.inArray( i, o.disabled ) != -1 && !$( li ).hasClass( "ui-tabs-selected" ) ); } // reset cache if switching from cached to not cached diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 0420bc31a..b5fb600d9 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -212,9 +212,7 @@ $.Widget.prototype = { if ( key === "disabled" ) { this.widget() - [ value ? "addClass" : "removeClass"]( - this.widgetBaseClass + "-disabled" + " " + - "ui-state-disabled" ) + .toggleClass( this.widgetBaseClass + "-disabled ui-state-disabled", !!value ) .attr( "aria-disabled", value ); } |