2010-09-08 16:00:29 +00:00
|
|
|
(function( jQuery ) {
|
|
|
|
|
2009-01-05 01:14:36 +00:00
|
|
|
var elemdisplay = {},
|
2011-04-15 14:33:21 +00:00
|
|
|
iframe, iframeDoc,
|
2010-09-22 13:16:28 +00:00
|
|
|
rfxtypes = /^(?:toggle|show|hide)$/,
|
2010-12-09 09:23:45 +00:00
|
|
|
rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,
|
2009-01-14 23:09:52 +00:00
|
|
|
timerId,
|
2009-01-05 12:05:38 +00:00
|
|
|
fxAttrs = [
|
|
|
|
// height animations
|
|
|
|
[ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
|
|
|
|
// width animations
|
|
|
|
[ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
|
|
|
|
// opacity animations
|
|
|
|
[ "opacity" ]
|
2011-04-07 03:07:20 +00:00
|
|
|
],
|
2011-08-16 15:21:01 +00:00
|
|
|
fxNow;
|
2011-04-07 03:07:20 +00:00
|
|
|
|
2010-10-05 18:28:43 +00:00
|
|
|
jQuery.fn.extend({
|
|
|
|
show: function( speed, easing, callback ) {
|
2010-10-26 21:37:44 +00:00
|
|
|
var elem, display;
|
|
|
|
|
2010-10-05 18:28:43 +00:00
|
|
|
if ( speed || speed === 0 ) {
|
|
|
|
return this.animate( genFx("show", 3), speed, easing, callback);
|
2010-10-26 21:37:44 +00:00
|
|
|
|
2010-10-05 18:28:43 +00:00
|
|
|
} else {
|
|
|
|
for ( var i = 0, j = this.length; i < j; i++ ) {
|
2010-10-26 21:37:44 +00:00
|
|
|
elem = this[i];
|
|
|
|
|
2011-04-17 18:07:42 +00:00
|
|
|
if ( elem.style ) {
|
|
|
|
display = elem.style.display;
|
|
|
|
|
|
|
|
// Reset the inline display of this element to learn if it is
|
|
|
|
// being hidden by cascaded rules or not
|
|
|
|
if ( !jQuery._data(elem, "olddisplay") && display === "none" ) {
|
|
|
|
display = elem.style.display = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set elements which have been overridden with display: none
|
|
|
|
// in a stylesheet to whatever the default browser style is
|
|
|
|
// for such an element
|
|
|
|
if ( display === "" && jQuery.css( elem, "display" ) === "none" ) {
|
|
|
|
jQuery._data(elem, "olddisplay", defaultDisplay(elem.nodeName));
|
|
|
|
}
|
2009-02-09 15:58:12 +00:00
|
|
|
}
|
2009-02-16 21:20:51 +00:00
|
|
|
}
|
2009-02-09 15:58:12 +00:00
|
|
|
|
2010-10-05 19:53:35 +00:00
|
|
|
// Set the display of most of the elements in a second loop
|
2009-02-16 21:20:51 +00:00
|
|
|
// to avoid the constant reflow
|
2010-10-05 19:53:35 +00:00
|
|
|
for ( i = 0; i < j; i++ ) {
|
2010-10-26 21:37:44 +00:00
|
|
|
elem = this[i];
|
|
|
|
|
2011-04-17 18:07:42 +00:00
|
|
|
if ( elem.style ) {
|
|
|
|
display = elem.style.display;
|
|
|
|
|
|
|
|
if ( display === "" || display === "none" ) {
|
|
|
|
elem.style.display = jQuery._data(elem, "olddisplay") || "";
|
|
|
|
}
|
2010-10-26 21:37:44 +00:00
|
|
|
}
|
2008-12-19 18:21:12 +00:00
|
|
|
}
|
2009-03-23 01:55:17 +00:00
|
|
|
|
2008-12-19 18:21:12 +00:00
|
|
|
return this;
|
|
|
|
}
|
2007-01-07 21:43:38 +00:00
|
|
|
},
|
2008-05-13 01:45:58 +00:00
|
|
|
|
Added full support for easing in all shorthand effects methods (hide, show, toggle, fadeTo, slideUp, etc.). Previously, these methods could only be used with two of the three (speed, easing, callback) arguments, or, in the case of fadeTo, 3 of the 4 (speed, opacity, easing, callback) arguments. Added three more sets of tests to the series of "Chain" tests. Fixes #7014
2010-09-08 20:31:32 +00:00
|
|
|
hide: function( speed, easing, callback ) {
|
2010-01-19 19:52:35 +00:00
|
|
|
if ( speed || speed === 0 ) {
|
Added full support for easing in all shorthand effects methods (hide, show, toggle, fadeTo, slideUp, etc.). Previously, these methods could only be used with two of the three (speed, easing, callback) arguments, or, in the case of fadeTo, 3 of the 4 (speed, opacity, easing, callback) arguments. Added three more sets of tests to the series of "Chain" tests. Fixes #7014
2010-09-08 20:31:32 +00:00
|
|
|
return this.animate( genFx("hide", 3), speed, easing, callback);
|
2009-12-18 16:16:26 +00:00
|
|
|
|
2008-12-19 18:21:12 +00:00
|
|
|
} else {
|
2010-10-05 19:53:35 +00:00
|
|
|
for ( var i = 0, j = this.length; i < j; i++ ) {
|
2011-04-19 17:45:01 +00:00
|
|
|
if ( this[i].style ) {
|
|
|
|
var display = jQuery.css( this[i], "display" );
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2011-04-19 17:45:01 +00:00
|
|
|
if ( display !== "none" && !jQuery._data( this[i], "olddisplay" ) ) {
|
|
|
|
jQuery._data( this[i], "olddisplay", display );
|
|
|
|
}
|
2010-11-10 04:42:05 +00:00
|
|
|
}
|
2009-02-09 15:58:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set the display of the elements in a second loop
|
|
|
|
// to avoid the constant reflow
|
2010-10-05 19:53:35 +00:00
|
|
|
for ( i = 0; i < j; i++ ) {
|
2011-04-17 18:07:42 +00:00
|
|
|
if ( this[i].style ) {
|
|
|
|
this[i].style.display = "none";
|
|
|
|
}
|
2008-12-19 18:21:12 +00:00
|
|
|
}
|
2009-02-09 15:58:12 +00:00
|
|
|
|
2008-12-19 18:21:12 +00:00
|
|
|
return this;
|
|
|
|
}
|
2007-01-07 21:43:38 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// Save the old toggle function
|
|
|
|
_toggle: jQuery.fn.toggle,
|
2008-05-13 01:45:58 +00:00
|
|
|
|
Added full support for easing in all shorthand effects methods (hide, show, toggle, fadeTo, slideUp, etc.). Previously, these methods could only be used with two of the three (speed, easing, callback) arguments, or, in the case of fadeTo, 3 of the 4 (speed, opacity, easing, callback) arguments. Added three more sets of tests to the series of "Chain" tests. Fixes #7014
2010-09-08 20:31:32 +00:00
|
|
|
toggle: function( fn, fn2, callback ) {
|
2008-12-25 20:13:42 +00:00
|
|
|
var bool = typeof fn === "boolean";
|
|
|
|
|
2009-12-18 16:16:26 +00:00
|
|
|
if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) {
|
|
|
|
this._toggle.apply( this, arguments );
|
|
|
|
|
|
|
|
} else if ( fn == null || bool ) {
|
2009-12-22 00:58:13 +00:00
|
|
|
this.each(function() {
|
2009-12-18 16:16:26 +00:00
|
|
|
var state = bool ? fn : jQuery(this).is(":hidden");
|
|
|
|
jQuery(this)[ state ? "show" : "hide" ]();
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
Added full support for easing in all shorthand effects methods (hide, show, toggle, fadeTo, slideUp, etc.). Previously, these methods could only be used with two of the three (speed, easing, callback) arguments, or, in the case of fadeTo, 3 of the 4 (speed, opacity, easing, callback) arguments. Added three more sets of tests to the series of "Chain" tests. Fixes #7014
2010-09-08 20:31:32 +00:00
|
|
|
this.animate(genFx("toggle", 3), fn, fn2, callback);
|
2009-12-18 16:16:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
2007-01-07 21:43:38 +00:00
|
|
|
},
|
2008-05-13 01:45:58 +00:00
|
|
|
|
Added full support for easing in all shorthand effects methods (hide, show, toggle, fadeTo, slideUp, etc.). Previously, these methods could only be used with two of the three (speed, easing, callback) arguments, or, in the case of fadeTo, 3 of the 4 (speed, opacity, easing, callback) arguments. Added three more sets of tests to the series of "Chain" tests. Fixes #7014
2010-09-08 20:31:32 +00:00
|
|
|
fadeTo: function( speed, to, easing, callback ) {
|
2009-12-18 16:16:26 +00:00
|
|
|
return this.filter(":hidden").css("opacity", 0).show().end()
|
Added full support for easing in all shorthand effects methods (hide, show, toggle, fadeTo, slideUp, etc.). Previously, these methods could only be used with two of the three (speed, easing, callback) arguments, or, in the case of fadeTo, 3 of the 4 (speed, opacity, easing, callback) arguments. Added three more sets of tests to the series of "Chain" tests. Fixes #7014
2010-09-08 20:31:32 +00:00
|
|
|
.animate({opacity: to}, speed, easing, callback);
|
2007-01-07 21:43:38 +00:00
|
|
|
},
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2007-01-07 21:43:38 +00:00
|
|
|
animate: function( prop, speed, easing, callback ) {
|
2011-09-12 23:48:44 +00:00
|
|
|
var optall = jQuery.speed( speed, easing, callback );
|
2007-09-07 21:57:40 +00:00
|
|
|
|
2009-12-21 16:11:03 +00:00
|
|
|
if ( jQuery.isEmptyObject( prop ) ) {
|
2011-04-11 11:40:14 +00:00
|
|
|
return this.each( optall.complete, [ false ] );
|
2009-12-21 16:11:03 +00:00
|
|
|
}
|
|
|
|
|
2011-05-08 01:26:02 +00:00
|
|
|
// Do not change referenced properties as per-property easing will be lost
|
|
|
|
prop = jQuery.extend( {}, prop );
|
|
|
|
|
2011-09-19 20:08:00 +00:00
|
|
|
function doAnimation() {
|
2010-10-28 19:59:58 +00:00
|
|
|
// XXX 'this' does not always have a nodeName when running the
|
2010-10-05 18:28:43 +00:00
|
|
|
// test suite
|
|
|
|
|
2011-04-11 11:40:14 +00:00
|
|
|
if ( optall.queue === false ) {
|
|
|
|
jQuery._mark( this );
|
|
|
|
}
|
|
|
|
|
2011-05-08 00:46:38 +00:00
|
|
|
var opt = jQuery.extend( {}, optall ),
|
2010-10-05 19:53:35 +00:00
|
|
|
isElement = this.nodeType === 1,
|
|
|
|
hidden = isElement && jQuery(this).is(":hidden"),
|
2011-09-12 23:48:44 +00:00
|
|
|
name, val, p, e,
|
|
|
|
parts, start, end, unit,
|
|
|
|
method;
|
2011-04-14 13:21:08 +00:00
|
|
|
|
|
|
|
// will store per property easing and be used to determine when an animation is complete
|
|
|
|
opt.animatedProperties = {};
|
2009-03-23 01:55:17 +00:00
|
|
|
|
2008-04-29 23:34:50 +00:00
|
|
|
for ( p in prop ) {
|
2009-07-25 20:56:15 +00:00
|
|
|
|
2011-04-14 13:21:08 +00:00
|
|
|
// property name normalization
|
|
|
|
name = jQuery.camelCase( p );
|
2009-07-25 20:56:15 +00:00
|
|
|
if ( p !== name ) {
|
|
|
|
prop[ name ] = prop[ p ];
|
|
|
|
delete prop[ p ];
|
|
|
|
}
|
|
|
|
|
2011-05-08 00:46:38 +00:00
|
|
|
val = prop[ name ];
|
|
|
|
|
|
|
|
// easing resolution: per property > opt.specialEasing > opt.easing > 'swing' (default)
|
|
|
|
if ( jQuery.isArray( val ) ) {
|
|
|
|
opt.animatedProperties[ name ] = val[ 1 ];
|
2011-05-08 01:26:02 +00:00
|
|
|
val = prop[ name ] = val[ 0 ];
|
2011-05-08 00:46:38 +00:00
|
|
|
} else {
|
|
|
|
opt.animatedProperties[ name ] = opt.specialEasing && opt.specialEasing[ name ] || opt.easing || 'swing';
|
|
|
|
}
|
2011-04-14 13:21:08 +00:00
|
|
|
|
|
|
|
if ( val === "hide" && hidden || val === "show" && !hidden ) {
|
2011-05-08 00:46:38 +00:00
|
|
|
return opt.complete.call( this );
|
2009-11-27 19:28:42 +00:00
|
|
|
}
|
2009-12-18 16:16:26 +00:00
|
|
|
|
2011-04-15 13:18:21 +00:00
|
|
|
if ( isElement && ( name === "height" || name === "width" ) ) {
|
2007-07-05 04:27:46 +00:00
|
|
|
// Make sure that nothing sneaks out
|
2010-10-05 18:32:07 +00:00
|
|
|
// Record all 3 overflow attributes because IE does not
|
|
|
|
// change the overflow attribute when overflowX and
|
|
|
|
// overflowY are set to the same value
|
|
|
|
opt.overflow = [ this.style.overflow, this.style.overflowX, this.style.overflowY ];
|
2010-10-05 18:28:43 +00:00
|
|
|
|
|
|
|
// Set display property to inline-block for height/width
|
2011-09-12 23:48:44 +00:00
|
|
|
// animations on inline elements that are having width/height animated
|
2010-10-05 19:53:35 +00:00
|
|
|
if ( jQuery.css( this, "display" ) === "inline" &&
|
2010-10-09 01:29:41 +00:00
|
|
|
jQuery.css( this, "float" ) === "none" ) {
|
2011-09-12 23:48:44 +00:00
|
|
|
|
|
|
|
// inline-level elements accept inline-block;
|
|
|
|
// block-level elements need to be inline with layout
|
|
|
|
if ( !jQuery.support.inlineBlockNeedsLayout || defaultDisplay( this.nodeName ) === "inline" ) {
|
2010-10-05 18:28:43 +00:00
|
|
|
this.style.display = "inline-block";
|
2010-10-09 01:29:41 +00:00
|
|
|
|
2010-10-05 18:28:43 +00:00
|
|
|
} else {
|
2011-09-12 23:48:44 +00:00
|
|
|
this.style.zoom = 1;
|
2010-10-05 18:28:43 +00:00
|
|
|
}
|
|
|
|
}
|
2007-07-05 04:27:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-05 20:20:44 +00:00
|
|
|
if ( opt.overflow != null ) {
|
2007-07-05 04:27:46 +00:00
|
|
|
this.style.overflow = "hidden";
|
2009-11-27 19:28:42 +00:00
|
|
|
}
|
2009-12-18 16:16:26 +00:00
|
|
|
|
2011-04-14 13:21:08 +00:00
|
|
|
for ( p in prop ) {
|
2011-04-15 12:44:55 +00:00
|
|
|
e = new jQuery.fx( this, opt, p );
|
2011-05-08 00:46:38 +00:00
|
|
|
val = prop[ p ];
|
2007-09-07 21:57:40 +00:00
|
|
|
|
2011-09-12 23:48:44 +00:00
|
|
|
if ( rfxtypes.test( val ) ) {
|
|
|
|
// Tracks whether to show or hide based on private
|
|
|
|
// data attached to the element
|
|
|
|
method = jQuery._data( this, "toggle" + p ) || (val === "toggle" ? hidden ? "show" : "hide" : 0);
|
|
|
|
if ( method ) {
|
|
|
|
jQuery._data( this, "toggle" + p, method === "show" ? "hide" : "show" );
|
|
|
|
e[ method ]();
|
|
|
|
} else {
|
|
|
|
e[ val ]();
|
|
|
|
}
|
2009-12-18 16:16:26 +00:00
|
|
|
|
2009-11-27 19:28:42 +00:00
|
|
|
} else {
|
2011-05-08 00:46:38 +00:00
|
|
|
parts = rfxnum.exec( val );
|
2011-04-14 13:21:08 +00:00
|
|
|
start = e.cur();
|
2007-09-07 21:57:40 +00:00
|
|
|
|
|
|
|
if ( parts ) {
|
2011-04-14 13:21:08 +00:00
|
|
|
end = parseFloat( parts[2] );
|
2011-05-07 23:18:52 +00:00
|
|
|
unit = parts[3] || ( jQuery.cssNumber[ p ] ? "" : "px" );
|
2007-09-07 21:57:40 +00:00
|
|
|
|
|
|
|
// We need to compute starting value
|
2009-12-18 16:16:26 +00:00
|
|
|
if ( unit !== "px" ) {
|
2011-04-15 12:44:55 +00:00
|
|
|
jQuery.style( this, p, (end || 1) + unit);
|
2010-10-25 15:19:45 +00:00
|
|
|
start = ((end || 1) / e.cur()) * start;
|
2011-04-15 12:44:55 +00:00
|
|
|
jQuery.style( this, p, start + unit);
|
2007-09-07 21:57:40 +00:00
|
|
|
}
|
|
|
|
|
2007-09-15 02:40:42 +00:00
|
|
|
// If a +=/-= token was provided, we're doing a relative animation
|
2009-11-27 19:28:42 +00:00
|
|
|
if ( parts[1] ) {
|
2011-05-08 00:46:38 +00:00
|
|
|
end = ( (parts[ 1 ] === "-=" ? -1 : 1) * end ) + start;
|
2009-11-27 19:28:42 +00:00
|
|
|
}
|
2009-12-18 16:16:26 +00:00
|
|
|
|
2007-09-07 21:57:40 +00:00
|
|
|
e.custom( start, end, unit );
|
2009-12-18 16:16:26 +00:00
|
|
|
|
2009-11-27 19:28:42 +00:00
|
|
|
} else {
|
2007-09-07 21:57:40 +00:00
|
|
|
e.custom( start, val, "" );
|
2009-11-27 19:28:42 +00:00
|
|
|
}
|
2007-09-07 21:57:40 +00:00
|
|
|
}
|
2011-04-14 13:21:08 +00:00
|
|
|
}
|
2007-08-20 03:59:34 +00:00
|
|
|
|
|
|
|
// For JS strict compliance
|
|
|
|
return true;
|
2011-09-19 20:08:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return optall.queue === false ?
|
|
|
|
this.each( doAnimation ) :
|
|
|
|
this.queue( optall.queue || "fx", doAnimation );
|
2007-01-07 21:43:38 +00:00
|
|
|
},
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2009-12-22 00:58:13 +00:00
|
|
|
stop: function( clearQueue, gotoEnd ) {
|
2009-12-18 16:16:26 +00:00
|
|
|
if ( clearQueue ) {
|
2007-11-30 21:36:49 +00:00
|
|
|
this.queue([]);
|
2009-11-27 19:28:42 +00:00
|
|
|
}
|
2009-12-18 16:16:26 +00:00
|
|
|
|
2009-12-22 00:58:13 +00:00
|
|
|
this.each(function() {
|
2011-04-14 13:21:08 +00:00
|
|
|
var timers = jQuery.timers,
|
|
|
|
i = timers.length;
|
2011-09-12 23:48:44 +00:00
|
|
|
|
2011-04-11 11:40:14 +00:00
|
|
|
// clear marker counters if we know they won't be
|
|
|
|
if ( !gotoEnd ) {
|
|
|
|
jQuery._unmark( true, this );
|
|
|
|
}
|
2011-04-14 13:21:08 +00:00
|
|
|
while ( i-- ) {
|
2011-09-12 23:48:44 +00:00
|
|
|
if ( timers[ i ].elem === this ) {
|
|
|
|
if ( gotoEnd ) {
|
2007-11-30 21:36:49 +00:00
|
|
|
// force the next step to be the last
|
2011-09-12 23:48:44 +00:00
|
|
|
timers[ i ]( true );
|
|
|
|
} else {
|
|
|
|
timers[ i ].saveState();
|
2009-11-27 19:28:42 +00:00
|
|
|
}
|
2009-12-18 16:16:26 +00:00
|
|
|
|
2011-09-12 23:48:44 +00:00
|
|
|
timers.splice( i, 1 );
|
2007-11-30 21:36:49 +00:00
|
|
|
}
|
2009-11-27 19:28:42 +00:00
|
|
|
}
|
2007-11-30 21:36:49 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// start the next in the queue if the last step wasn't forced
|
2009-12-18 16:16:26 +00:00
|
|
|
if ( !gotoEnd ) {
|
2007-11-30 21:36:49 +00:00
|
|
|
this.dequeue();
|
2009-11-27 19:28:42 +00:00
|
|
|
}
|
2009-12-18 16:16:26 +00:00
|
|
|
|
2007-11-30 21:36:49 +00:00
|
|
|
return this;
|
2007-01-07 21:43:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2011-04-17 18:08:52 +00:00
|
|
|
// Animations created synchronously will run synchronously
|
|
|
|
function createFxNow() {
|
|
|
|
setTimeout( clearFxNow, 0 );
|
|
|
|
return ( fxNow = jQuery.now() );
|
|
|
|
}
|
|
|
|
|
|
|
|
function clearFxNow() {
|
|
|
|
fxNow = undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Generate parameters to create a standard animation
|
|
|
|
function genFx( type, num ) {
|
|
|
|
var obj = {};
|
|
|
|
|
2011-09-12 23:48:44 +00:00
|
|
|
jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice( 0, num )), function() {
|
2011-04-17 18:08:52 +00:00
|
|
|
obj[ this ] = type;
|
|
|
|
});
|
|
|
|
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2008-07-03 22:54:12 +00:00
|
|
|
// Generate shortcuts for custom animations
|
|
|
|
jQuery.each({
|
2011-09-12 23:48:44 +00:00
|
|
|
slideDown: genFx( "show", 1 ),
|
|
|
|
slideUp: genFx( "hide", 1 ),
|
|
|
|
slideToggle: genFx( "toggle", 1 ),
|
2008-07-03 22:54:12 +00:00
|
|
|
fadeIn: { opacity: "show" },
|
2010-10-17 18:26:32 +00:00
|
|
|
fadeOut: { opacity: "hide" },
|
|
|
|
fadeToggle: { opacity: "toggle" }
|
2009-12-22 00:58:13 +00:00
|
|
|
}, function( name, props ) {
|
Added full support for easing in all shorthand effects methods (hide, show, toggle, fadeTo, slideUp, etc.). Previously, these methods could only be used with two of the three (speed, easing, callback) arguments, or, in the case of fadeTo, 3 of the 4 (speed, opacity, easing, callback) arguments. Added three more sets of tests to the series of "Chain" tests. Fixes #7014
2010-09-08 20:31:32 +00:00
|
|
|
jQuery.fn[ name ] = function( speed, easing, callback ) {
|
|
|
|
return this.animate( props, speed, easing, callback );
|
2008-07-03 22:54:12 +00:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2007-01-07 21:43:38 +00:00
|
|
|
jQuery.extend({
|
2009-12-18 16:16:26 +00:00
|
|
|
speed: function( speed, easing, fn ) {
|
2011-09-12 23:48:44 +00:00
|
|
|
var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
|
2008-05-13 01:45:58 +00:00
|
|
|
complete: fn || !fn && easing ||
|
2007-01-14 06:22:20 +00:00
|
|
|
jQuery.isFunction( speed ) && speed,
|
2007-01-07 00:28:31 +00:00
|
|
|
duration: speed,
|
2011-09-12 23:48:44 +00:00
|
|
|
easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
|
2007-01-07 00:28:31 +00:00
|
|
|
};
|
2007-01-07 21:43:38 +00:00
|
|
|
|
2008-11-17 16:32:05 +00:00
|
|
|
opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
|
2011-09-12 23:48:44 +00:00
|
|
|
opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2007-01-07 21:43:38 +00:00
|
|
|
// Queueing
|
2007-01-14 06:22:20 +00:00
|
|
|
opt.old = opt.complete;
|
2011-04-11 11:40:14 +00:00
|
|
|
opt.complete = function( noUnmark ) {
|
2011-05-11 18:31:42 +00:00
|
|
|
if ( jQuery.isFunction( opt.old ) ) {
|
|
|
|
opt.old.call( this );
|
|
|
|
}
|
|
|
|
|
2009-11-27 19:28:42 +00:00
|
|
|
if ( opt.queue !== false ) {
|
2011-09-19 20:08:00 +00:00
|
|
|
jQuery.dequeue( this, opt.queue || "fx" );
|
2011-04-11 11:40:14 +00:00
|
|
|
} else if ( noUnmark !== false ) {
|
|
|
|
jQuery._unmark( this );
|
2009-11-27 19:28:42 +00:00
|
|
|
}
|
2007-01-07 21:43:38 +00:00
|
|
|
};
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2007-01-07 21:43:38 +00:00
|
|
|
return opt;
|
|
|
|
},
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2007-03-24 03:12:12 +00:00
|
|
|
easing: {
|
|
|
|
linear: function( p, n, firstNum, diff ) {
|
|
|
|
return firstNum + diff * p;
|
|
|
|
},
|
|
|
|
swing: function( p, n, firstNum, diff ) {
|
|
|
|
return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
|
|
|
|
}
|
|
|
|
},
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2007-03-17 02:02:01 +00:00
|
|
|
timers: [],
|
|
|
|
|
2009-12-18 16:16:26 +00:00
|
|
|
fx: function( elem, options, prop ) {
|
2007-09-07 21:57:40 +00:00
|
|
|
this.options = options;
|
|
|
|
this.elem = elem;
|
|
|
|
this.prop = prop;
|
2007-01-07 21:43:38 +00:00
|
|
|
|
2011-04-14 13:21:08 +00:00
|
|
|
options.orig = options.orig || {};
|
2007-09-07 21:57:40 +00:00
|
|
|
}
|
2007-01-07 21:43:38 +00:00
|
|
|
|
2007-09-07 21:57:40 +00:00
|
|
|
});
|
2007-01-07 21:43:38 +00:00
|
|
|
|
2007-09-07 21:57:40 +00:00
|
|
|
jQuery.fx.prototype = {
|
|
|
|
// Simple function for setting a style value
|
2009-12-18 16:16:26 +00:00
|
|
|
update: function() {
|
2009-11-27 19:28:42 +00:00
|
|
|
if ( this.options.step ) {
|
2008-05-12 19:45:02 +00:00
|
|
|
this.options.step.call( this.elem, this.now, this );
|
2009-11-27 19:28:42 +00:00
|
|
|
}
|
2009-12-18 16:16:26 +00:00
|
|
|
|
2011-09-12 23:48:44 +00:00
|
|
|
(jQuery.fx.step[ this.prop ] || jQuery.fx.step._default)( this );
|
2007-09-07 21:57:40 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// Get the current size
|
2010-09-16 14:00:56 +00:00
|
|
|
cur: function() {
|
2011-09-12 23:48:44 +00:00
|
|
|
if ( this.elem[ this.prop ] != null && (!this.elem.style || this.elem.style[ this.prop ] == null) ) {
|
2007-09-07 21:57:40 +00:00
|
|
|
return this.elem[ this.prop ];
|
2009-11-27 19:28:42 +00:00
|
|
|
}
|
2009-12-18 16:16:26 +00:00
|
|
|
|
2011-02-17 16:26:23 +00:00
|
|
|
var parsed,
|
|
|
|
r = jQuery.css( this.elem, this.prop );
|
|
|
|
// Empty strings, null, undefined and "auto" are converted to 0,
|
|
|
|
// complex values such as "rotate(1rad)" are returned as is,
|
|
|
|
// simple values such as "10px" are parsed to Float.
|
|
|
|
return isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" ? 0 : r : parsed;
|
2007-09-07 21:57:40 +00:00
|
|
|
},
|
2007-09-04 00:28:22 +00:00
|
|
|
|
2007-09-07 21:57:40 +00:00
|
|
|
// Start an animation from one number to another
|
2009-12-18 16:16:26 +00:00
|
|
|
custom: function( from, to, unit ) {
|
2010-11-09 16:09:07 +00:00
|
|
|
var self = this,
|
2011-08-16 15:21:01 +00:00
|
|
|
fx = jQuery.fx;
|
2010-11-09 16:09:07 +00:00
|
|
|
|
2011-04-07 03:07:20 +00:00
|
|
|
this.startTime = fxNow || createFxNow();
|
2007-09-07 21:57:40 +00:00
|
|
|
this.end = to;
|
2011-09-12 23:48:44 +00:00
|
|
|
this.now = this.start = from;
|
2007-09-07 21:57:40 +00:00
|
|
|
this.pos = this.state = 0;
|
2011-09-12 23:48:44 +00:00
|
|
|
this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" );
|
2007-09-07 21:57:40 +00:00
|
|
|
|
2009-12-18 16:16:26 +00:00
|
|
|
function t( gotoEnd ) {
|
2011-09-12 23:48:44 +00:00
|
|
|
return self.step( gotoEnd );
|
2007-09-07 21:57:40 +00:00
|
|
|
}
|
2007-03-17 02:02:01 +00:00
|
|
|
|
2007-09-07 21:57:40 +00:00
|
|
|
t.elem = this.elem;
|
2011-09-12 23:48:44 +00:00
|
|
|
t.saveState = function() {
|
|
|
|
if ( self.options.hide && jQuery._data( self.elem, "fxshow" + self.prop ) === undefined ) {
|
|
|
|
jQuery._data( self.elem, "fxshow" + self.prop, self.start );
|
|
|
|
}
|
|
|
|
};
|
2007-03-17 02:02:01 +00:00
|
|
|
|
2009-11-27 19:28:42 +00:00
|
|
|
if ( t() && jQuery.timers.push(t) && !timerId ) {
|
2011-08-16 15:21:01 +00:00
|
|
|
timerId = setInterval( fx.tick, fx.interval );
|
2009-11-27 19:28:42 +00:00
|
|
|
}
|
2007-09-07 21:57:40 +00:00
|
|
|
},
|
2007-01-07 21:43:38 +00:00
|
|
|
|
2007-09-07 21:57:40 +00:00
|
|
|
// Simple 'show' function
|
2009-12-18 16:16:26 +00:00
|
|
|
show: function() {
|
2011-09-12 23:48:44 +00:00
|
|
|
var dataShow = jQuery._data( this.elem, "fxshow" + this.prop );
|
|
|
|
|
2007-09-07 21:57:40 +00:00
|
|
|
// Remember where we started, so that we can go back to it later
|
2011-09-12 23:48:44 +00:00
|
|
|
this.options.orig[ this.prop ] = dataShow || jQuery.style( this.elem, this.prop );
|
2007-09-07 21:57:40 +00:00
|
|
|
this.options.show = true;
|
2007-01-07 21:43:38 +00:00
|
|
|
|
2007-09-07 21:57:40 +00:00
|
|
|
// Begin the animation
|
2011-09-12 23:48:44 +00:00
|
|
|
// Make sure that we start at a small width/height to avoid any flash of content
|
|
|
|
if ( dataShow !== undefined ) {
|
|
|
|
// This show is picking up where a previous hide or show left off
|
|
|
|
this.custom( this.cur(), dataShow );
|
|
|
|
} else {
|
|
|
|
this.custom( this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur() );
|
|
|
|
}
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2007-09-07 21:57:40 +00:00
|
|
|
// Start by showing the element
|
2009-12-18 16:16:26 +00:00
|
|
|
jQuery( this.elem ).show();
|
2007-09-07 21:57:40 +00:00
|
|
|
},
|
2007-01-07 21:43:38 +00:00
|
|
|
|
2007-09-07 21:57:40 +00:00
|
|
|
// Simple 'hide' function
|
2009-12-18 16:16:26 +00:00
|
|
|
hide: function() {
|
2007-09-07 21:57:40 +00:00
|
|
|
// Remember where we started, so that we can go back to it later
|
2011-09-12 23:48:44 +00:00
|
|
|
this.options.orig[ this.prop ] = jQuery._data( this.elem, "fxshow" + this.prop ) || jQuery.style( this.elem, this.prop );
|
2007-09-07 21:57:40 +00:00
|
|
|
this.options.hide = true;
|
2007-01-07 21:43:38 +00:00
|
|
|
|
2007-09-07 21:57:40 +00:00
|
|
|
// Begin the animation
|
2011-09-12 23:48:44 +00:00
|
|
|
this.custom( this.cur(), 0 );
|
2007-09-07 21:57:40 +00:00
|
|
|
},
|
2007-01-07 21:43:38 +00:00
|
|
|
|
2007-09-07 21:57:40 +00:00
|
|
|
// Each step of an animation
|
2009-12-18 16:16:26 +00:00
|
|
|
step: function( gotoEnd ) {
|
2011-04-07 03:07:20 +00:00
|
|
|
var t = fxNow || createFxNow(),
|
2011-04-14 13:21:08 +00:00
|
|
|
done = true,
|
|
|
|
elem = this.elem,
|
2011-04-15 12:44:55 +00:00
|
|
|
options = this.options,
|
2011-09-12 23:48:44 +00:00
|
|
|
p, n;
|
2007-01-07 21:43:38 +00:00
|
|
|
|
2011-04-14 13:21:08 +00:00
|
|
|
if ( gotoEnd || t >= options.duration + this.startTime ) {
|
2007-09-07 21:57:40 +00:00
|
|
|
this.now = this.end;
|
|
|
|
this.pos = this.state = 1;
|
|
|
|
this.update();
|
2007-01-07 21:43:38 +00:00
|
|
|
|
2011-04-14 13:21:08 +00:00
|
|
|
options.animatedProperties[ this.prop ] = true;
|
2007-01-07 21:43:38 +00:00
|
|
|
|
2011-09-12 23:48:44 +00:00
|
|
|
for ( p in options.animatedProperties ) {
|
|
|
|
if ( options.animatedProperties[ p ] !== true ) {
|
2007-09-07 21:57:40 +00:00
|
|
|
done = false;
|
2009-11-27 19:28:42 +00:00
|
|
|
}
|
|
|
|
}
|
2009-12-18 16:16:26 +00:00
|
|
|
|
2007-09-07 21:57:40 +00:00
|
|
|
if ( done ) {
|
2010-10-05 18:28:43 +00:00
|
|
|
// Reset the overflow
|
2011-04-14 13:21:08 +00:00
|
|
|
if ( options.overflow != null && !jQuery.support.shrinkWrapBlocks ) {
|
2010-11-09 16:09:07 +00:00
|
|
|
|
2011-09-12 23:48:44 +00:00
|
|
|
jQuery.each( [ "", "X", "Y" ], function( index, value ) {
|
|
|
|
elem.style[ "overflow" + value ] = options.overflow[ index ];
|
2011-04-08 15:41:14 +00:00
|
|
|
});
|
2007-09-07 21:57:40 +00:00
|
|
|
}
|
2007-01-07 21:43:38 +00:00
|
|
|
|
2007-09-07 21:57:40 +00:00
|
|
|
// Hide the element if the "hide" operation was done
|
2011-04-14 13:21:08 +00:00
|
|
|
if ( options.hide ) {
|
2011-09-12 23:48:44 +00:00
|
|
|
jQuery( elem ).hide();
|
2009-11-27 19:28:42 +00:00
|
|
|
}
|
2009-12-18 16:16:26 +00:00
|
|
|
|
2007-09-07 21:57:40 +00:00
|
|
|
// Reset the properties, if the item has been hidden or shown
|
2011-04-14 13:21:08 +00:00
|
|
|
if ( options.hide || options.show ) {
|
2011-09-12 23:48:44 +00:00
|
|
|
for ( p in options.animatedProperties ) {
|
|
|
|
jQuery.style( elem, p, options.orig[ p ] );
|
|
|
|
jQuery.removeData( elem, "fxshow" + p, true );
|
|
|
|
// Toggle data is no longer needed
|
|
|
|
jQuery.removeData( elem, "toggle" + p, true );
|
2009-11-27 19:28:42 +00:00
|
|
|
}
|
|
|
|
}
|
2009-12-18 16:16:26 +00:00
|
|
|
|
2007-09-07 21:57:40 +00:00
|
|
|
// Execute the complete function
|
2011-04-14 13:21:08 +00:00
|
|
|
options.complete.call( elem );
|
2009-01-14 23:09:52 +00:00
|
|
|
}
|
2007-09-07 21:57:40 +00:00
|
|
|
|
|
|
|
return false;
|
2009-12-18 16:16:26 +00:00
|
|
|
|
2007-09-07 21:57:40 +00:00
|
|
|
} else {
|
2011-04-14 13:21:08 +00:00
|
|
|
// classical easing cannot be used with an Infinity duration
|
|
|
|
if ( options.duration == Infinity ) {
|
|
|
|
this.now = t;
|
|
|
|
} else {
|
2011-04-15 12:44:55 +00:00
|
|
|
n = t - this.startTime;
|
2011-04-14 13:21:08 +00:00
|
|
|
this.state = n / options.duration;
|
2011-05-08 00:46:38 +00:00
|
|
|
|
2011-04-14 13:21:08 +00:00
|
|
|
// Perform the easing function, defaults to swing
|
2011-09-12 23:48:44 +00:00
|
|
|
this.pos = jQuery.easing[ options.animatedProperties[this.prop] ]( this.state, n, 0, 1, options.duration );
|
|
|
|
this.now = this.start + ( (this.end - this.start) * this.pos );
|
2011-04-14 13:21:08 +00:00
|
|
|
}
|
2007-09-07 21:57:40 +00:00
|
|
|
// Perform the next step of the animation
|
|
|
|
this.update();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2007-01-07 21:43:38 +00:00
|
|
|
}
|
2007-09-07 21:57:40 +00:00
|
|
|
};
|
|
|
|
|
2008-04-29 23:34:50 +00:00
|
|
|
jQuery.extend( jQuery.fx, {
|
2009-12-18 16:16:26 +00:00
|
|
|
tick: function() {
|
2011-09-12 23:48:44 +00:00
|
|
|
var timer,
|
|
|
|
timers = jQuery.timers,
|
|
|
|
i = 0;
|
|
|
|
|
|
|
|
for ( ; i < timers.length; i++ ) {
|
|
|
|
timer = timers[ i ];
|
|
|
|
// Checks the timer has not already been removed
|
|
|
|
if ( !timer() && timers[ i ] === timer ) {
|
|
|
|
timers.splice( i--, 1 );
|
2009-11-27 19:28:42 +00:00
|
|
|
}
|
|
|
|
}
|
2009-12-18 16:16:26 +00:00
|
|
|
|
2009-11-27 19:28:42 +00:00
|
|
|
if ( !timers.length ) {
|
2009-06-02 02:14:58 +00:00
|
|
|
jQuery.fx.stop();
|
2009-11-27 19:28:42 +00:00
|
|
|
}
|
2009-06-02 02:14:58 +00:00
|
|
|
},
|
2010-10-05 18:38:19 +00:00
|
|
|
|
2010-06-25 14:24:36 +00:00
|
|
|
interval: 13,
|
2010-10-05 18:38:19 +00:00
|
|
|
|
2009-12-18 16:16:26 +00:00
|
|
|
stop: function() {
|
2009-06-02 02:14:58 +00:00
|
|
|
clearInterval( timerId );
|
|
|
|
timerId = null;
|
|
|
|
},
|
2010-10-05 18:38:19 +00:00
|
|
|
|
2009-12-18 16:16:26 +00:00
|
|
|
speeds: {
|
2008-05-13 01:45:58 +00:00
|
|
|
slow: 600,
|
2010-03-01 17:44:56 +00:00
|
|
|
fast: 200,
|
|
|
|
// Default speed
|
|
|
|
_default: 400
|
2007-09-07 21:57:40 +00:00
|
|
|
},
|
2009-06-02 02:14:58 +00:00
|
|
|
|
2008-04-29 23:34:50 +00:00
|
|
|
step: {
|
2009-12-18 16:16:26 +00:00
|
|
|
opacity: function( fx ) {
|
2010-09-16 14:00:56 +00:00
|
|
|
jQuery.style( fx.elem, "opacity", fx.now );
|
2008-04-29 23:34:50 +00:00
|
|
|
},
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2009-12-18 16:16:26 +00:00
|
|
|
_default: function( fx ) {
|
2009-11-27 19:28:42 +00:00
|
|
|
if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
|
2011-09-12 23:48:44 +00:00
|
|
|
fx.elem.style[ fx.prop ] = fx.now + fx.unit;
|
2009-11-27 19:28:42 +00:00
|
|
|
} else {
|
2009-01-02 23:32:10 +00:00
|
|
|
fx.elem[ fx.prop ] = fx.now;
|
2009-11-27 19:28:42 +00:00
|
|
|
}
|
2008-04-29 23:34:50 +00:00
|
|
|
}
|
2007-09-07 21:57:40 +00:00
|
|
|
}
|
2008-04-29 23:34:50 +00:00
|
|
|
});
|
2009-10-26 22:07:57 +00:00
|
|
|
|
2011-09-12 23:48:44 +00:00
|
|
|
// Adds width/height step functions
|
|
|
|
// Do not set anything below 0
|
|
|
|
jQuery.each([ "width", "height" ], function( i, prop ) {
|
|
|
|
jQuery.fx.step[ prop ] = function( fx ) {
|
|
|
|
jQuery.style( fx.elem, prop, Math.max(0, fx.now) );
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2009-10-26 22:07:57 +00:00
|
|
|
if ( jQuery.expr && jQuery.expr.filters ) {
|
2009-12-22 00:58:13 +00:00
|
|
|
jQuery.expr.filters.animated = function( elem ) {
|
|
|
|
return jQuery.grep(jQuery.timers, function( fn ) {
|
2009-10-26 22:07:57 +00:00
|
|
|
return elem === fn.elem;
|
|
|
|
}).length;
|
|
|
|
};
|
2009-11-07 16:22:35 +00:00
|
|
|
}
|
2010-09-08 16:00:29 +00:00
|
|
|
|
2011-04-15 12:44:55 +00:00
|
|
|
// Try to restore the default display value of an element
|
2010-10-09 01:29:41 +00:00
|
|
|
function defaultDisplay( nodeName ) {
|
2011-04-12 15:48:07 +00:00
|
|
|
|
2010-10-09 01:29:41 +00:00
|
|
|
if ( !elemdisplay[ nodeName ] ) {
|
|
|
|
|
2011-05-20 15:22:52 +00:00
|
|
|
var body = document.body,
|
|
|
|
elem = jQuery( "<" + nodeName + ">" ).appendTo( body ),
|
2011-04-13 17:43:52 +00:00
|
|
|
display = elem.css( "display" );
|
2011-04-12 17:47:27 +00:00
|
|
|
|
2011-04-13 19:43:15 +00:00
|
|
|
elem.remove();
|
2011-04-12 17:47:27 +00:00
|
|
|
|
2011-04-15 14:33:21 +00:00
|
|
|
// If the simple way fails,
|
|
|
|
// get element's real default display by attaching it to a temp iframe
|
2011-04-13 17:43:52 +00:00
|
|
|
if ( display === "none" || display === "" ) {
|
|
|
|
// No iframe to use yet, so create it
|
2011-04-13 17:58:17 +00:00
|
|
|
if ( !iframe ) {
|
2011-04-13 17:43:52 +00:00
|
|
|
iframe = document.createElement( "iframe" );
|
2011-04-13 19:43:15 +00:00
|
|
|
iframe.frameBorder = iframe.width = iframe.height = 0;
|
|
|
|
}
|
2010-10-09 01:29:41 +00:00
|
|
|
|
2011-05-20 15:22:52 +00:00
|
|
|
body.appendChild( iframe );
|
2011-04-13 17:43:52 +00:00
|
|
|
|
2011-04-13 19:43:15 +00:00
|
|
|
// Create a cacheable copy of the iframe document on first call.
|
2011-05-20 15:22:52 +00:00
|
|
|
// IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML
|
|
|
|
// document to it; WebKit & Firefox won't allow reusing the iframe document.
|
2011-04-13 19:43:15 +00:00
|
|
|
if ( !iframeDoc || !iframe.createElement ) {
|
2011-04-13 17:43:52 +00:00
|
|
|
iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
|
2011-05-20 15:22:52 +00:00
|
|
|
iframeDoc.write( ( document.compatMode === "CSS1Compat" ? "<!doctype html>" : "" ) + "<html><body>" );
|
|
|
|
iframeDoc.close();
|
2011-04-13 17:43:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
elem = iframeDoc.createElement( nodeName );
|
|
|
|
|
|
|
|
iframeDoc.body.appendChild( elem );
|
|
|
|
|
2011-04-13 19:43:15 +00:00
|
|
|
display = jQuery.css( elem, "display" );
|
2011-04-13 17:43:52 +00:00
|
|
|
|
2011-05-20 15:22:52 +00:00
|
|
|
body.removeChild( iframe );
|
2010-10-09 01:29:41 +00:00
|
|
|
}
|
2011-04-12 17:47:27 +00:00
|
|
|
|
2011-04-12 15:48:07 +00:00
|
|
|
// Store the correct default display
|
2010-10-09 01:29:41 +00:00
|
|
|
elemdisplay[ nodeName ] = display;
|
|
|
|
}
|
|
|
|
|
|
|
|
return elemdisplay[ nodeName ];
|
|
|
|
}
|
|
|
|
|
2010-09-08 16:00:29 +00:00
|
|
|
})( jQuery );
|