X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Ffx%2Ffx.js;h=ece0cea8c2e81b820df21649f4046cc8652e8d7b;hb=8507faea6ed79e46a0461bec9b73879cd700e8ab;hp=6dd3279d89ab645be4115f55c596c2b8bd16557d;hpb=0798c6e64e4e0c984d5ece50ade61827c2105c39;p=jquery.git diff --git a/src/fx/fx.js b/src/fx/fx.js index 6dd3279..ece0cea 100644 --- a/src/fx/fx.js +++ b/src/fx/fx.js @@ -33,16 +33,18 @@ jQuery.fn.extend({ * @see hide(String|Number,Function) */ show: function(speed,callback){ - return speed ? - this.animate({ + var hidden = this.filter(":hidden"); + speed ? + 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"; }); + return this; }, /** @@ -78,17 +80,19 @@ jQuery.fn.extend({ * @see show(String|Number,Function) */ hide: function(speed,callback){ - return speed ? - this.animate({ + var visible = this.filter(":visible"); + speed ? + 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"; this.style.display = "none"; }); + return this; }, // Save the old toggle function @@ -108,11 +112,12 @@ jQuery.fn.extend({ * @cat Effects */ toggle: function( fn, fn2 ){ - return fn ? + var args = arguments; + return fn && fn.constructor == Function && fn2 && fn2.constructor == Function ? this._toggle( fn, fn2 ) : this.each(function(){ jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ] - .apply( jQuery(this), arguments ); + .apply( jQuery(this), args ); }); }, @@ -352,14 +357,14 @@ 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, + speed && speed.constructor == Function && 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;