2010-09-08 18:00:29 +02:00
|
|
|
(function( jQuery ) {
|
|
|
|
|
2009-01-05 02:14:36 +01:00
|
|
|
var elemdisplay = {},
|
2010-09-22 15:16:28 +02:00
|
|
|
rfxtypes = /^(?:toggle|show|hide)$/,
|
2010-03-02 03:24:49 +01:00
|
|
|
rfxnum = /^([+\-]=)?([\d+.\-]+)(.*)$/,
|
2009-01-15 00:09:52 +01:00
|
|
|
timerId,
|
2009-01-05 13:05:38 +01:00
|
|
|
fxAttrs = [
|
|
|
|
// height animations
|
|
|
|
[ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
|
|
|
|
// width animations
|
|
|
|
[ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
|
|
|
|
// opacity animations
|
|
|
|
[ "opacity" ]
|
2010-09-17 20:53:10 +02:00
|
|
|
];
|
2009-01-05 13:05:38 +01:00
|
|
|
|
2007-01-07 22:43:38 +01:00
|
|
|
jQuery.fn.extend({
|
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 22:31:32 +02:00
|
|
|
show: function( speed, easing, callback ) {
|
2010-01-19 20:52:35 +01: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 22:31:32 +02:00
|
|
|
return this.animate( genFx("show", 3), speed, easing, callback);
|
2009-12-18 17:16:26 +01:00
|
|
|
|
2008-12-19 19:21:12 +01:00
|
|
|
} else {
|
2009-12-22 01:58:13 +01:00
|
|
|
for ( var i = 0, l = this.length; i < l; i++ ) {
|
2008-12-19 19:21:12 +01:00
|
|
|
var old = jQuery.data(this[i], "olddisplay");
|
2009-03-23 02:55:17 +01:00
|
|
|
|
2008-12-19 19:21:12 +01:00
|
|
|
this[i].style.display = old || "";
|
2009-03-23 02:55:17 +01:00
|
|
|
|
2010-09-16 16:00:56 +02:00
|
|
|
if ( jQuery.css( this[i], "display" ) === "none" ) {
|
2009-07-19 15:32:53 +02:00
|
|
|
var nodeName = this[i].nodeName, display;
|
2009-03-23 02:55:17 +01:00
|
|
|
|
2009-07-19 15:32:53 +02:00
|
|
|
if ( elemdisplay[ nodeName ] ) {
|
|
|
|
display = elemdisplay[ nodeName ];
|
2009-12-18 17:16:26 +01:00
|
|
|
|
2008-12-19 19:21:12 +01:00
|
|
|
} else {
|
2010-09-22 15:16:28 +02:00
|
|
|
var elem = jQuery("<" + nodeName + ">").appendTo("body");
|
2009-03-23 02:55:17 +01:00
|
|
|
|
2008-12-19 19:21:12 +01:00
|
|
|
display = elem.css("display");
|
2009-12-18 17:16:26 +01:00
|
|
|
|
2009-11-27 20:28:42 +01:00
|
|
|
if ( display === "none" ) {
|
2008-12-19 19:21:12 +01:00
|
|
|
display = "block";
|
2009-11-27 20:28:42 +01:00
|
|
|
}
|
2009-12-18 17:16:26 +01:00
|
|
|
|
2008-12-19 19:21:12 +01:00
|
|
|
elem.remove();
|
2009-03-23 02:55:17 +01:00
|
|
|
|
2009-07-19 15:32:53 +02:00
|
|
|
elemdisplay[ nodeName ] = display;
|
2008-12-19 19:21:12 +01:00
|
|
|
}
|
2009-03-23 02:55:17 +01:00
|
|
|
|
2009-02-09 16:58:12 +01:00
|
|
|
jQuery.data(this[i], "olddisplay", display);
|
|
|
|
}
|
2009-02-16 22:20:51 +01:00
|
|
|
}
|
2009-02-09 16:58:12 +01:00
|
|
|
|
2009-02-16 22:20:51 +01:00
|
|
|
// Set the display of the elements in a second loop
|
|
|
|
// to avoid the constant reflow
|
2009-12-22 01:58:13 +01:00
|
|
|
for ( var j = 0, k = this.length; j < k; j++ ) {
|
2009-12-18 17:16:26 +01:00
|
|
|
this[j].style.display = jQuery.data(this[j], "olddisplay") || "";
|
2008-12-19 19:21:12 +01:00
|
|
|
}
|
2009-03-23 02:55:17 +01:00
|
|
|
|
2008-12-19 19:21:12 +01:00
|
|
|
return this;
|
|
|
|
}
|
2007-01-07 22:43:38 +01:00
|
|
|
},
|
2008-05-13 03:45:58 +02: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 22:31:32 +02:00
|
|
|
hide: function( speed, easing, callback ) {
|
2010-01-19 20:52:35 +01: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 22:31:32 +02:00
|
|
|
return this.animate( genFx("hide", 3), speed, easing, callback);
|
2009-12-18 17:16:26 +01:00
|
|
|
|
2008-12-19 19:21:12 +01:00
|
|
|
} else {
|
2009-12-22 01:58:13 +01:00
|
|
|
for ( var i = 0, l = this.length; i < l; i++ ) {
|
2008-12-19 19:21:12 +01:00
|
|
|
var old = jQuery.data(this[i], "olddisplay");
|
2009-12-22 01:58:13 +01:00
|
|
|
if ( !old && old !== "none" ) {
|
2010-09-16 16:00:56 +02:00
|
|
|
jQuery.data( this[i], "olddisplay", jQuery.css( this[i], "display" ) );
|
2009-11-27 20:28:42 +01:00
|
|
|
}
|
2009-02-09 16:58:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set the display of the elements in a second loop
|
|
|
|
// to avoid the constant reflow
|
2009-12-22 01:58:13 +01:00
|
|
|
for ( var j = 0, k = this.length; j < k; j++ ) {
|
2009-12-18 17:16:26 +01:00
|
|
|
this[j].style.display = "none";
|
2008-12-19 19:21:12 +01:00
|
|
|
}
|
2009-02-09 16:58:12 +01:00
|
|
|
|
2008-12-19 19:21:12 +01:00
|
|
|
return this;
|
|
|
|
}
|
2007-01-07 22:43:38 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
// Save the old toggle function
|
|
|
|
_toggle: jQuery.fn.toggle,
|
2008-05-13 03:45:58 +02: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 22:31:32 +02:00
|
|
|
toggle: function( fn, fn2, callback ) {
|
2008-12-25 21:13:42 +01:00
|
|
|
var bool = typeof fn === "boolean";
|
|
|
|
|
2009-12-18 17:16:26 +01:00
|
|
|
if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) {
|
|
|
|
this._toggle.apply( this, arguments );
|
|
|
|
|
|
|
|
} else if ( fn == null || bool ) {
|
2009-12-22 01:58:13 +01:00
|
|
|
this.each(function() {
|
2009-12-18 17:16:26 +01: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 22:31:32 +02:00
|
|
|
this.animate(genFx("toggle", 3), fn, fn2, callback);
|
2009-12-18 17:16:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
2007-01-07 22:43:38 +01:00
|
|
|
},
|
2008-05-13 03:45:58 +02: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 22:31:32 +02:00
|
|
|
fadeTo: function( speed, to, easing, callback ) {
|
2009-12-18 17:16:26 +01: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 22:31:32 +02:00
|
|
|
.animate({opacity: to}, speed, easing, callback);
|
2007-01-07 22:43:38 +01:00
|
|
|
},
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2007-01-07 22:43:38 +01:00
|
|
|
animate: function( prop, speed, easing, callback ) {
|
2007-10-18 02:30:37 +02:00
|
|
|
var optall = jQuery.speed(speed, easing, callback);
|
2007-09-07 23:57:40 +02:00
|
|
|
|
2009-12-21 17:11:03 +01:00
|
|
|
if ( jQuery.isEmptyObject( prop ) ) {
|
|
|
|
return this.each( optall.complete );
|
|
|
|
}
|
|
|
|
|
2009-12-18 17:16:26 +01:00
|
|
|
return this[ optall.queue === false ? "each" : "queue" ](function() {
|
2008-04-30 01:34:50 +02:00
|
|
|
var opt = jQuery.extend({}, optall), p,
|
2009-12-18 17:16:26 +01:00
|
|
|
hidden = this.nodeType === 1 && jQuery(this).is(":hidden"),
|
2008-06-20 18:20:20 +02:00
|
|
|
self = this;
|
2009-03-23 02:55:17 +01:00
|
|
|
|
2008-04-30 01:34:50 +02:00
|
|
|
for ( p in prop ) {
|
2010-09-17 20:53:10 +02:00
|
|
|
var name = jQuery.camelCase( p );
|
2009-07-25 22:56:15 +02:00
|
|
|
|
|
|
|
if ( p !== name ) {
|
|
|
|
prop[ name ] = prop[ p ];
|
|
|
|
delete prop[ p ];
|
|
|
|
p = name;
|
|
|
|
}
|
|
|
|
|
2009-12-18 17:16:26 +01:00
|
|
|
if ( prop[p] === "hide" && hidden || prop[p] === "show" && !hidden ) {
|
2008-05-16 21:51:34 +02:00
|
|
|
return opt.complete.call(this);
|
2009-11-27 20:28:42 +01:00
|
|
|
}
|
2009-12-18 17:16:26 +01:00
|
|
|
|
|
|
|
if ( ( p === "height" || p === "width" ) && this.style ) {
|
2007-07-05 06:27:46 +02:00
|
|
|
// Store display property
|
2010-09-16 16:00:56 +02:00
|
|
|
opt.display = this.style.display;
|
2007-07-05 06:27:46 +02:00
|
|
|
|
|
|
|
// Make sure that nothing sneaks out
|
|
|
|
opt.overflow = this.style.overflow;
|
|
|
|
}
|
2009-12-18 17:16:26 +01:00
|
|
|
|
2009-12-06 17:37:34 +01:00
|
|
|
if ( jQuery.isArray( prop[p] ) ) {
|
|
|
|
// Create (if needed) and add to specialEasing
|
|
|
|
(opt.specialEasing = opt.specialEasing || {})[p] = prop[p][1];
|
|
|
|
prop[p] = prop[p][0];
|
|
|
|
}
|
2007-07-05 06:27:46 +02:00
|
|
|
}
|
|
|
|
|
2009-11-27 20:28:42 +01:00
|
|
|
if ( opt.overflow != null ) {
|
2007-07-05 06:27:46 +02:00
|
|
|
this.style.overflow = "hidden";
|
2009-11-27 20:28:42 +01:00
|
|
|
}
|
2009-12-18 17:16:26 +01:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
opt.curAnim = jQuery.extend({}, prop);
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2009-12-18 17:16:26 +01:00
|
|
|
jQuery.each( prop, function( name, val ) {
|
2007-05-20 10:40:13 +02:00
|
|
|
var e = new jQuery.fx( self, opt, name );
|
2007-09-07 23:57:40 +02:00
|
|
|
|
2009-12-18 17:16:26 +01:00
|
|
|
if ( rfxtypes.test(val) ) {
|
|
|
|
e[ val === "toggle" ? hidden ? "show" : "hide" : val ]( prop );
|
|
|
|
|
2009-11-27 20:28:42 +01:00
|
|
|
} else {
|
2009-12-18 17:16:26 +01:00
|
|
|
var parts = rfxnum.exec(val),
|
2007-09-07 23:57:40 +02:00
|
|
|
start = e.cur(true) || 0;
|
|
|
|
|
|
|
|
if ( parts ) {
|
2009-12-18 17:16:26 +01:00
|
|
|
var end = parseFloat( parts[2] ),
|
2007-09-15 05:12:56 +02:00
|
|
|
unit = parts[3] || "px";
|
2007-09-07 23:57:40 +02:00
|
|
|
|
|
|
|
// We need to compute starting value
|
2009-12-18 17:16:26 +01:00
|
|
|
if ( unit !== "px" ) {
|
2007-09-15 05:26:33 +02:00
|
|
|
self.style[ name ] = (end || 1) + unit;
|
|
|
|
start = ((end || 1) / e.cur(true)) * start;
|
2007-09-07 23:57:40 +02:00
|
|
|
self.style[ name ] = start + unit;
|
|
|
|
}
|
|
|
|
|
2007-09-15 04:40:42 +02:00
|
|
|
// If a +=/-= token was provided, we're doing a relative animation
|
2009-11-27 20:28:42 +01:00
|
|
|
if ( parts[1] ) {
|
2009-12-18 17:16:26 +01:00
|
|
|
end = ((parts[1] === "-=" ? -1 : 1) * end) + start;
|
2009-11-27 20:28:42 +01:00
|
|
|
}
|
2009-12-18 17:16:26 +01:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
e.custom( start, end, unit );
|
2009-12-18 17:16:26 +01:00
|
|
|
|
2009-11-27 20:28:42 +01:00
|
|
|
} else {
|
2007-09-07 23:57:40 +02:00
|
|
|
e.custom( start, val, "" );
|
2009-11-27 20:28:42 +01:00
|
|
|
}
|
2007-09-07 23:57:40 +02:00
|
|
|
}
|
2007-05-20 10:40:13 +02:00
|
|
|
});
|
2007-08-20 05:59:34 +02:00
|
|
|
|
|
|
|
// For JS strict compliance
|
|
|
|
return true;
|
2007-01-07 22:43:38 +01:00
|
|
|
});
|
|
|
|
},
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2009-12-22 01:58:13 +01:00
|
|
|
stop: function( clearQueue, gotoEnd ) {
|
2007-09-04 02:28:22 +02:00
|
|
|
var timers = jQuery.timers;
|
|
|
|
|
2009-12-18 17:16:26 +01:00
|
|
|
if ( clearQueue ) {
|
2007-11-30 22:36:49 +01:00
|
|
|
this.queue([]);
|
2009-11-27 20:28:42 +01:00
|
|
|
}
|
2009-12-18 17:16:26 +01:00
|
|
|
|
2009-12-22 01:58:13 +01:00
|
|
|
this.each(function() {
|
2007-11-30 22:36:49 +01:00
|
|
|
// go in reverse order so anything added to the queue during the loop is ignored
|
2009-11-27 20:28:42 +01:00
|
|
|
for ( var i = timers.length - 1; i >= 0; i-- ) {
|
2009-12-18 17:16:26 +01:00
|
|
|
if ( timers[i].elem === this ) {
|
2009-11-27 20:28:42 +01:00
|
|
|
if (gotoEnd) {
|
2007-11-30 22:36:49 +01:00
|
|
|
// force the next step to be the last
|
|
|
|
timers[i](true);
|
2009-11-27 20:28:42 +01:00
|
|
|
}
|
2009-12-18 17:16:26 +01:00
|
|
|
|
2007-11-30 22:36:49 +01:00
|
|
|
timers.splice(i, 1);
|
|
|
|
}
|
2009-11-27 20:28:42 +01:00
|
|
|
}
|
2007-11-30 22:36:49 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
// start the next in the queue if the last step wasn't forced
|
2009-12-18 17:16:26 +01:00
|
|
|
if ( !gotoEnd ) {
|
2007-11-30 22:36:49 +01:00
|
|
|
this.dequeue();
|
2009-11-27 20:28:42 +01:00
|
|
|
}
|
2009-12-18 17:16:26 +01:00
|
|
|
|
2007-11-30 22:36:49 +01:00
|
|
|
return this;
|
2007-01-07 22:43:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2010-03-02 03:24:49 +01:00
|
|
|
function genFx( type, num ) {
|
|
|
|
var obj = {};
|
|
|
|
|
|
|
|
jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() {
|
|
|
|
obj[ this ] = type;
|
|
|
|
});
|
|
|
|
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2008-07-04 00:54:12 +02:00
|
|
|
// Generate shortcuts for custom animations
|
|
|
|
jQuery.each({
|
2009-01-05 13:05:38 +01:00
|
|
|
slideDown: genFx("show", 1),
|
|
|
|
slideUp: genFx("hide", 1),
|
|
|
|
slideToggle: genFx("toggle", 1),
|
2008-07-04 00:54:12 +02:00
|
|
|
fadeIn: { opacity: "show" },
|
|
|
|
fadeOut: { opacity: "hide" }
|
2009-12-22 01:58:13 +01: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 22:31:32 +02:00
|
|
|
jQuery.fn[ name ] = function( speed, easing, callback ) {
|
|
|
|
return this.animate( props, speed, easing, callback );
|
2008-07-04 00:54:12 +02:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2007-01-07 22:43:38 +01:00
|
|
|
jQuery.extend({
|
2009-12-18 17:16:26 +01:00
|
|
|
speed: function( speed, easing, fn ) {
|
2009-12-05 20:33:40 +01:00
|
|
|
var opt = speed && typeof speed === "object" ? speed : {
|
2008-05-13 03:45:58 +02:00
|
|
|
complete: fn || !fn && easing ||
|
2007-01-14 07:22:20 +01:00
|
|
|
jQuery.isFunction( speed ) && speed,
|
2007-01-07 01:28:31 +01:00
|
|
|
duration: speed,
|
2008-11-18 07:00:34 +01:00
|
|
|
easing: fn && easing || easing && !jQuery.isFunction(easing) && easing
|
2007-01-07 01:28:31 +01:00
|
|
|
};
|
2007-01-07 22:43:38 +01:00
|
|
|
|
2008-11-17 17:32:05 +01:00
|
|
|
opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
|
2008-10-19 01:27:43 +02:00
|
|
|
jQuery.fx.speeds[opt.duration] || jQuery.fx.speeds._default;
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2007-01-07 22:43:38 +01:00
|
|
|
// Queueing
|
2007-01-14 07:22:20 +01:00
|
|
|
opt.old = opt.complete;
|
2009-12-22 01:58:13 +01:00
|
|
|
opt.complete = function() {
|
2009-11-27 20:28:42 +01:00
|
|
|
if ( opt.queue !== false ) {
|
2007-11-16 18:49:12 +01:00
|
|
|
jQuery(this).dequeue();
|
2009-11-27 20:28:42 +01:00
|
|
|
}
|
|
|
|
if ( jQuery.isFunction( opt.old ) ) {
|
2008-05-12 21:45:02 +02:00
|
|
|
opt.old.call( this );
|
2009-11-27 20:28:42 +01:00
|
|
|
}
|
2007-01-07 22:43:38 +01:00
|
|
|
};
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2007-01-07 22:43:38 +01:00
|
|
|
return opt;
|
|
|
|
},
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2007-03-24 04:12:12 +01: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 03:45:58 +02:00
|
|
|
|
2007-03-17 03:02:01 +01:00
|
|
|
timers: [],
|
|
|
|
|
2009-12-18 17:16:26 +01:00
|
|
|
fx: function( elem, options, prop ) {
|
2007-09-07 23:57:40 +02:00
|
|
|
this.options = options;
|
|
|
|
this.elem = elem;
|
|
|
|
this.prop = prop;
|
2007-01-07 22:43:38 +01:00
|
|
|
|
2009-11-27 20:28:42 +01:00
|
|
|
if ( !options.orig ) {
|
2007-09-07 23:57:40 +02:00
|
|
|
options.orig = {};
|
2009-11-27 20:28:42 +01:00
|
|
|
}
|
2007-09-07 23:57:40 +02:00
|
|
|
}
|
2007-01-07 22:43:38 +01:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
});
|
2007-01-07 22:43:38 +01:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
jQuery.fx.prototype = {
|
|
|
|
// Simple function for setting a style value
|
2009-12-18 17:16:26 +01:00
|
|
|
update: function() {
|
2009-11-27 20:28:42 +01:00
|
|
|
if ( this.options.step ) {
|
2008-05-12 21:45:02 +02:00
|
|
|
this.options.step.call( this.elem, this.now, this );
|
2009-11-27 20:28:42 +01:00
|
|
|
}
|
2009-12-18 17:16:26 +01:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
(jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
|
2007-01-07 22:43:38 +01:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
// Set display property to block for height/width animations
|
2009-12-18 17:16:26 +01:00
|
|
|
if ( ( this.prop === "height" || this.prop === "width" ) && this.elem.style ) {
|
2007-09-07 23:57:40 +02:00
|
|
|
this.elem.style.display = "block";
|
2009-11-27 20:28:42 +01:00
|
|
|
}
|
2007-09-07 23:57:40 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
// Get the current size
|
2010-09-16 16:00:56 +02:00
|
|
|
cur: function() {
|
2009-11-27 20:28:42 +01:00
|
|
|
if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
|
2007-09-07 23:57:40 +02:00
|
|
|
return this.elem[ this.prop ];
|
2009-11-27 20:28:42 +01:00
|
|
|
}
|
2009-12-18 17:16:26 +01:00
|
|
|
|
2010-09-17 23:02:03 +02:00
|
|
|
var r = parseFloat( jQuery.css( this.elem, this.prop ) );
|
2010-09-16 16:00:56 +02:00
|
|
|
return r && r > -10000 ? r : 0;
|
2007-09-07 23:57:40 +02:00
|
|
|
},
|
2007-09-04 02:28:22 +02:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
// Start an animation from one number to another
|
2009-12-18 17:16:26 +01:00
|
|
|
custom: function( from, to, unit ) {
|
2010-03-23 17:12:16 +01:00
|
|
|
this.startTime = jQuery.now();
|
2007-09-07 23:57:40 +02:00
|
|
|
this.start = from;
|
|
|
|
this.end = to;
|
|
|
|
this.unit = unit || this.unit || "px";
|
|
|
|
this.now = this.start;
|
|
|
|
this.pos = this.state = 0;
|
|
|
|
|
2010-06-25 16:24:36 +02:00
|
|
|
var self = this, fx = jQuery.fx;
|
2009-12-18 17:16:26 +01:00
|
|
|
function t( gotoEnd ) {
|
2007-11-30 22:36:49 +01:00
|
|
|
return self.step(gotoEnd);
|
2007-09-07 23:57:40 +02:00
|
|
|
}
|
2007-03-17 03:02:01 +01:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
t.elem = this.elem;
|
2007-03-17 03:02:01 +01:00
|
|
|
|
2009-11-27 20:28:42 +01:00
|
|
|
if ( t() && jQuery.timers.push(t) && !timerId ) {
|
2010-06-25 16:24:36 +02:00
|
|
|
timerId = setInterval(fx.tick, fx.interval);
|
2009-11-27 20:28:42 +01:00
|
|
|
}
|
2007-09-07 23:57:40 +02:00
|
|
|
},
|
2007-01-07 22:43:38 +01:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
// Simple 'show' function
|
2009-12-18 17:16:26 +01:00
|
|
|
show: function() {
|
2007-09-07 23:57:40 +02:00
|
|
|
// Remember where we started, so that we can go back to it later
|
2010-09-16 16:00:56 +02:00
|
|
|
this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
|
2007-09-07 23:57:40 +02:00
|
|
|
this.options.show = true;
|
2007-01-07 22:43:38 +01:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
// Begin the animation
|
|
|
|
// Make sure that we start at a small width/height to avoid any
|
|
|
|
// flash of content
|
2009-12-18 17:16:26 +01:00
|
|
|
this.custom(this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur());
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
// Start by showing the element
|
2009-12-18 17:16:26 +01:00
|
|
|
jQuery( this.elem ).show();
|
2007-09-07 23:57:40 +02:00
|
|
|
},
|
2007-01-07 22:43:38 +01:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
// Simple 'hide' function
|
2009-12-18 17:16:26 +01:00
|
|
|
hide: function() {
|
2007-09-07 23:57:40 +02:00
|
|
|
// Remember where we started, so that we can go back to it later
|
2010-09-16 16:00:56 +02:00
|
|
|
this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
|
2007-09-07 23:57:40 +02:00
|
|
|
this.options.hide = true;
|
2007-01-07 22:43:38 +01:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
// Begin the animation
|
|
|
|
this.custom(this.cur(), 0);
|
|
|
|
},
|
2007-01-07 22:43:38 +01:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
// Each step of an animation
|
2009-12-18 17:16:26 +01:00
|
|
|
step: function( gotoEnd ) {
|
2010-03-23 17:12:16 +01:00
|
|
|
var t = jQuery.now(), done = true;
|
2007-01-07 22:43:38 +01:00
|
|
|
|
2008-10-19 01:27:43 +02:00
|
|
|
if ( gotoEnd || t >= this.options.duration + this.startTime ) {
|
2007-09-07 23:57:40 +02:00
|
|
|
this.now = this.end;
|
|
|
|
this.pos = this.state = 1;
|
|
|
|
this.update();
|
2007-01-07 22:43:38 +01:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
this.options.curAnim[ this.prop ] = true;
|
2007-01-07 22:43:38 +01:00
|
|
|
|
2009-11-27 20:28:42 +01:00
|
|
|
for ( var i in this.options.curAnim ) {
|
|
|
|
if ( this.options.curAnim[i] !== true ) {
|
2007-09-07 23:57:40 +02:00
|
|
|
done = false;
|
2009-11-27 20:28:42 +01:00
|
|
|
}
|
|
|
|
}
|
2009-12-18 17:16:26 +01:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
if ( done ) {
|
|
|
|
if ( this.options.display != null ) {
|
|
|
|
// Reset the overflow
|
|
|
|
this.elem.style.overflow = this.options.overflow;
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
// Reset the display
|
2009-12-06 03:06:14 +01:00
|
|
|
var old = jQuery.data(this.elem, "olddisplay");
|
|
|
|
this.elem.style.display = old ? old : this.options.display;
|
|
|
|
|
2010-09-16 16:00:56 +02:00
|
|
|
if ( jQuery.css( this.elem, "display" ) === "none" ) {
|
2007-09-07 23:57:40 +02:00
|
|
|
this.elem.style.display = "block";
|
2009-11-27 20:28:42 +01:00
|
|
|
}
|
2007-09-07 23:57:40 +02:00
|
|
|
}
|
2007-01-07 22:43:38 +01:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
// Hide the element if the "hide" operation was done
|
2009-11-27 20:28:42 +01:00
|
|
|
if ( this.options.hide ) {
|
2009-01-03 00:32:10 +01:00
|
|
|
jQuery(this.elem).hide();
|
2009-11-27 20:28:42 +01:00
|
|
|
}
|
2009-12-18 17:16:26 +01:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
// Reset the properties, if the item has been hidden or shown
|
2009-12-18 17:16:26 +01:00
|
|
|
if ( this.options.hide || this.options.show ) {
|
2009-11-27 20:28:42 +01:00
|
|
|
for ( var p in this.options.curAnim ) {
|
2010-09-16 16:00:56 +02:00
|
|
|
jQuery.style( this.elem, p, this.options.orig[p] );
|
2009-11-27 20:28:42 +01:00
|
|
|
}
|
|
|
|
}
|
2009-12-18 17:16:26 +01:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
// Execute the complete function
|
2008-05-12 21:45:02 +02:00
|
|
|
this.options.complete.call( this.elem );
|
2009-01-15 00:09:52 +01:00
|
|
|
}
|
2007-09-07 23:57:40 +02:00
|
|
|
|
|
|
|
return false;
|
2009-12-18 17:16:26 +01:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
} else {
|
|
|
|
var n = t - this.startTime;
|
|
|
|
this.state = n / this.options.duration;
|
|
|
|
|
|
|
|
// Perform the easing function, defaults to swing
|
2009-12-06 17:37:34 +01:00
|
|
|
var specialEasing = this.options.specialEasing && this.options.specialEasing[this.prop];
|
|
|
|
var defaultEasing = this.options.easing || (jQuery.easing.swing ? "swing" : "linear");
|
|
|
|
this.pos = jQuery.easing[specialEasing || defaultEasing](this.state, n, 0, 1, this.options.duration);
|
2007-09-07 23:57:40 +02:00
|
|
|
this.now = this.start + ((this.end - this.start) * this.pos);
|
|
|
|
|
|
|
|
// Perform the next step of the animation
|
|
|
|
this.update();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2007-01-07 22:43:38 +01:00
|
|
|
}
|
2007-09-07 23:57:40 +02:00
|
|
|
};
|
|
|
|
|
2008-04-30 01:34:50 +02:00
|
|
|
jQuery.extend( jQuery.fx, {
|
2009-12-18 17:16:26 +01:00
|
|
|
tick: function() {
|
2009-06-02 04:14:58 +02:00
|
|
|
var timers = jQuery.timers;
|
|
|
|
|
2009-11-27 20:28:42 +01:00
|
|
|
for ( var i = 0; i < timers.length; i++ ) {
|
|
|
|
if ( !timers[i]() ) {
|
2009-06-02 04:14:58 +02:00
|
|
|
timers.splice(i--, 1);
|
2009-11-27 20:28:42 +01:00
|
|
|
}
|
|
|
|
}
|
2009-12-18 17:16:26 +01:00
|
|
|
|
2009-11-27 20:28:42 +01:00
|
|
|
if ( !timers.length ) {
|
2009-06-02 04:14:58 +02:00
|
|
|
jQuery.fx.stop();
|
2009-11-27 20:28:42 +01:00
|
|
|
}
|
2009-06-02 04:14:58 +02:00
|
|
|
},
|
2010-06-25 16:24:36 +02:00
|
|
|
|
|
|
|
interval: 13,
|
2009-06-02 04:14:58 +02:00
|
|
|
|
2009-12-18 17:16:26 +01:00
|
|
|
stop: function() {
|
2009-06-02 04:14:58 +02:00
|
|
|
clearInterval( timerId );
|
|
|
|
timerId = null;
|
|
|
|
},
|
|
|
|
|
2009-12-18 17:16:26 +01:00
|
|
|
speeds: {
|
2008-05-13 03:45:58 +02:00
|
|
|
slow: 600,
|
2010-03-01 18:44:56 +01:00
|
|
|
fast: 200,
|
|
|
|
// Default speed
|
|
|
|
_default: 400
|
2007-09-07 23:57:40 +02:00
|
|
|
},
|
2009-06-02 04:14:58 +02:00
|
|
|
|
2008-04-30 01:34:50 +02:00
|
|
|
step: {
|
2009-12-18 17:16:26 +01:00
|
|
|
opacity: function( fx ) {
|
2010-09-16 16:00:56 +02:00
|
|
|
jQuery.style( fx.elem, "opacity", fx.now );
|
2008-04-30 01:34:50 +02:00
|
|
|
},
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2009-12-18 17:16:26 +01:00
|
|
|
_default: function( fx ) {
|
2009-11-27 20:28:42 +01:00
|
|
|
if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
|
2009-12-05 06:10:19 +01:00
|
|
|
fx.elem.style[ fx.prop ] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit;
|
2009-11-27 20:28:42 +01:00
|
|
|
} else {
|
2009-01-03 00:32:10 +01:00
|
|
|
fx.elem[ fx.prop ] = fx.now;
|
2009-11-27 20:28:42 +01:00
|
|
|
}
|
2008-04-30 01:34:50 +02:00
|
|
|
}
|
2007-09-07 23:57:40 +02:00
|
|
|
}
|
2008-04-30 01:34:50 +02:00
|
|
|
});
|
2009-10-26 23:07:57 +01:00
|
|
|
|
|
|
|
if ( jQuery.expr && jQuery.expr.filters ) {
|
2009-12-22 01:58:13 +01:00
|
|
|
jQuery.expr.filters.animated = function( elem ) {
|
|
|
|
return jQuery.grep(jQuery.timers, function( fn ) {
|
2009-10-26 23:07:57 +01:00
|
|
|
return elem === fn.elem;
|
|
|
|
}).length;
|
|
|
|
};
|
2009-11-07 17:22:35 +01:00
|
|
|
}
|
2010-09-08 18:00:29 +02:00
|
|
|
|
|
|
|
})( jQuery );
|