2013-09-09 15:26:21 +00:00
|
|
|
define(function( require ) {
|
2013-08-15 18:15:49 +00:00
|
|
|
|
2013-09-09 15:26:21 +00:00
|
|
|
var
|
|
|
|
jQuery = require( "./core" ),
|
|
|
|
pnum = require( "./var/pnum" ),
|
|
|
|
cssExpand = require( "./css/var/cssExpand" ),
|
|
|
|
isHidden = require( "./css/var/isHidden" ),
|
|
|
|
defaultDisplay = require( "./css/defaultDisplay" ),
|
2013-09-10 00:13:01 +00:00
|
|
|
support = require( "./effects/support" ),
|
2013-09-09 15:26:21 +00:00
|
|
|
|
|
|
|
fxNow, timerId,
|
2010-09-22 13:16:28 +00:00
|
|
|
rfxtypes = /^(?:toggle|show|hide)$/,
|
2013-08-15 18:15:49 +00:00
|
|
|
rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ),
|
2012-05-23 03:04:45 +00:00
|
|
|
rrun = /queueHooks$/,
|
2012-05-11 20:20:32 +00:00
|
|
|
animationPrefilters = [ defaultPrefilter ],
|
2012-04-23 19:05:12 +00:00
|
|
|
tweeners = {
|
|
|
|
"*": [function( prop, value ) {
|
2013-05-09 02:56:51 +00:00
|
|
|
var tween = this.createTween( prop, value ),
|
2012-06-26 17:48:31 +00:00
|
|
|
target = tween.cur(),
|
2013-05-09 02:56:51 +00:00
|
|
|
parts = rfxnum.exec( value ),
|
|
|
|
unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
|
|
|
|
|
|
|
|
// Starting value computation is required for potential unit mismatches
|
|
|
|
start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) &&
|
|
|
|
rfxnum.exec( jQuery.css( tween.elem, prop ) ),
|
2012-09-15 15:57:01 +00:00
|
|
|
scale = 1,
|
|
|
|
maxIterations = 20;
|
2012-04-23 19:05:12 +00:00
|
|
|
|
2013-05-09 02:56:51 +00:00
|
|
|
if ( start && start[ 3 ] !== unit ) {
|
|
|
|
// Trust units reported by jQuery.css
|
|
|
|
unit = unit || start[ 3 ];
|
|
|
|
|
|
|
|
// Make sure we update the tween properties later on
|
|
|
|
parts = parts || [];
|
|
|
|
|
|
|
|
// Iteratively approximate from a nonzero starting point
|
|
|
|
start = +target || 1;
|
2010-10-26 21:37:44 +00:00
|
|
|
|
2013-05-09 02:56:51 +00:00
|
|
|
do {
|
|
|
|
// If previous iteration zeroed out, double until we get *something*
|
|
|
|
// Use a string for doubling factor so we don't accidentally see scale as unchanged below
|
|
|
|
scale = scale || ".5";
|
|
|
|
|
|
|
|
// Adjust and apply
|
|
|
|
start = start / scale;
|
|
|
|
jQuery.style( tween.elem, prop, start + unit );
|
|
|
|
|
|
|
|
// Update scale, tolerating zero or NaN from tween.cur()
|
|
|
|
// And breaking the loop if scale is unchanged or perfect, or if we've just had enough
|
|
|
|
} while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update tween properties
|
|
|
|
if ( parts ) {
|
2013-05-26 20:02:32 +00:00
|
|
|
start = tween.start = +start || +target || 0;
|
2012-04-23 19:05:12 +00:00
|
|
|
tween.unit = unit;
|
|
|
|
// If a +=/-= token was provided, we're doing a relative animation
|
2013-05-09 02:56:51 +00:00
|
|
|
tween.end = parts[ 1 ] ?
|
|
|
|
start + ( parts[ 1 ] + 1 ) * parts[ 2 ] :
|
|
|
|
+parts[ 2 ];
|
2012-04-23 19:05:12 +00:00
|
|
|
}
|
2013-05-09 02:56:51 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
return tween;
|
|
|
|
}]
|
2012-05-29 02:25:04 +00:00
|
|
|
};
|
2010-10-26 21:37:44 +00:00
|
|
|
|
2013-09-09 15:26:21 +00:00
|
|
|
// Dependencies not needed as vars
|
2013-09-10 00:13:01 +00:00
|
|
|
require( "./core/init" );
|
2013-09-09 15:26:21 +00:00
|
|
|
require( "./effects/Tween" );
|
|
|
|
require( "./queue" );
|
|
|
|
require( "./css" );
|
|
|
|
require( "./deferred" );
|
|
|
|
require( "./traversing" );
|
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
// Animations created synchronously will run synchronously
|
|
|
|
function createFxNow() {
|
|
|
|
setTimeout(function() {
|
|
|
|
fxNow = undefined;
|
2012-12-10 08:00:12 +00:00
|
|
|
});
|
2012-04-23 19:05:12 +00:00
|
|
|
return ( fxNow = jQuery.now() );
|
|
|
|
}
|
2010-10-26 21:37:44 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
// Generate parameters to create a standard animation
|
|
|
|
function genFx( type, includeWidth ) {
|
|
|
|
var which,
|
|
|
|
attrs = { height: type },
|
|
|
|
i = 0;
|
|
|
|
|
|
|
|
// if we include width, step value is 1 to do all cssExpand values,
|
|
|
|
// if we don't include width, step value is 2 to skip over Left and Right
|
|
|
|
includeWidth = includeWidth? 1 : 0;
|
|
|
|
for( ; i < 4 ; i += 2 - includeWidth ) {
|
|
|
|
which = cssExpand[ i ];
|
|
|
|
attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( includeWidth ) {
|
|
|
|
attrs.opacity = attrs.width = type;
|
|
|
|
}
|
|
|
|
|
|
|
|
return attrs;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-09 02:56:51 +00:00
|
|
|
function createTween( value, prop, animation ) {
|
|
|
|
var tween,
|
|
|
|
collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
|
|
|
|
index = 0,
|
|
|
|
length = collection.length;
|
|
|
|
for ( ; index < length; index++ ) {
|
|
|
|
if ( (tween = collection[ index ].call( animation, prop, value )) ) {
|
2012-05-18 17:48:24 +00:00
|
|
|
|
2013-05-09 02:56:51 +00:00
|
|
|
// we're done with this property
|
|
|
|
return tween;
|
2012-04-23 19:05:12 +00:00
|
|
|
}
|
2013-05-09 02:56:51 +00:00
|
|
|
}
|
2012-04-23 19:05:12 +00:00
|
|
|
}
|
2011-04-17 18:07:42 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
function defaultPrefilter( elem, props, opts ) {
|
|
|
|
/* jshint validthis: true */
|
2013-09-10 20:09:58 +00:00
|
|
|
var prop, value, toggle, tween, hooks, oldfire, display, dDisplay,
|
2013-09-09 16:22:37 +00:00
|
|
|
anim = this,
|
|
|
|
orig = {},
|
|
|
|
style = elem.style,
|
|
|
|
hidden = elem.nodeType && isHidden( elem ),
|
|
|
|
dataShow = jQuery._data( elem, "fxshow" );
|
|
|
|
|
|
|
|
// handle queue: false promises
|
|
|
|
if ( !opts.queue ) {
|
|
|
|
hooks = jQuery._queueHooks( elem, "fx" );
|
|
|
|
if ( hooks.unqueued == null ) {
|
|
|
|
hooks.unqueued = 0;
|
|
|
|
oldfire = hooks.empty.fire;
|
|
|
|
hooks.empty.fire = function() {
|
|
|
|
if ( !hooks.unqueued ) {
|
|
|
|
oldfire();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
hooks.unqueued++;
|
|
|
|
|
|
|
|
anim.always(function() {
|
|
|
|
// doing this makes sure that the complete handler will be called
|
|
|
|
// before this completes
|
|
|
|
anim.always(function() {
|
|
|
|
hooks.unqueued--;
|
|
|
|
if ( !jQuery.queue( elem, "fx" ).length ) {
|
|
|
|
hooks.empty.fire();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// height/width overflow pass
|
|
|
|
if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
|
|
|
|
// Make sure that nothing sneaks out
|
|
|
|
// Record all 3 overflow attributes because IE does not
|
|
|
|
// change the overflow attribute when overflowX and
|
|
|
|
// overflowY are set to the same value
|
|
|
|
opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
|
|
|
|
|
|
|
|
// Set display property to inline-block for height/width
|
|
|
|
// animations on inline elements that are having width/height animated
|
2013-09-10 20:09:58 +00:00
|
|
|
display = jQuery.css( elem, "display" );
|
|
|
|
dDisplay = defaultDisplay( elem.nodeName );
|
|
|
|
if ( display === "none" ) {
|
|
|
|
display = dDisplay;
|
|
|
|
}
|
|
|
|
if ( display === "inline" &&
|
2013-09-09 16:22:37 +00:00
|
|
|
jQuery.css( elem, "float" ) === "none" ) {
|
|
|
|
|
|
|
|
// inline-level elements accept inline-block;
|
|
|
|
// block-level elements need to be inline with layout
|
2013-09-10 20:09:58 +00:00
|
|
|
if ( !support.inlineBlockNeedsLayout || dDisplay === "inline" ) {
|
2013-09-09 16:22:37 +00:00
|
|
|
style.display = "inline-block";
|
|
|
|
} else {
|
|
|
|
style.zoom = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( opts.overflow ) {
|
|
|
|
style.overflow = "hidden";
|
|
|
|
if ( !support.shrinkWrapBlocks() ) {
|
|
|
|
anim.always(function() {
|
|
|
|
style.overflow = opts.overflow[ 0 ];
|
|
|
|
style.overflowX = opts.overflow[ 1 ];
|
|
|
|
style.overflowY = opts.overflow[ 2 ];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// show/hide pass
|
|
|
|
for ( prop in props ) {
|
|
|
|
value = props[ prop ];
|
|
|
|
if ( rfxtypes.exec( value ) ) {
|
|
|
|
delete props[ prop ];
|
|
|
|
toggle = toggle || value === "toggle";
|
|
|
|
if ( value === ( hidden ? "hide" : "show" ) ) {
|
|
|
|
|
|
|
|
// If there is dataShow left over from a stopped hide or show and we are going to proceed with show, we should pretend to be hidden
|
|
|
|
if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
|
|
|
|
hidden = true;
|
|
|
|
} else {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !jQuery.isEmptyObject( orig ) ) {
|
|
|
|
if ( dataShow ) {
|
|
|
|
if ( "hidden" in dataShow ) {
|
|
|
|
hidden = dataShow.hidden;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
dataShow = jQuery._data( elem, "fxshow", {} );
|
|
|
|
}
|
|
|
|
|
|
|
|
// store state if its toggle - enables .stop().toggle() to "reverse"
|
|
|
|
if ( toggle ) {
|
|
|
|
dataShow.hidden = !hidden;
|
|
|
|
}
|
|
|
|
if ( hidden ) {
|
|
|
|
jQuery( elem ).show();
|
|
|
|
} else {
|
|
|
|
anim.done(function() {
|
|
|
|
jQuery( elem ).hide();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
anim.done(function() {
|
|
|
|
var prop;
|
|
|
|
jQuery._removeData( elem, "fxshow" );
|
|
|
|
for ( prop in orig ) {
|
|
|
|
jQuery.style( elem, prop, orig[ prop ] );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
for ( prop in orig ) {
|
|
|
|
tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
|
|
|
|
|
|
|
|
if ( !( prop in dataShow ) ) {
|
|
|
|
dataShow[ prop ] = tween.start;
|
|
|
|
if ( hidden ) {
|
|
|
|
tween.end = tween.start;
|
|
|
|
tween.start = prop === "width" || prop === "height" ? 1 : 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function propFilter( props, specialEasing ) {
|
|
|
|
var index, name, easing, value, hooks;
|
|
|
|
|
|
|
|
// camelCase, specialEasing and expand cssHook pass
|
|
|
|
for ( index in props ) {
|
|
|
|
name = jQuery.camelCase( index );
|
|
|
|
easing = specialEasing[ name ];
|
|
|
|
value = props[ index ];
|
|
|
|
if ( jQuery.isArray( value ) ) {
|
|
|
|
easing = value[ 1 ];
|
|
|
|
value = props[ index ] = value[ 0 ];
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( index !== name ) {
|
|
|
|
props[ name ] = value;
|
|
|
|
delete props[ index ];
|
|
|
|
}
|
|
|
|
|
|
|
|
hooks = jQuery.cssHooks[ name ];
|
|
|
|
if ( hooks && "expand" in hooks ) {
|
|
|
|
value = hooks.expand( value );
|
|
|
|
delete props[ name ];
|
|
|
|
|
|
|
|
// not quite $.extend, this wont overwrite keys already present.
|
|
|
|
// also - reusing 'index' from above because we have the correct "name"
|
|
|
|
for ( index in value ) {
|
|
|
|
if ( !( index in props ) ) {
|
|
|
|
props[ index ] = value[ index ];
|
|
|
|
specialEasing[ index ] = easing;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
specialEasing[ name ] = easing;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
function Animation( elem, properties, options ) {
|
|
|
|
var result,
|
2013-01-08 01:16:50 +00:00
|
|
|
stopped,
|
2012-04-23 19:05:12 +00:00
|
|
|
index = 0,
|
|
|
|
length = animationPrefilters.length,
|
2012-06-22 20:03:39 +00:00
|
|
|
deferred = jQuery.Deferred().always( function() {
|
2012-05-18 17:48:24 +00:00
|
|
|
// don't match elem in the :animated selector
|
|
|
|
delete tick.elem;
|
2012-04-23 19:05:12 +00:00
|
|
|
}),
|
2012-05-18 17:48:24 +00:00
|
|
|
tick = function() {
|
2013-01-08 01:16:50 +00:00
|
|
|
if ( stopped ) {
|
|
|
|
return false;
|
|
|
|
}
|
2012-05-18 17:48:24 +00:00
|
|
|
var currentTime = fxNow || createFxNow(),
|
|
|
|
remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
|
2012-11-08 03:29:55 +00:00
|
|
|
// archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
|
|
|
|
temp = remaining / animation.duration || 0,
|
|
|
|
percent = 1 - temp,
|
2012-05-18 17:48:24 +00:00
|
|
|
index = 0,
|
|
|
|
length = animation.tweens.length;
|
|
|
|
|
|
|
|
for ( ; index < length ; index++ ) {
|
|
|
|
animation.tweens[ index ].run( percent );
|
|
|
|
}
|
|
|
|
|
2012-06-23 21:50:57 +00:00
|
|
|
deferred.notifyWith( elem, [ animation, percent, remaining ]);
|
|
|
|
|
2012-05-18 17:48:24 +00:00
|
|
|
if ( percent < 1 && length ) {
|
|
|
|
return remaining;
|
|
|
|
} else {
|
2012-06-22 20:03:39 +00:00
|
|
|
deferred.resolveWith( elem, [ animation ] );
|
2012-05-18 17:48:24 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
2012-04-23 19:05:12 +00:00
|
|
|
animation = deferred.promise({
|
|
|
|
elem: elem,
|
2012-05-11 20:20:32 +00:00
|
|
|
props: jQuery.extend( {}, properties ),
|
|
|
|
opts: jQuery.extend( true, { specialEasing: {} }, options ),
|
2012-04-23 19:05:12 +00:00
|
|
|
originalProperties: properties,
|
|
|
|
originalOptions: options,
|
|
|
|
startTime: fxNow || createFxNow(),
|
|
|
|
duration: options.duration,
|
|
|
|
tweens: [],
|
2012-10-17 16:50:12 +00:00
|
|
|
createTween: function( prop, end ) {
|
2012-04-23 19:05:12 +00:00
|
|
|
var tween = jQuery.Tween( elem, animation.opts, prop, end,
|
|
|
|
animation.opts.specialEasing[ prop ] || animation.opts.easing );
|
|
|
|
animation.tweens.push( tween );
|
|
|
|
return tween;
|
|
|
|
},
|
|
|
|
stop: function( gotoEnd ) {
|
|
|
|
var index = 0,
|
|
|
|
// if we are going to the end, we want to run all the tweens
|
|
|
|
// otherwise we skip this part
|
|
|
|
length = gotoEnd ? animation.tweens.length : 0;
|
2013-01-08 01:16:50 +00:00
|
|
|
if ( stopped ) {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
stopped = true;
|
2012-04-23 19:05:12 +00:00
|
|
|
for ( ; index < length ; index++ ) {
|
|
|
|
animation.tweens[ index ].run( 1 );
|
2009-02-09 15:58:12 +00:00
|
|
|
}
|
2012-06-22 20:03:39 +00:00
|
|
|
|
|
|
|
// resolve when we played the last frame
|
|
|
|
// otherwise, reject
|
|
|
|
if ( gotoEnd ) {
|
|
|
|
deferred.resolveWith( elem, [ animation, gotoEnd ] );
|
|
|
|
} else {
|
|
|
|
deferred.rejectWith( elem, [ animation, gotoEnd ] );
|
|
|
|
}
|
2012-04-23 19:05:12 +00:00
|
|
|
return this;
|
2009-02-16 21:20:51 +00:00
|
|
|
}
|
2012-04-23 19:05:12 +00:00
|
|
|
}),
|
|
|
|
props = animation.props;
|
2009-02-09 15:58:12 +00:00
|
|
|
|
2012-05-11 20:20:32 +00:00
|
|
|
propFilter( props, animation.opts.specialEasing );
|
2010-10-26 21:37:44 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
for ( ; index < length ; index++ ) {
|
2012-06-22 20:03:39 +00:00
|
|
|
result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
|
2012-04-23 19:05:12 +00:00
|
|
|
if ( result ) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
2011-04-17 18:07:42 +00:00
|
|
|
|
2013-05-09 02:56:51 +00:00
|
|
|
jQuery.map( props, createTween, animation );
|
2012-06-22 20:03:39 +00:00
|
|
|
|
|
|
|
if ( jQuery.isFunction( animation.opts.start ) ) {
|
|
|
|
animation.opts.start.call( elem, animation );
|
|
|
|
}
|
2009-03-23 01:55:17 +00:00
|
|
|
|
2012-05-18 17:48:24 +00:00
|
|
|
jQuery.fx.timer(
|
|
|
|
jQuery.extend( tick, {
|
2013-01-12 22:11:07 +00:00
|
|
|
elem: elem,
|
2012-05-18 17:48:24 +00:00
|
|
|
anim: animation,
|
2013-01-12 22:11:07 +00:00
|
|
|
queue: animation.opts.queue
|
2012-05-18 17:48:24 +00:00
|
|
|
})
|
|
|
|
);
|
2012-06-22 20:03:39 +00:00
|
|
|
|
|
|
|
// attach callbacks from options
|
2012-06-23 21:50:57 +00:00
|
|
|
return animation.progress( animation.opts.progress )
|
|
|
|
.done( animation.opts.done, animation.opts.complete )
|
2012-06-22 20:03:39 +00:00
|
|
|
.fail( animation.opts.fail )
|
|
|
|
.always( animation.opts.always );
|
2012-04-23 19:05:12 +00:00
|
|
|
}
|
2009-12-18 16:16:26 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
jQuery.Animation = jQuery.extend( Animation, {
|
|
|
|
tweener: function( props, callback ) {
|
|
|
|
if ( jQuery.isFunction( props ) ) {
|
|
|
|
callback = props;
|
|
|
|
props = [ "*" ];
|
|
|
|
} else {
|
|
|
|
props = props.split(" ");
|
|
|
|
}
|
|
|
|
|
|
|
|
var prop,
|
|
|
|
index = 0,
|
|
|
|
length = props.length;
|
|
|
|
|
|
|
|
for ( ; index < length ; index++ ) {
|
|
|
|
prop = props[ index ];
|
|
|
|
tweeners[ prop ] = tweeners[ prop ] || [];
|
|
|
|
tweeners[ prop ].unshift( callback );
|
2008-12-19 18:21:12 +00:00
|
|
|
}
|
2007-01-07 21:43:38 +00:00
|
|
|
},
|
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
prefilter: function( callback, prepend ) {
|
|
|
|
if ( prepend ) {
|
|
|
|
animationPrefilters.unshift( callback );
|
|
|
|
} else {
|
|
|
|
animationPrefilters.push( callback );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
jQuery.speed = function( speed, easing, fn ) {
|
|
|
|
var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
|
|
|
|
complete: fn || !fn && easing ||
|
|
|
|
jQuery.isFunction( speed ) && speed,
|
|
|
|
duration: speed,
|
|
|
|
easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
|
|
|
|
};
|
2012-04-23 19:05:12 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
|
|
|
|
opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
|
2013-08-30 16:38:43 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
// normalize opt.queue - true/undefined/null -> "fx"
|
|
|
|
if ( opt.queue == null || opt.queue === true ) {
|
|
|
|
opt.queue = "fx";
|
2012-04-23 19:05:12 +00:00
|
|
|
}
|
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
// Queueing
|
|
|
|
opt.old = opt.complete;
|
2012-11-08 01:23:24 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
opt.complete = function() {
|
|
|
|
if ( jQuery.isFunction( opt.old ) ) {
|
|
|
|
opt.old.call( this );
|
2009-12-18 16:16:26 +00:00
|
|
|
}
|
2012-04-23 19:05:12 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
if ( opt.queue ) {
|
|
|
|
jQuery.dequeue( this, opt.queue );
|
2012-04-23 19:05:12 +00:00
|
|
|
}
|
2012-05-29 02:25:04 +00:00
|
|
|
};
|
2013-09-09 16:22:37 +00:00
|
|
|
|
|
|
|
return opt;
|
|
|
|
};
|
2007-09-07 21:57:40 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
jQuery.fn.extend({
|
|
|
|
fadeTo: function( speed, to, easing, callback ) {
|
2012-05-23 02:36:55 +00:00
|
|
|
|
|
|
|
// show any hidden elements after setting opacity to 0
|
|
|
|
return this.filter( isHidden ).css( "opacity", 0 ).show()
|
|
|
|
|
|
|
|
// animate to the value specified
|
|
|
|
.end().animate({ opacity: to }, speed, easing, callback );
|
2012-04-23 19:05:12 +00:00
|
|
|
},
|
|
|
|
animate: function( prop, speed, easing, callback ) {
|
2012-06-22 20:03:39 +00:00
|
|
|
var empty = jQuery.isEmptyObject( prop ),
|
|
|
|
optall = jQuery.speed( speed, easing, callback ),
|
2012-04-23 19:05:12 +00:00
|
|
|
doAnimation = function() {
|
2012-06-22 20:03:39 +00:00
|
|
|
// Operate on a copy of prop so per-property easing won't be lost
|
|
|
|
var anim = Animation( this, jQuery.extend( {}, prop ), optall );
|
2013-05-25 14:18:57 +00:00
|
|
|
|
2013-01-08 01:16:50 +00:00
|
|
|
// Empty animations, or finishing resolves immediately
|
|
|
|
if ( empty || jQuery._data( this, "finish" ) ) {
|
2012-06-22 20:03:39 +00:00
|
|
|
anim.stop( true );
|
|
|
|
}
|
|
|
|
};
|
2013-01-08 01:16:50 +00:00
|
|
|
doAnimation.finish = doAnimation;
|
2012-04-23 19:05:12 +00:00
|
|
|
|
2012-06-22 20:03:39 +00:00
|
|
|
return empty || optall.queue === false ?
|
2011-09-19 20:08:00 +00:00
|
|
|
this.each( doAnimation ) :
|
2011-09-28 15:55:29 +00:00
|
|
|
this.queue( optall.queue, doAnimation );
|
2007-01-07 21:43:38 +00:00
|
|
|
},
|
2011-10-12 01:21:59 +00:00
|
|
|
stop: function( type, clearQueue, gotoEnd ) {
|
2012-05-23 03:04:45 +00:00
|
|
|
var stopQueue = function( hooks ) {
|
|
|
|
var stop = hooks.stop;
|
|
|
|
delete hooks.stop;
|
|
|
|
stop( gotoEnd );
|
2012-04-23 19:05:12 +00:00
|
|
|
};
|
|
|
|
|
2011-10-12 01:21:59 +00:00
|
|
|
if ( typeof type !== "string" ) {
|
|
|
|
gotoEnd = clearQueue;
|
|
|
|
clearQueue = type;
|
|
|
|
type = undefined;
|
|
|
|
}
|
2011-09-28 15:55:29 +00:00
|
|
|
if ( clearQueue && type !== false ) {
|
|
|
|
this.queue( type || "fx", [] );
|
2009-11-27 19:28:42 +00:00
|
|
|
}
|
2009-12-18 16:16:26 +00:00
|
|
|
|
2011-09-28 15:55:29 +00:00
|
|
|
return this.each(function() {
|
2012-05-23 03:04:45 +00:00
|
|
|
var dequeue = true,
|
|
|
|
index = type != null && type + "queueHooks",
|
2011-09-28 15:55:29 +00:00
|
|
|
timers = jQuery.timers,
|
|
|
|
data = jQuery._data( this );
|
2011-09-12 23:48:44 +00:00
|
|
|
|
2012-05-23 03:04:45 +00:00
|
|
|
if ( index ) {
|
|
|
|
if ( data[ index ] && data[ index ].stop ) {
|
|
|
|
stopQueue( data[ index ] );
|
|
|
|
}
|
|
|
|
} else {
|
2011-11-11 20:05:06 +00:00
|
|
|
for ( index in data ) {
|
2012-04-23 19:05:12 +00:00
|
|
|
if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
|
2012-05-23 03:04:45 +00:00
|
|
|
stopQueue( data[ index ] );
|
2011-09-28 15:55:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-11 20:05:06 +00:00
|
|
|
for ( index = timers.length; index--; ) {
|
|
|
|
if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
|
2012-04-23 19:05:12 +00:00
|
|
|
timers[ index ].anim.stop( gotoEnd );
|
2012-05-23 03:04:45 +00:00
|
|
|
dequeue = false;
|
2011-11-11 20:05:06 +00:00
|
|
|
timers.splice( index, 1 );
|
2007-11-30 21:36:49 +00:00
|
|
|
}
|
2009-11-27 19:28:42 +00:00
|
|
|
}
|
2009-12-18 16:16:26 +00:00
|
|
|
|
2011-09-28 15:55:29 +00:00
|
|
|
// start the next in the queue if the last step wasn't forced
|
|
|
|
// timers currently will call their complete callbacks, which will dequeue
|
|
|
|
// but only if they were gotoEnd
|
2012-05-23 03:04:45 +00:00
|
|
|
if ( dequeue || !gotoEnd ) {
|
2011-09-28 15:55:29 +00:00
|
|
|
jQuery.dequeue( this, type );
|
|
|
|
}
|
|
|
|
});
|
2013-01-08 01:16:50 +00:00
|
|
|
},
|
|
|
|
finish: function( type ) {
|
|
|
|
if ( type !== false ) {
|
|
|
|
type = type || "fx";
|
|
|
|
}
|
|
|
|
return this.each(function() {
|
|
|
|
var index,
|
|
|
|
data = jQuery._data( this ),
|
|
|
|
queue = data[ type + "queue" ],
|
|
|
|
hooks = data[ type + "queueHooks" ],
|
|
|
|
timers = jQuery.timers,
|
|
|
|
length = queue ? queue.length : 0;
|
|
|
|
|
|
|
|
// enable finishing flag on private data
|
|
|
|
data.finish = true;
|
|
|
|
|
|
|
|
// empty the queue first
|
|
|
|
jQuery.queue( this, type, [] );
|
|
|
|
|
2013-05-25 14:18:57 +00:00
|
|
|
if ( hooks && hooks.stop ) {
|
|
|
|
hooks.stop.call( this, true );
|
2013-01-08 01:16:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// look for any active animations, and finish them
|
|
|
|
for ( index = timers.length; index--; ) {
|
|
|
|
if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
|
|
|
|
timers[ index ].anim.stop( true );
|
|
|
|
timers.splice( index, 1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// look for any animations in the old queue and finish them
|
|
|
|
for ( index = 0; index < length; index++ ) {
|
|
|
|
if ( queue[ index ] && queue[ index ].finish ) {
|
|
|
|
queue[ index ].finish.call( this );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// turn off finishing flag
|
|
|
|
delete data.finish;
|
|
|
|
});
|
2007-01-07 21:43:38 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
|
|
|
|
var cssFn = jQuery.fn[ name ];
|
|
|
|
jQuery.fn[ name ] = function( speed, easing, callback ) {
|
|
|
|
return speed == null || typeof speed === "boolean" ?
|
|
|
|
cssFn.apply( this, arguments ) :
|
|
|
|
this.animate( genFx( name, true ), speed, easing, callback );
|
|
|
|
};
|
|
|
|
});
|
2011-04-17 18:08:52 +00:00
|
|
|
|
2008-07-03 22:54:12 +00:00
|
|
|
// Generate shortcuts for custom animations
|
|
|
|
jQuery.each({
|
2012-04-23 19:05:12 +00:00
|
|
|
slideDown: genFx("show"),
|
|
|
|
slideUp: genFx("hide"),
|
|
|
|
slideToggle: genFx("toggle"),
|
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
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
jQuery.timers = [];
|
|
|
|
jQuery.fx.tick = function() {
|
|
|
|
var timer,
|
|
|
|
timers = jQuery.timers,
|
|
|
|
i = 0;
|
|
|
|
|
2012-11-08 01:22:14 +00:00
|
|
|
fxNow = jQuery.now();
|
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
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
|
|
|
}
|
2012-04-23 19:05:12 +00:00
|
|
|
}
|
2010-10-05 18:38:19 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
if ( !timers.length ) {
|
|
|
|
jQuery.fx.stop();
|
|
|
|
}
|
2012-11-08 01:22:14 +00:00
|
|
|
fxNow = undefined;
|
2012-04-23 19:05:12 +00:00
|
|
|
};
|
2010-10-05 18:38:19 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
jQuery.fx.timer = function( timer ) {
|
2012-11-08 06:02:14 +00:00
|
|
|
if ( timer() && jQuery.timers.push( timer ) ) {
|
|
|
|
jQuery.fx.start();
|
2012-04-23 19:05:12 +00:00
|
|
|
}
|
|
|
|
};
|
2010-10-05 18:38:19 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
jQuery.fx.interval = 13;
|
2009-06-02 02:14:58 +00:00
|
|
|
|
2012-11-08 06:02:14 +00:00
|
|
|
jQuery.fx.start = function() {
|
|
|
|
if ( !timerId ) {
|
|
|
|
timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
jQuery.fx.stop = function() {
|
|
|
|
clearInterval( timerId );
|
|
|
|
timerId = null;
|
|
|
|
};
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
jQuery.fx.speeds = {
|
|
|
|
slow: 600,
|
|
|
|
fast: 200,
|
|
|
|
// Default speed
|
|
|
|
_default: 400
|
|
|
|
};
|
2009-10-26 22:07:57 +00:00
|
|
|
|
2013-09-09 01:25:27 +00:00
|
|
|
return jQuery;
|
2013-08-15 18:15:49 +00:00
|
|
|
});
|