2012-05-29 02:25:04 +00:00
|
|
|
var fxNow, timerId,
|
2010-09-22 13:16:28 +00:00
|
|
|
rfxtypes = /^(?:toggle|show|hide)$/,
|
2012-11-26 08:20:43 +00:00
|
|
|
rfxnum = new RegExp( "^(?:([+-])=|)(" + core_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 ) {
|
2012-09-15 15:57:01 +00:00
|
|
|
var end, unit,
|
2012-04-23 19:05:12 +00:00
|
|
|
tween = this.createTween( prop, value ),
|
|
|
|
parts = rfxnum.exec( value ),
|
2012-06-26 17:48:31 +00:00
|
|
|
target = tween.cur(),
|
|
|
|
start = +target || 0,
|
2012-09-15 15:57:01 +00:00
|
|
|
scale = 1,
|
|
|
|
maxIterations = 20;
|
2012-04-23 19:05:12 +00:00
|
|
|
|
|
|
|
if ( parts ) {
|
|
|
|
end = +parts[2];
|
|
|
|
unit = parts[3] || ( jQuery.cssNumber[ prop ] ? "" : "px" );
|
|
|
|
|
|
|
|
// We need to compute starting value
|
2012-06-11 18:17:36 +00:00
|
|
|
if ( unit !== "px" && start ) {
|
|
|
|
// Iteratively approximate from a nonzero starting point
|
|
|
|
// Prefer the current property, because this process will be trivial if it uses the same units
|
|
|
|
// Fallback to end or a simple constant
|
2012-06-26 17:48:31 +00:00
|
|
|
start = jQuery.css( tween.elem, prop, true ) || end || 1;
|
2012-06-11 18:17:36 +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
|
2012-09-15 15:57:01 +00:00
|
|
|
scale = scale || ".5";
|
2012-06-11 18:17:36 +00:00
|
|
|
|
|
|
|
// Adjust and apply
|
|
|
|
start = start / scale;
|
|
|
|
jQuery.style( tween.elem, prop, start + unit );
|
|
|
|
|
2012-09-15 15:57:01 +00:00
|
|
|
// 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 );
|
2012-04-23 19:05:12 +00:00
|
|
|
}
|
2010-10-26 21:37:44 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
tween.unit = unit;
|
|
|
|
tween.start = start;
|
|
|
|
// If a +=/-= token was provided, we're doing a relative animation
|
2012-06-26 17:48:31 +00:00
|
|
|
tween.end = parts[1] ? start + ( parts[1] + 1 ) * end : end;
|
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
|
|
|
|
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
|
|
|
|
2012-06-22 20:03:39 +00:00
|
|
|
function createTweens( animation, props ) {
|
2012-04-23 19:05:12 +00:00
|
|
|
jQuery.each( props, function( prop, value ) {
|
|
|
|
var collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
|
|
|
|
index = 0,
|
|
|
|
length = collection.length;
|
|
|
|
for ( ; index < length; index++ ) {
|
|
|
|
if ( collection[ index ].call( animation, prop, value ) ) {
|
2012-05-18 17:48:24 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
// we're done with this property
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2011-04-17 18:07:42 +00:00
|
|
|
|
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
|
|
|
|
2012-06-22 20:03:39 +00:00
|
|
|
createTweens( animation, props );
|
|
|
|
|
|
|
|
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-05-11 20:20:32 +00:00
|
|
|
function propFilter( props, specialEasing ) {
|
|
|
|
var index, name, easing, value, hooks;
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2012-05-11 20:20:32 +00:00
|
|
|
// camelCase, specialEasing and expand cssHook pass
|
2012-04-23 19:05:12 +00:00
|
|
|
for ( index in props ) {
|
|
|
|
name = jQuery.camelCase( index );
|
2012-05-11 20:20:32 +00:00
|
|
|
easing = specialEasing[ name ];
|
|
|
|
value = props[ index ];
|
|
|
|
if ( jQuery.isArray( value ) ) {
|
|
|
|
easing = value[ 1 ];
|
|
|
|
value = props[ index ] = value[ 0 ];
|
|
|
|
}
|
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
if ( index !== name ) {
|
2012-05-11 20:20:32 +00:00
|
|
|
props[ name ] = value;
|
2012-04-23 19:05:12 +00:00
|
|
|
delete props[ index ];
|
|
|
|
}
|
2011-11-01 13:46:20 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
hooks = jQuery.cssHooks[ name ];
|
|
|
|
if ( hooks && "expand" in hooks ) {
|
2012-05-11 20:20:32 +00:00
|
|
|
value = hooks.expand( value );
|
2012-04-23 19:05:12 +00:00
|
|
|
delete props[ name ];
|
2009-02-09 15:58:12 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
// not quite $.extend, this wont overwrite keys already present.
|
|
|
|
// also - reusing 'index' from above because we have the correct "name"
|
2012-05-11 20:20:32 +00:00
|
|
|
for ( index in value ) {
|
|
|
|
if ( !( index in props ) ) {
|
|
|
|
props[ index ] = value[ index ];
|
|
|
|
specialEasing[ index ] = easing;
|
2011-04-17 18:07:42 +00:00
|
|
|
}
|
2008-12-19 18:21:12 +00:00
|
|
|
}
|
2012-05-11 20:20:32 +00:00
|
|
|
} else {
|
|
|
|
specialEasing[ name ] = easing;
|
2012-04-23 19:05:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-02-09 15:58:12 +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
|
|
|
|
2012-05-11 20:20:32 +00:00
|
|
|
function defaultPrefilter( elem, props, opts ) {
|
2012-10-18 04:50:01 +00:00
|
|
|
/*jshint validthis:true */
|
2012-11-08 01:23:24 +00:00
|
|
|
var index, prop, value, length, dataShow, toggle, tween, hooks, oldfire,
|
2012-05-23 03:04:45 +00:00
|
|
|
anim = this,
|
2012-05-11 20:20:32 +00:00
|
|
|
style = elem.style,
|
|
|
|
orig = {},
|
|
|
|
handled = [],
|
2012-05-23 02:36:55 +00:00
|
|
|
hidden = elem.nodeType && isHidden( elem );
|
2008-12-25 20:13:42 +00:00
|
|
|
|
2012-05-23 03:04:45 +00:00
|
|
|
// 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++;
|
2012-06-22 20:03:39 +00:00
|
|
|
|
2012-05-23 03:04:45 +00:00
|
|
|
anim.always(function() {
|
2012-06-22 20:03:39 +00:00
|
|
|
// 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();
|
|
|
|
}
|
|
|
|
});
|
2012-05-23 03:04:45 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
// height/width overflow pass
|
2012-07-20 23:36:55 +00:00
|
|
|
if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
|
2012-04-23 19:05:12 +00:00
|
|
|
// 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 ];
|
2009-12-18 16:16:26 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
// Set display property to inline-block for height/width
|
|
|
|
// animations on inline elements that are having width/height animated
|
|
|
|
if ( jQuery.css( elem, "display" ) === "inline" &&
|
|
|
|
jQuery.css( elem, "float" ) === "none" ) {
|
|
|
|
|
2013-01-03 01:45:45 +00:00
|
|
|
style.display = "inline-block";
|
2012-04-23 19:05:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( opts.overflow ) {
|
|
|
|
style.overflow = "hidden";
|
2013-01-03 01:45:45 +00:00
|
|
|
anim.done(function() {
|
|
|
|
style.overflow = opts.overflow[ 0 ];
|
|
|
|
style.overflowX = opts.overflow[ 1 ];
|
|
|
|
style.overflowY = opts.overflow[ 2 ];
|
|
|
|
});
|
2012-04-23 19:05:12 +00:00
|
|
|
}
|
2009-12-18 16:16:26 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
|
2012-05-11 20:20:32 +00:00
|
|
|
// show/hide pass
|
2012-04-23 19:05:12 +00:00
|
|
|
for ( index in props ) {
|
|
|
|
value = props[ index ];
|
|
|
|
if ( rfxtypes.exec( value ) ) {
|
|
|
|
delete props[ index ];
|
2012-11-08 01:23:24 +00:00
|
|
|
toggle = toggle || value === "toggle";
|
2012-04-23 19:05:12 +00:00
|
|
|
if ( value === ( hidden ? "hide" : "show" ) ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
handled.push( index );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
length = handled.length;
|
|
|
|
if ( length ) {
|
|
|
|
dataShow = jQuery._data( elem, "fxshow" ) || jQuery._data( elem, "fxshow", {} );
|
2012-11-08 01:23:24 +00:00
|
|
|
if ( "hidden" in dataShow ) {
|
|
|
|
hidden = dataShow.hidden;
|
|
|
|
}
|
|
|
|
|
|
|
|
// store state if its toggle - enables .stop().toggle() to "reverse"
|
|
|
|
if ( toggle ) {
|
|
|
|
dataShow.hidden = !hidden;
|
|
|
|
}
|
2012-04-23 19:05:12 +00:00
|
|
|
if ( hidden ) {
|
2012-05-29 02:25:04 +00:00
|
|
|
jQuery( elem ).show();
|
2009-12-18 16:16:26 +00:00
|
|
|
} else {
|
2012-06-22 20:03:39 +00:00
|
|
|
anim.done(function() {
|
2012-05-29 02:25:04 +00:00
|
|
|
jQuery( elem ).hide();
|
2012-04-23 19:05:12 +00:00
|
|
|
});
|
2009-12-18 16:16:26 +00:00
|
|
|
}
|
2012-06-22 20:03:39 +00:00
|
|
|
anim.done(function() {
|
2012-04-23 19:05:12 +00:00
|
|
|
var prop;
|
2012-10-16 15:15:41 +00:00
|
|
|
jQuery._removeData( elem, "fxshow" );
|
2012-04-23 19:05:12 +00:00
|
|
|
for ( prop in orig ) {
|
|
|
|
jQuery.style( elem, prop, orig[ prop ] );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
for ( index = 0 ; index < length ; index++ ) {
|
|
|
|
prop = handled[ index ];
|
2012-05-23 03:04:45 +00:00
|
|
|
tween = anim.createTween( prop, hidden ? dataShow[ prop ] : 0 );
|
2012-04-23 19:05:12 +00:00
|
|
|
orig[ prop ] = dataShow[ prop ] || jQuery.style( elem, prop );
|
|
|
|
|
|
|
|
if ( !( prop in dataShow ) ) {
|
|
|
|
dataShow[ prop ] = tween.start;
|
|
|
|
if ( hidden ) {
|
|
|
|
tween.end = tween.start;
|
|
|
|
tween.start = prop === "width" || prop === "height" ? 1 : 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-05-11 20:20:32 +00:00
|
|
|
}
|
2009-12-18 16:16:26 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
function Tween( elem, options, prop, end, easing ) {
|
|
|
|
return new Tween.prototype.init( elem, options, prop, end, easing );
|
|
|
|
}
|
|
|
|
jQuery.Tween = Tween;
|
|
|
|
|
|
|
|
Tween.prototype = {
|
|
|
|
constructor: Tween,
|
|
|
|
init: function( elem, options, prop, end, easing, unit ) {
|
|
|
|
this.elem = elem;
|
|
|
|
this.prop = prop;
|
|
|
|
this.easing = easing || "swing";
|
|
|
|
this.options = options;
|
|
|
|
this.start = this.now = this.cur();
|
|
|
|
this.end = end;
|
|
|
|
this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
|
2007-01-07 21:43:38 +00:00
|
|
|
},
|
2012-04-23 19:05:12 +00:00
|
|
|
cur: function() {
|
|
|
|
var hooks = Tween.propHooks[ this.prop ];
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
return hooks && hooks.get ?
|
|
|
|
hooks.get( this ) :
|
|
|
|
Tween.propHooks._default.get( this );
|
2007-01-07 21:43:38 +00:00
|
|
|
},
|
2012-04-23 19:05:12 +00:00
|
|
|
run: function( percent ) {
|
|
|
|
var eased,
|
|
|
|
hooks = Tween.propHooks[ this.prop ];
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2012-08-15 19:31:37 +00:00
|
|
|
if ( this.options.duration ) {
|
|
|
|
this.pos = eased = jQuery.easing[ this.easing ](
|
|
|
|
percent, this.options.duration * percent, 0, 1, this.options.duration
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
this.pos = eased = percent;
|
|
|
|
}
|
2012-04-23 19:05:12 +00:00
|
|
|
this.now = ( this.end - this.start ) * eased + this.start;
|
2007-09-07 21:57:40 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
if ( this.options.step ) {
|
|
|
|
this.options.step.call( this.elem, this.now, this );
|
2009-12-21 16:11:03 +00:00
|
|
|
}
|
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
if ( hooks && hooks.set ) {
|
|
|
|
hooks.set( this );
|
|
|
|
} else {
|
|
|
|
Tween.propHooks._default.set( this );
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
};
|
2011-04-11 11:40:14 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
Tween.prototype.init.prototype = Tween.prototype;
|
2012-02-24 05:14:15 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
Tween.propHooks = {
|
|
|
|
_default: {
|
|
|
|
get: function( tween ) {
|
2012-06-06 23:03:10 +00:00
|
|
|
var result;
|
2011-12-09 01:01:23 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
if ( tween.elem[ tween.prop ] != null &&
|
|
|
|
(!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
|
|
|
|
return tween.elem[ tween.prop ];
|
2011-12-09 01:01:23 +00:00
|
|
|
}
|
2009-07-25 20:56:15 +00:00
|
|
|
|
2013-01-16 04:09:35 +00:00
|
|
|
// passing an empty string as a 3rd parameter to .css will automatically
|
2012-06-06 23:03:10 +00:00
|
|
|
// attempt a parseFloat and fallback to a string if the parse fails
|
|
|
|
// so, simple values such as "10px" are parsed to Float.
|
|
|
|
// complex values such as "rotate(1rad)" are returned as is.
|
2013-01-16 04:09:35 +00:00
|
|
|
result = jQuery.css( tween.elem, tween.prop, "" );
|
2012-06-06 23:03:10 +00:00
|
|
|
// Empty strings, null, undefined and "auto" are converted to 0.
|
|
|
|
return !result || result === "auto" ? 0 : result;
|
2012-04-23 19:05:12 +00:00
|
|
|
},
|
|
|
|
set: function( tween ) {
|
|
|
|
// use step hook for back compat - use cssHook if its there - use .style if its
|
|
|
|
// available and use plain properties where available
|
|
|
|
if ( jQuery.fx.step[ tween.prop ] ) {
|
|
|
|
jQuery.fx.step[ tween.prop ]( tween );
|
|
|
|
} else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
|
|
|
|
jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
|
|
|
|
} else {
|
|
|
|
tween.elem[ tween.prop ] = tween.now;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2011-04-14 13:21:08 +00:00
|
|
|
|
2012-07-13 21:03:21 +00:00
|
|
|
// Remove in 2.0 - this supports IE8's panic based approach
|
|
|
|
// to setting things on disconnected nodes
|
|
|
|
|
|
|
|
Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
|
|
|
|
set: function( tween ) {
|
|
|
|
if ( tween.elem.nodeType && tween.elem.parentNode ) {
|
|
|
|
tween.elem[ tween.prop ] = tween.now;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-05-29 02:25:04 +00:00
|
|
|
jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
|
|
|
|
var cssFn = jQuery.fn[ name ];
|
|
|
|
jQuery.fn[ name ] = function( speed, easing, callback ) {
|
2012-10-16 04:15:22 +00:00
|
|
|
return speed == null || typeof speed === "boolean" ?
|
2012-05-29 02:25:04 +00:00
|
|
|
cssFn.apply( this, arguments ) :
|
|
|
|
this.animate( genFx( name, true ), speed, easing, callback );
|
|
|
|
};
|
|
|
|
});
|
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-01-08 01:16:50 +00:00
|
|
|
doAnimation.finish = function() {
|
|
|
|
anim.stop( true );
|
|
|
|
};
|
|
|
|
// 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, [] );
|
|
|
|
|
|
|
|
if ( hooks && hooks.cur && hooks.cur.finish ) {
|
|
|
|
hooks.cur.finish.call( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2011-04-17 18:08:52 +00:00
|
|
|
// Generate parameters to create a standard animation
|
2012-04-23 19:05:12 +00:00
|
|
|
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
|
2012-08-30 14:47:47 +00:00
|
|
|
includeWidth = includeWidth? 1 : 0;
|
2012-04-23 19:05:12 +00:00
|
|
|
for( ; i < 4 ; i += 2 - includeWidth ) {
|
2012-07-10 01:38:11 +00:00
|
|
|
which = cssExpand[ i ];
|
2012-04-23 19:05:12 +00:00
|
|
|
attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
|
|
|
|
}
|
2011-04-17 18:08:52 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
if ( includeWidth ) {
|
|
|
|
attrs.opacity = attrs.width = type;
|
|
|
|
}
|
2011-04-17 18:08:52 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
return attrs;
|
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.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
|
|
|
|
};
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2012-04-23 19:05:12 +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;
|
2007-03-17 02:02:01 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
// normalize opt.queue - true/undefined/null -> "fx"
|
|
|
|
if ( opt.queue == null || opt.queue === true ) {
|
|
|
|
opt.queue = "fx";
|
2007-09-07 21:57:40 +00:00
|
|
|
}
|
2007-01-07 21:43:38 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
// Queueing
|
|
|
|
opt.old = opt.complete;
|
2007-03-17 02:02:01 +00:00
|
|
|
|
2012-05-23 03:04:45 +00:00
|
|
|
opt.complete = function() {
|
2012-04-23 19:05:12 +00:00
|
|
|
if ( jQuery.isFunction( opt.old ) ) {
|
|
|
|
opt.old.call( this );
|
2009-11-27 19:28:42 +00:00
|
|
|
}
|
2011-09-12 23:48:44 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
if ( opt.queue ) {
|
|
|
|
jQuery.dequeue( this, opt.queue );
|
2011-09-12 23:48:44 +00:00
|
|
|
}
|
2012-04-23 19:05:12 +00:00
|
|
|
};
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
return opt;
|
|
|
|
};
|
2007-01-07 21:43:38 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
jQuery.easing = {
|
|
|
|
linear: function( p ) {
|
|
|
|
return p;
|
2007-09-07 21:57:40 +00:00
|
|
|
},
|
2012-04-23 19:05:12 +00:00
|
|
|
swing: function( p ) {
|
|
|
|
return 0.5 - Math.cos( p*Math.PI ) / 2;
|
2007-01-07 21:43:38 +00:00
|
|
|
}
|
2007-09-07 21:57:40 +00:00
|
|
|
};
|
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
jQuery.timers = [];
|
|
|
|
jQuery.fx = Tween.prototype.init;
|
|
|
|
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
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
// Back Compat <1.8 extension point
|
|
|
|
jQuery.fx.step = {};
|
2011-09-12 23:48:44 +00:00
|
|
|
|
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
|
|
|
}
|