X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Ffx%2Ffx.js;h=e39ea7b36b412417f718746a33c000c96a11eb0c;hb=e1e631a04440c0d9ab6580ea1593286072fa7ef5;hp=6dd3279d89ab645be4115f55c596c2b8bd16557d;hpb=0798c6e64e4e0c984d5ece50ade61827c2105c39;p=jquery.git diff --git a/src/fx/fx.js b/src/fx/fx.js index 6dd3279..e39ea7b 100644 --- a/src/fx/fx.js +++ b/src/fx/fx.js @@ -33,12 +33,13 @@ jQuery.fn.extend({ * @see hide(String|Number,Function) */ show: function(speed,callback){ + var hidden = this.filter(":hidden"); return speed ? - this.animate({ + hidden.animate({ height: "show", width: "show", opacity: "show" }, speed, callback) : - this.each(function(){ + hidden.each(function(){ this.style.display = this.oldblock ? this.oldblock : ""; if ( jQuery.css(this,"display") == "none" ) this.style.display = "block"; @@ -78,12 +79,13 @@ jQuery.fn.extend({ * @see show(String|Number,Function) */ hide: function(speed,callback){ + var visible = this.filter(":visible"); return speed ? - this.animate({ + visible.animate({ height: "hide", width: "hide", opacity: "hide" }, speed, callback) : - this.each(function(){ + visible.each(function(){ this.oldblock = this.oldblock || jQuery.css(this,"display"); if ( this.oldblock == "none" ) this.oldblock = "block"; @@ -108,11 +110,12 @@ jQuery.fn.extend({ * @cat Effects */ toggle: function( fn, fn2 ){ - return fn ? + var args = arguments; + return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ? this._toggle( fn, fn2 ) : this.each(function(){ jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ] - .apply( jQuery(this), arguments ); + .apply( jQuery(this), args ); }); }, @@ -352,23 +355,23 @@ jQuery.fn.extend({ jQuery.extend({ speed: function(speed, easing, fn) { - var opt = speed.constructor == Object ? speed : { + var opt = speed && speed.constructor == Object ? speed : { complete: fn || !fn && easing || - speed.constructor == Function && speed, + jQuery.isFunction( speed ) && speed, duration: speed, easing: fn && easing || easing && easing.constructor != Function && easing }; - opt.duration = (opt.duration.constructor == Number ? + opt.duration = (opt.duration && opt.duration.constructor == Number ? opt.duration : { slow: 600, fast: 200 }[opt.duration]) || 400; // Queueing - opt.oldComplete = opt.complete; + opt.old = opt.complete; opt.complete = function(){ jQuery.dequeue(this, "fx"); - if ( opt.oldComplete && opt.oldComplete.constructor == Function ) - opt.oldComplete.apply( this ); + if ( jQuery.isFunction( opt.old ) ) + opt.old.apply( this ); }; return opt; @@ -406,9 +409,11 @@ jQuery.extend({ var y = elem.style; // Store display property - var oldDisplay = jQuery.css(elem, 'display'); + var oldDisplay = jQuery.css(elem, "display"); + // Set display property to block for animation y.display = "block"; + // Make sure that nothing sneaks out y.overflow = "hidden"; @@ -482,7 +487,7 @@ jQuery.extend({ // Remember where we started, so that we can go back to it later elem.orig[prop] = this.cur(); - if(oldDisplay == 'none') { + if(oldDisplay == "none") { options.show = true; // Stupid IE, look what you made me do @@ -520,16 +525,16 @@ jQuery.extend({ if ( done ) { // Reset the overflow - y.overflow = ''; + y.overflow = ""; // Reset the display y.display = oldDisplay; - if (jQuery.css(elem, 'display') == 'none') - y.display = 'block'; + if (jQuery.css(elem, "display") == "none") + y.display = "block"; // Hide the element if the "hide" operation was done if ( options.hide ) - y.display = 'none'; + y.display = "none"; // Reset the properties, if the item has been hidden or shown if ( options.hide || options.show ) @@ -537,11 +542,11 @@ jQuery.extend({ if (p == "opacity") jQuery.attr(y, p, elem.orig[p]); else - y[p] = ''; + y[p] = ""; } // If a callback was provided, execute it - if ( done && options.complete && options.complete.constructor == Function ) + if ( done && jQuery.isFunction( options.complete ) ) // Execute the complete function options.complete.apply( elem ); } else {