Normal hide/show toggling was broken, this fixes it (#1219).
[jquery.git] / src / fx / fx.js
index dd5407c..f53b2b2 100644 (file)
@@ -110,9 +110,13 @@ jQuery.fn.extend({
        toggle: function( fn, fn2 ){
                return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ?
                        this._toggle( fn, fn2 ) :
-                       this.animate({
-                               height: "toggle", width: "toggle", opacity: "toggle"
-                       }, fn, fn2);
+                       fn ?
+                               this.animate({
+                                       height: "toggle", width: "toggle", opacity: "toggle"
+                               }, fn, fn2) :
+                               this.each(function(){
+                                       jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ]();
+                               });
        },
        
        /**
@@ -307,16 +311,15 @@ jQuery.fn.extend({
         */
        animate: function( prop, speed, easing, callback ) {
                return this.queue(function(){
-                       var hidden = jQuery(this).is(":hidden");
+                       var hidden = jQuery(this).is(":hidden"),
+                               opt = jQuery.speed(speed, easing, callback),
+                               self = this;
                        
                        for ( var p in prop )
-                               if ( prop[p] == "hide" && hidden ||
-                                       prop[p] == "show" && !hidden )
-                                               return;
+                               if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden )
+                                       return jQuery.isFunction(opt.complete) && opt.complete.apply(this);
                
                        this.curAnim = jQuery.extend({}, prop);
-                       var opt = jQuery.speed(speed, easing, callback);
-                       var self = this;
                        
                        jQuery.each( prop, function(name, val){
                                var e = new jQuery.fx( self, opt, name );