]> source.dussan.org Git - jquery-ui.git/commitdiff
Effects: handle switch parameter in toggleClass, fixes #4722
authorChi Cheng <cloudream@gmail.com>
Mon, 27 Jul 2009 17:35:54 +0000 (17:35 +0000)
committerChi Cheng <cloudream@gmail.com>
Mon, 27 Jul 2009 17:35:54 +0000 (17:35 +0000)
ui/effects.core.js

index 2cc7542f2e39ee8d5c635dc2dd7d0a633b9b7262..e41d7144169f2121dee3a9125a82f77c951fd099 100644 (file)
@@ -222,8 +222,18 @@ $.fn.extend({
        },
 
        _toggleClass: $.fn.toggleClass,
-       toggleClass: function(classNames,speed,easing,callback) {
-               return ( (typeof speed !== "boolean") && speed ) ? $.effects.animateClass.apply(this, [{ toggle: classNames },speed,easing,callback]) : this._toggleClass(classNames, speed);
+       toggleClass: function(classNames, force, speed, easing, callback) {
+               if ( typeof force == "boolean" || force === undefined ) {
+                       if ( !speed ) {
+                               // without speed parameter;
+                               return this._toggleClass(classNames, force);
+                       } else {
+                               return $.effects.animateClass.apply(this, [(force?{add:classNames}:{remove:classNames}),speed,easing,callback]);
+                       }
+               } else {
+                       // without switch parameter;
+                       return $.effects.animateClass.apply(this, [{ toggle: classNames },force,speed,easing]);
+               }
        },
 
        switchClass: function(remove,add,speed,easing,callback) {