2007-01-07 22:43:38 +01:00
|
|
|
jQuery.fn.extend({
|
|
|
|
show: function(speed,callback){
|
2007-05-20 10:40:13 +02:00
|
|
|
return speed ?
|
|
|
|
this.animate({
|
2007-01-07 22:43:38 +01:00
|
|
|
height: "show", width: "show", opacity: "show"
|
|
|
|
}, speed, callback) :
|
|
|
|
|
2007-05-20 10:40:13 +02:00
|
|
|
this.filter(":hidden").each(function(){
|
2007-01-07 22:43:38 +01:00
|
|
|
this.style.display = this.oldblock ? this.oldblock : "";
|
|
|
|
if ( jQuery.css(this,"display") == "none" )
|
|
|
|
this.style.display = "block";
|
2007-05-20 10:40:13 +02:00
|
|
|
}).end();
|
2007-01-07 22:43:38 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
hide: function(speed,callback){
|
2007-05-20 10:40:13 +02:00
|
|
|
return speed ?
|
|
|
|
this.animate({
|
2007-01-07 22:43:38 +01:00
|
|
|
height: "hide", width: "hide", opacity: "hide"
|
|
|
|
}, speed, callback) :
|
|
|
|
|
2007-05-20 10:40:13 +02:00
|
|
|
this.filter(":visible").each(function(){
|
2007-01-07 22:43:38 +01:00
|
|
|
this.oldblock = this.oldblock || jQuery.css(this,"display");
|
|
|
|
if ( this.oldblock == "none" )
|
|
|
|
this.oldblock = "block";
|
|
|
|
this.style.display = "none";
|
2007-05-20 10:40:13 +02:00
|
|
|
}).end();
|
2007-01-07 22:43:38 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
// Save the old toggle function
|
|
|
|
_toggle: jQuery.fn.toggle,
|
|
|
|
|
|
|
|
toggle: function( fn, fn2 ){
|
2007-01-14 07:22:20 +01:00
|
|
|
return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ?
|
2007-01-07 22:43:38 +01:00
|
|
|
this._toggle( fn, fn2 ) :
|
2007-06-21 04:52:53 +02:00
|
|
|
fn ?
|
|
|
|
this.animate({
|
|
|
|
height: "toggle", width: "toggle", opacity: "toggle"
|
|
|
|
}, fn, fn2) :
|
|
|
|
this.each(function(){
|
|
|
|
jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ]();
|
|
|
|
});
|
2007-01-07 22:43:38 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
slideDown: function(speed,callback){
|
2007-05-20 10:40:13 +02:00
|
|
|
return this.animate({height: "show"}, speed, callback);
|
2007-01-07 22:43:38 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
slideUp: function(speed,callback){
|
2007-05-20 10:40:13 +02:00
|
|
|
return this.animate({height: "hide"}, speed, callback);
|
2007-01-07 22:43:38 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
slideToggle: function(speed, callback){
|
2007-05-20 10:40:13 +02:00
|
|
|
return this.animate({height: "toggle"}, speed, callback);
|
2007-01-07 22:43:38 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
fadeIn: function(speed, callback){
|
2007-05-20 10:40:13 +02:00
|
|
|
return this.animate({opacity: "show"}, speed, callback);
|
2007-01-07 22:43:38 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
fadeOut: function(speed, callback){
|
2007-05-20 10:40:13 +02:00
|
|
|
return this.animate({opacity: "hide"}, speed, callback);
|
2007-01-07 22:43:38 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
fadeTo: function(speed,to,callback){
|
|
|
|
return this.animate({opacity: to}, speed, callback);
|
|
|
|
},
|
|
|
|
|
|
|
|
animate: function( prop, speed, easing, callback ) {
|
2007-09-07 23:57:40 +02:00
|
|
|
var opt = jQuery.speed(speed, easing, callback);
|
|
|
|
|
|
|
|
return this[ opt.queue === false ? "each" : "queue" ](function(){
|
|
|
|
opt = jQuery.extend({}, opt);
|
|
|
|
var hidden = jQuery(this).is(":hidden"), self = this;
|
2007-05-20 10:40:13 +02:00
|
|
|
|
2007-07-05 06:27:46 +02:00
|
|
|
for ( var p in prop ) {
|
2007-06-21 04:38:16 +02:00
|
|
|
if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden )
|
|
|
|
return jQuery.isFunction(opt.complete) && opt.complete.apply(this);
|
2007-06-21 05:09:04 +02:00
|
|
|
|
2007-07-05 06:27:46 +02:00
|
|
|
if ( p == "height" || p == "width" ) {
|
|
|
|
// Store display property
|
|
|
|
opt.display = jQuery.css(this, "display");
|
|
|
|
|
|
|
|
// Make sure that nothing sneaks out
|
|
|
|
opt.overflow = this.style.overflow;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( opt.overflow != null )
|
|
|
|
this.style.overflow = "hidden";
|
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
opt.curAnim = jQuery.extend({}, prop);
|
2007-01-07 22:43:38 +01:00
|
|
|
|
2007-05-20 10:40:13 +02:00
|
|
|
jQuery.each( prop, function(name, val){
|
|
|
|
var e = new jQuery.fx( self, opt, name );
|
2007-09-07 23:57:40 +02:00
|
|
|
|
|
|
|
if ( /toggle|show|hide/.test(val) )
|
2007-05-20 10:40:13 +02:00
|
|
|
e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop );
|
2007-09-07 23:57:40 +02:00
|
|
|
else {
|
2007-09-15 04:40:42 +02:00
|
|
|
var parts = val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),
|
2007-09-07 23:57:40 +02:00
|
|
|
start = e.cur(true) || 0;
|
|
|
|
|
|
|
|
if ( parts ) {
|
2007-09-15 05:12:56 +02:00
|
|
|
var end = parseFloat(parts[2]),
|
|
|
|
unit = parts[3] || "px";
|
2007-09-07 23:57:40 +02:00
|
|
|
|
|
|
|
// We need to compute starting value
|
|
|
|
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
|
2007-09-13 00:16:43 +02:00
|
|
|
if ( parts[1] )
|
2007-09-15 04:40:42 +02:00
|
|
|
end = ((parts[1] == "-=" ? -1 : 1) * end) + start;
|
2007-09-13 00:16:43 +02:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
e.custom( start, end, unit );
|
|
|
|
} else
|
|
|
|
e.custom( start, val, "" );
|
|
|
|
}
|
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
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
queue: function(type, fn){
|
2007-09-14 19:47:01 +02:00
|
|
|
if ( jQuery.isFunction(type) ) {
|
2007-01-07 22:43:38 +01:00
|
|
|
fn = type;
|
|
|
|
type = "fx";
|
|
|
|
}
|
2007-09-07 23:57:40 +02:00
|
|
|
|
2007-09-15 04:40:42 +02:00
|
|
|
if ( !type || (typeof type == "string" && !fn) )
|
2007-09-07 23:57:40 +02:00
|
|
|
return queue( this[0], type );
|
|
|
|
|
2007-01-07 22:43:38 +01:00
|
|
|
return this.each(function(){
|
2007-09-07 23:57:40 +02:00
|
|
|
if ( fn.constructor == Array )
|
|
|
|
queue(this, type, fn);
|
|
|
|
else {
|
|
|
|
queue(this, type).push( fn );
|
|
|
|
|
|
|
|
if ( queue(this, type).length == 1 )
|
|
|
|
fn.apply(this);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2007-09-04 02:28:22 +02:00
|
|
|
stop: function(){
|
|
|
|
var timers = jQuery.timers;
|
|
|
|
|
|
|
|
return this.each(function(){
|
|
|
|
for ( var i = 0; i < timers.length; i++ )
|
|
|
|
if ( timers[i].elem == this )
|
|
|
|
timers.splice(i--, 1);
|
2007-09-09 18:12:56 +02:00
|
|
|
}).dequeue();
|
2007-01-07 22:43:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2007-09-10 21:43:58 +02:00
|
|
|
var queue = function( elem, type, array ) {
|
2007-09-07 23:57:40 +02:00
|
|
|
if ( !elem )
|
|
|
|
return;
|
|
|
|
|
2007-09-10 21:43:58 +02:00
|
|
|
var q = jQuery.data( elem, type + "queue" );
|
2007-09-07 23:57:40 +02:00
|
|
|
|
2007-09-10 21:43:58 +02:00
|
|
|
if ( !q || array )
|
|
|
|
q = jQuery.data( elem, type + "queue",
|
2007-09-09 18:17:32 +02:00
|
|
|
array ? jQuery.makeArray(array) : [] );
|
2007-09-07 23:57:40 +02:00
|
|
|
|
2007-09-10 21:43:58 +02:00
|
|
|
return q;
|
|
|
|
};
|
|
|
|
|
|
|
|
jQuery.fn.dequeue = function(type){
|
|
|
|
type = type || "fx";
|
|
|
|
|
|
|
|
return this.each(function(){
|
|
|
|
var q = queue(this, type);
|
|
|
|
|
|
|
|
q.shift();
|
|
|
|
|
|
|
|
if ( q.length )
|
|
|
|
q[0].apply( this );
|
|
|
|
});
|
|
|
|
};
|
2007-09-07 23:57:40 +02:00
|
|
|
|
2007-01-07 22:43:38 +01:00
|
|
|
jQuery.extend({
|
|
|
|
|
|
|
|
speed: function(speed, easing, fn) {
|
2007-01-10 01:46:10 +01:00
|
|
|
var opt = speed && speed.constructor == Object ? speed : {
|
2007-01-07 01:28:31 +01: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,
|
2007-07-20 22:05:20 +02:00
|
|
|
easing: fn && easing || easing && easing.constructor != Function && easing
|
2007-01-07 01:28:31 +01:00
|
|
|
};
|
2007-01-07 22:43:38 +01:00
|
|
|
|
2007-01-10 02:06:22 +01:00
|
|
|
opt.duration = (opt.duration && opt.duration.constructor == Number ?
|
2007-01-07 01:28:31 +01:00
|
|
|
opt.duration :
|
2007-01-07 22:43:38 +01:00
|
|
|
{ slow: 600, fast: 200 }[opt.duration]) || 400;
|
|
|
|
|
|
|
|
// Queueing
|
2007-01-14 07:22:20 +01:00
|
|
|
opt.old = opt.complete;
|
2007-01-07 22:43:38 +01:00
|
|
|
opt.complete = function(){
|
2007-09-07 23:57:40 +02:00
|
|
|
jQuery(this).dequeue();
|
2007-01-14 07:22:20 +01:00
|
|
|
if ( jQuery.isFunction( opt.old ) )
|
|
|
|
opt.old.apply( this );
|
2007-01-07 22:43:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
return opt;
|
|
|
|
},
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
},
|
2007-01-07 22:43:38 +01:00
|
|
|
|
2007-03-17 03:02:01 +01:00
|
|
|
timers: [],
|
|
|
|
|
2007-01-07 22:43:38 +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
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
if ( !options.orig )
|
|
|
|
options.orig = {};
|
|
|
|
}
|
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 = {
|
2007-01-07 22:43:38 +01:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
// Simple function for setting a style value
|
|
|
|
update: function(){
|
|
|
|
if ( this.options.step )
|
|
|
|
this.options.step.apply( this.elem, [ this.now, this ] );
|
2007-01-07 22:43:38 +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
|
|
|
|
if ( this.prop == "height" || this.prop == "width" )
|
|
|
|
this.elem.style.display = "block";
|
|
|
|
},
|
|
|
|
|
|
|
|
// Get the current size
|
|
|
|
cur: function(force){
|
|
|
|
if ( this.elem[this.prop] != null && this.elem.style[this.prop] == null )
|
|
|
|
return this.elem[ this.prop ];
|
2007-09-04 02:28:22 +02:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
var r = parseFloat(jQuery.curCSS(this.elem, this.prop, force));
|
|
|
|
return r && r > -10000 ? r : parseFloat(jQuery.css(this.elem, this.prop)) || 0;
|
|
|
|
},
|
2007-09-04 02:28:22 +02:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
// Start an animation from one number to another
|
|
|
|
custom: function(from, to, unit){
|
|
|
|
this.startTime = (new Date()).getTime();
|
|
|
|
this.start = from;
|
|
|
|
this.end = to;
|
|
|
|
this.unit = unit || this.unit || "px";
|
|
|
|
this.now = this.start;
|
|
|
|
this.pos = this.state = 0;
|
|
|
|
this.update();
|
|
|
|
|
|
|
|
var self = this;
|
|
|
|
function t(){
|
|
|
|
return self.step();
|
|
|
|
}
|
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
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
jQuery.timers.push(t);
|
2007-01-07 22:43:38 +01:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
if ( jQuery.timers.length == 1 ) {
|
|
|
|
var timer = setInterval(function(){
|
|
|
|
var timers = jQuery.timers;
|
|
|
|
|
|
|
|
for ( var i = 0; i < timers.length; i++ )
|
|
|
|
if ( !timers[i]() )
|
|
|
|
timers.splice(i--, 1);
|
2007-01-07 22:43:38 +01:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
if ( !timers.length )
|
|
|
|
clearInterval( timer );
|
|
|
|
}, 13);
|
|
|
|
}
|
|
|
|
},
|
2007-01-07 22:43:38 +01:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
// Simple 'show' function
|
|
|
|
show: function(){
|
|
|
|
// Remember where we started, so that we can go back to it later
|
|
|
|
this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
|
|
|
|
this.options.show = true;
|
2007-01-07 22:43:38 +01:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
// Begin the animation
|
|
|
|
this.custom(0, this.cur());
|
2007-01-07 22:43:38 +01:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
// Make sure that we start at a small width/height to avoid any
|
|
|
|
// flash of content
|
|
|
|
if ( this.prop == "width" || this.prop == "height" )
|
|
|
|
this.elem.style[this.prop] = "1px";
|
|
|
|
|
|
|
|
// Start by showing the element
|
|
|
|
jQuery(this.elem).show();
|
|
|
|
},
|
2007-01-07 22:43:38 +01:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
// Simple 'hide' function
|
|
|
|
hide: function(){
|
|
|
|
// Remember where we started, so that we can go back to it later
|
|
|
|
this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
|
|
|
|
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
|
|
|
|
step: function(){
|
|
|
|
var t = (new Date()).getTime();
|
2007-01-07 22:43:38 +01:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
if ( t > this.options.duration + this.startTime ) {
|
|
|
|
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
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
var done = true;
|
|
|
|
for ( var i in this.options.curAnim )
|
|
|
|
if ( this.options.curAnim[i] !== true )
|
|
|
|
done = false;
|
2007-03-17 03:02:01 +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;
|
2007-01-07 22:43:38 +01:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
// Reset the display
|
|
|
|
this.elem.style.display = this.options.display;
|
|
|
|
if ( jQuery.css(this.elem, "display") == "none" )
|
|
|
|
this.elem.style.display = "block";
|
|
|
|
}
|
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
|
|
|
|
if ( this.options.hide )
|
|
|
|
this.elem.style.display = "none";
|
|
|
|
|
|
|
|
// Reset the properties, if the item has been hidden or shown
|
|
|
|
if ( this.options.hide || this.options.show )
|
|
|
|
for ( var p in this.options.curAnim )
|
|
|
|
jQuery.attr(this.elem.style, p, this.options.orig[p]);
|
2007-01-07 22:43:38 +01:00
|
|
|
}
|
2007-03-17 03:02:01 +01:00
|
|
|
|
2007-09-07 23:57:40 +02:00
|
|
|
// If a callback was provided, execute it
|
|
|
|
if ( done && jQuery.isFunction( this.options.complete ) )
|
|
|
|
// Execute the complete function
|
|
|
|
this.options.complete.apply( this.elem );
|
|
|
|
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
var n = t - this.startTime;
|
|
|
|
this.state = n / this.options.duration;
|
|
|
|
|
|
|
|
// Perform the easing function, defaults to swing
|
|
|
|
this.pos = jQuery.easing[this.options.easing || (jQuery.easing.swing ? "swing" : "linear")](this.state, n, 0, 1, this.options.duration);
|
|
|
|
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
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
jQuery.fx.step = {
|
|
|
|
scrollLeft: function(fx){
|
|
|
|
fx.elem.scrollLeft = fx.now;
|
|
|
|
},
|
|
|
|
|
|
|
|
scrollTop: function(fx){
|
|
|
|
fx.elem.scrollTop = fx.now;
|
|
|
|
},
|
|
|
|
|
|
|
|
opacity: function(fx){
|
|
|
|
jQuery.attr(fx.elem.style, "opacity", fx.now);
|
|
|
|
},
|
|
|
|
|
|
|
|
_default: function(fx){
|
|
|
|
fx.elem.style[ fx.prop ] = fx.now + fx.unit;
|
|
|
|
}
|
|
|
|
};
|