2010-09-08 16:00:29 +00:00
|
|
|
(function( jQuery ) {
|
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
var fxNow, timerId, iframe, iframeDoc,
|
|
|
|
elemdisplay = {},
|
2010-09-22 13:16:28 +00:00
|
|
|
rfxtypes = /^(?:toggle|show|hide)$/,
|
2012-04-23 19:05:12 +00:00
|
|
|
rfxnum = /^([\-+]=)?((?:\d*\.)?\d+)([a-z%]*)$/i,
|
|
|
|
rrun = /\.run$/,
|
2012-05-11 20:20:32 +00:00
|
|
|
animationPrefilters = [ defaultPrefilter ],
|
2012-04-23 19:05:12 +00:00
|
|
|
tweeners = {
|
|
|
|
"*": [function( prop, value ) {
|
|
|
|
var end, unit,
|
|
|
|
tween = this.createTween( prop, value ),
|
|
|
|
parts = rfxnum.exec( value ),
|
|
|
|
start = tween.cur();
|
|
|
|
|
|
|
|
if ( parts ) {
|
|
|
|
end = +parts[2];
|
|
|
|
unit = parts[3] || ( jQuery.cssNumber[ prop ] ? "" : "px" );
|
|
|
|
|
|
|
|
// We need to compute starting value
|
|
|
|
if ( unit !== "px" ) {
|
|
|
|
jQuery.style( this, prop, (end || 1) + unit);
|
|
|
|
start = start * (end || 1) / tween.cur() || 0;
|
|
|
|
jQuery.style( this, prop, start + unit);
|
|
|
|
}
|
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
|
|
|
|
tween.end = parts[1] ? start + end * ( parts[1] === "-=" ? -1 : 1 ) : end;
|
|
|
|
}
|
|
|
|
return tween;
|
|
|
|
}]
|
|
|
|
},
|
|
|
|
oldToggle = jQuery.fn.toggle;
|
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;
|
|
|
|
}, 0 );
|
|
|
|
return ( fxNow = jQuery.now() );
|
|
|
|
}
|
2010-10-26 21:37:44 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
function callTweeners( animation, props ) {
|
|
|
|
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,
|
|
|
|
index = 0,
|
|
|
|
tweenerIndex = 0,
|
|
|
|
length = animationPrefilters.length,
|
|
|
|
finished = jQuery.Deferred(),
|
|
|
|
deferred = jQuery.Deferred().always(function( ended ) {
|
|
|
|
|
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
|
|
|
if ( deferred.state() === "resolved" || ended ) {
|
2012-05-18 17:48:24 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
// fire callbacks
|
|
|
|
finished.resolveWith( this );
|
|
|
|
}
|
|
|
|
}),
|
2012-05-18 17:48:24 +00:00
|
|
|
tick = function() {
|
|
|
|
var currentTime = fxNow || createFxNow(),
|
|
|
|
remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
|
|
|
|
percent = 1 - ( remaining / animation.duration || 0 ),
|
|
|
|
index = 0,
|
|
|
|
length = animation.tweens.length;
|
|
|
|
|
|
|
|
for ( ; index < length ; index++ ) {
|
|
|
|
animation.tweens[ index ].run( percent );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( percent < 1 && length ) {
|
|
|
|
return remaining;
|
|
|
|
} else {
|
|
|
|
deferred.resolveWith( elem, [ currentTime ] );
|
|
|
|
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,
|
|
|
|
finish: finished.done,
|
|
|
|
tweens: [],
|
|
|
|
createTween: function( prop, end, easing ) {
|
|
|
|
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;
|
|
|
|
|
|
|
|
for ( ; index < length ; index++ ) {
|
|
|
|
animation.tweens[ index ].run( 1 );
|
2009-02-09 15:58:12 +00:00
|
|
|
}
|
2012-04-23 19:05:12 +00:00
|
|
|
deferred.rejectWith( elem, [ gotoEnd ] );
|
|
|
|
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++ ) {
|
|
|
|
result = animationPrefilters[ index ].call( animation,
|
|
|
|
elem, props, animation.opts );
|
|
|
|
if ( result ) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
2011-04-17 18:07:42 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
callTweeners( animation, props );
|
2009-03-23 01:55:17 +00:00
|
|
|
|
2012-05-18 17:48:24 +00:00
|
|
|
jQuery.fx.timer(
|
|
|
|
jQuery.extend( tick, {
|
|
|
|
anim: animation,
|
|
|
|
queue: animation.opts.queue,
|
|
|
|
elem: elem
|
|
|
|
})
|
|
|
|
);
|
2012-04-23 19:05:12 +00:00
|
|
|
return animation;
|
|
|
|
}
|
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 ) {
|
|
|
|
var index, prop, value, length, dataShow, tween,
|
|
|
|
style = elem.style,
|
|
|
|
orig = {},
|
|
|
|
handled = [],
|
|
|
|
hidden = jQuery( elem ).is(":hidden");
|
2008-12-25 20:13:42 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
// height/width overflow pass
|
|
|
|
if ( elem.nodeType === 1 && ( props.height || props.width ) ) {
|
|
|
|
// 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" ) {
|
|
|
|
|
|
|
|
// inline-level elements accept inline-block;
|
|
|
|
// block-level elements need to be inline with layout
|
|
|
|
if ( !jQuery.support.inlineBlockNeedsLayout || defaultDisplay( elem.nodeName ) === "inline" ) {
|
|
|
|
style.display = "inline-block";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
style.zoom = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( opts.overflow ) {
|
|
|
|
style.overflow = "hidden";
|
|
|
|
this.finish(function() {
|
|
|
|
style.overflow = opts.overflow[ 0 ];
|
|
|
|
style.overflowX = opts.overflow[ 1 ];
|
|
|
|
style.overflowY = opts.overflow[ 2 ];
|
|
|
|
});
|
|
|
|
}
|
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 ];
|
|
|
|
if ( value === ( hidden ? "hide" : "show" ) ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
handled.push( index );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
length = handled.length;
|
|
|
|
if ( length ) {
|
|
|
|
dataShow = jQuery._data( elem, "fxshow" ) || jQuery._data( elem, "fxshow", {} );
|
|
|
|
if ( hidden ) {
|
|
|
|
showHide([ elem ], true );
|
2009-12-18 16:16:26 +00:00
|
|
|
} else {
|
2012-04-23 19:05:12 +00:00
|
|
|
this.finish(function() {
|
|
|
|
showHide([ elem ]);
|
|
|
|
});
|
2009-12-18 16:16:26 +00:00
|
|
|
}
|
2012-04-23 19:05:12 +00:00
|
|
|
this.finish(function() {
|
|
|
|
var prop;
|
|
|
|
jQuery.removeData( elem, "fxshow", true );
|
|
|
|
for ( prop in orig ) {
|
|
|
|
jQuery.style( elem, prop, orig[ prop ] );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
for ( index = 0 ; index < length ; index++ ) {
|
|
|
|
prop = handled[ index ];
|
|
|
|
tween = this.createTween( prop, hidden ? dataShow[ prop ] : 0 );
|
|
|
|
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-04-23 19:05:12 +00:00
|
|
|
this.pos = eased = jQuery.easing[ this.easing ]( percent, this.options.duration * percent, 0, 1, this.options.duration );
|
|
|
|
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 ) {
|
|
|
|
var parsed, 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
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
result = jQuery.css( tween.elem, tween.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( result ) ) ?
|
|
|
|
!result || result === "auto" ? 0 : result : parsed;
|
|
|
|
},
|
|
|
|
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-04-23 19:05:12 +00:00
|
|
|
function showHide( elements, show ) {
|
|
|
|
var elem, display,
|
|
|
|
values = [],
|
|
|
|
index = 0,
|
|
|
|
length = elements.length;
|
2009-12-18 16:16:26 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
for ( ; index < length; index++ ) {
|
|
|
|
elem = elements[ index ];
|
|
|
|
if ( !elem.style ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
values[ index ] = jQuery._data( elem, "olddisplay" );
|
|
|
|
if ( show ) {
|
|
|
|
// Reset the inline display of this element to learn if it is
|
|
|
|
// being hidden by cascaded rules or not
|
|
|
|
if ( !values[ index ] && elem.style.display === "none" ) {
|
|
|
|
elem.style.display = "";
|
2007-07-05 04:27:46 +00:00
|
|
|
}
|
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
// Set elements which have been overridden with display: none
|
|
|
|
// in a stylesheet to whatever the default browser style is
|
|
|
|
// for such an element
|
|
|
|
if ( (elem.style.display === "" && jQuery.css( elem, "display" ) === "none") ||
|
|
|
|
!jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
|
|
|
|
values[ index ] = jQuery._data( elem, "olddisplay", defaultDisplay(elem.nodeName) );
|
2009-11-27 19:28:42 +00:00
|
|
|
}
|
2012-04-23 19:05:12 +00:00
|
|
|
} else {
|
|
|
|
display = jQuery.css( elem, "display" );
|
2009-12-18 16:16:26 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
if ( !values[ index ] && display !== "none" ) {
|
|
|
|
jQuery._data( elem, "olddisplay", display );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-09-28 15:55:29 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
// Set the display of most of the elements in a second loop
|
|
|
|
// to avoid the constant reflow
|
|
|
|
for ( index = 0; index < length; index++ ) {
|
|
|
|
elem = elements[ index ];
|
|
|
|
if ( !elem.style ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
|
|
|
|
elem.style.display = show ? values[ index ] || "" : "none";
|
|
|
|
}
|
|
|
|
}
|
2009-12-18 16:16:26 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
return elements;
|
|
|
|
}
|
2007-09-07 21:57:40 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
jQuery.fn.extend({
|
|
|
|
show: function( speed, easing, callback ) {
|
|
|
|
return speed || speed === 0 ?
|
|
|
|
this.animate( genFx( "show", true ), speed, easing, callback ) :
|
|
|
|
showHide( this, true );
|
|
|
|
},
|
|
|
|
hide: function( speed, easing, callback ) {
|
|
|
|
return speed || speed === 0 ?
|
|
|
|
this.animate( genFx( "hide", true ), speed, easing, callback ) :
|
|
|
|
showHide( this );
|
|
|
|
},
|
|
|
|
toggle: function( fn, fn2, callback ) {
|
|
|
|
var bool = typeof fn === "boolean";
|
2007-09-07 21:57:40 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
if ( jQuery.isFunction( fn ) && jQuery.isFunction( fn2 ) ) {
|
|
|
|
oldToggle.apply( this, arguments );
|
2007-09-07 21:57:40 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
} else if ( fn == null || bool ) {
|
|
|
|
this.each(function() {
|
|
|
|
var state = bool ? fn : jQuery( this ).is(":hidden");
|
|
|
|
showHide([ this ], state );
|
|
|
|
});
|
2009-12-18 16:16:26 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
} else {
|
|
|
|
this.animate( genFx( "toggle", true ), fn, fn2, callback );
|
|
|
|
}
|
2009-12-18 16:16:26 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
fadeTo: function( speed, to, easing, callback ) {
|
|
|
|
return this.filter(":hidden").css("opacity", 0).show().end()
|
|
|
|
.animate({opacity: to}, speed, easing, callback);
|
|
|
|
},
|
|
|
|
animate: function( prop, speed, easing, callback ) {
|
|
|
|
var optall = jQuery.speed( speed, easing, callback ),
|
|
|
|
doAnimation = function() {
|
|
|
|
Animation( this, prop, optall ).finish( optall.complete );
|
|
|
|
};
|
2007-08-20 03:59:34 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
if ( jQuery.isEmptyObject( prop ) ) {
|
|
|
|
return this.each( optall.complete, [ false ] );
|
2011-09-19 20:08:00 +00:00
|
|
|
}
|
|
|
|
|
2012-04-23 19:05:12 +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
|
|
|
return optall.queue === false ?
|
|
|
|
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-04-23 19:05:12 +00:00
|
|
|
var stopQueue = function( elem, data, index ) {
|
|
|
|
var hooks = data[ index ];
|
|
|
|
jQuery.removeData( elem, index, true );
|
|
|
|
hooks.stop( gotoEnd );
|
|
|
|
};
|
|
|
|
|
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() {
|
2011-11-11 20:05:06 +00:00
|
|
|
var index,
|
2011-09-28 15:55:29 +00:00
|
|
|
hadTimers = false,
|
|
|
|
timers = jQuery.timers,
|
|
|
|
data = jQuery._data( this );
|
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-09-28 15:55:29 +00:00
|
|
|
|
|
|
|
if ( type == null ) {
|
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 ) ) {
|
2011-11-11 20:05:06 +00:00
|
|
|
stopQueue( this, data, index );
|
2011-09-28 15:55:29 +00:00
|
|
|
}
|
|
|
|
}
|
2011-11-11 20:05:06 +00:00
|
|
|
} else if ( data[ index = type + ".run" ] && data[ index ].stop ){
|
|
|
|
stopQueue( this, 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 );
|
2011-09-28 15:55:29 +00:00
|
|
|
hadTimers = true;
|
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
|
|
|
|
if ( !( gotoEnd && hadTimers ) ) {
|
|
|
|
jQuery.dequeue( this, type );
|
|
|
|
}
|
|
|
|
});
|
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
|
|
|
|
for( ; i < 4 ; i += 2 - includeWidth ) {
|
|
|
|
which = jQuery.cssExpand[ i ];
|
|
|
|
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-04-23 19:05:12 +00:00
|
|
|
opt.complete = function( noUnmark ) {
|
|
|
|
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 );
|
|
|
|
} else if ( noUnmark !== false ) {
|
|
|
|
jQuery._unmark( this );
|
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;
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
};
|
2010-10-05 18:38:19 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
jQuery.fx.timer = function( timer ) {
|
|
|
|
if ( timer() && jQuery.timers.push( timer ) && !timerId ) {
|
|
|
|
timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
|
|
|
|
}
|
|
|
|
};
|
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-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
|
|
|
}
|
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 ) {
|
2012-04-23 19:05:12 +00:00
|
|
|
if ( elemdisplay[ nodeName ] ) {
|
|
|
|
return elemdisplay[ nodeName ];
|
|
|
|
}
|
2011-04-12 15:48:07 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
var elem = jQuery( "<" + nodeName + ">" ).appendTo( document.body ),
|
|
|
|
display = elem.css("display");
|
|
|
|
elem.remove();
|
|
|
|
|
|
|
|
// If the simple way fails,
|
|
|
|
// get element's real default display by attaching it to a temp iframe
|
|
|
|
if ( display === "none" || display === "" ) {
|
|
|
|
// Use the already-created iframe if possible
|
|
|
|
iframe = document.body.appendChild(
|
|
|
|
iframe || jQuery.extend( document.createElement("iframe"), {
|
|
|
|
frameBorder: 0,
|
|
|
|
width: 0,
|
|
|
|
height: 0
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
// Create a cacheable copy of the iframe document on first call.
|
|
|
|
// 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.
|
|
|
|
if ( !iframeDoc || !iframe.createElement ) {
|
|
|
|
iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
|
2012-05-15 01:02:42 +00:00
|
|
|
iframeDoc.write("<!doctype html><html><body>");
|
2012-04-23 19:05:12 +00:00
|
|
|
iframeDoc.close();
|
2010-10-09 01:29:41 +00:00
|
|
|
}
|
2011-04-12 17:47:27 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
elem = iframeDoc.body.appendChild( iframeDoc.createElement(nodeName) );
|
|
|
|
|
|
|
|
display = jQuery.css( elem, "display" );
|
|
|
|
document.body.removeChild( iframe );
|
2010-10-09 01:29:41 +00:00
|
|
|
}
|
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
// Store the correct default display
|
|
|
|
elemdisplay[ nodeName ] = display;
|
|
|
|
|
|
|
|
return display;
|
2010-10-09 01:29:41 +00:00
|
|
|
}
|
|
|
|
|
2010-09-08 16:00:29 +00:00
|
|
|
})( jQuery );
|