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 ) {
|
|
|
|
return this.queue(function(){
|
2007-06-21 04:38:16 +02:00
|
|
|
var hidden = jQuery(this).is(":hidden"),
|
|
|
|
opt = jQuery.speed(speed, easing, callback),
|
|
|
|
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-01-07 01:28:31 +01:00
|
|
|
this.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 );
|
|
|
|
if ( val.constructor == Number )
|
2007-08-22 06:52:53 +02:00
|
|
|
e.custom( e.cur() || 0, val );
|
2007-01-07 22:43:38 +01:00
|
|
|
else
|
2007-05-20 10:40:13 +02:00
|
|
|
e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop );
|
|
|
|
});
|
2007-08-20 05:59:34 +02:00
|
|
|
|
|
|
|
// For JS strict compliance
|
|
|
|
return true;
|
2007-01-07 22:43:38 +01:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
queue: function(type,fn){
|
|
|
|
if ( !fn ) {
|
|
|
|
fn = type;
|
|
|
|
type = "fx";
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.each(function(){
|
|
|
|
if ( !this.queue )
|
|
|
|
this.queue = {};
|
|
|
|
|
|
|
|
if ( !this.queue[type] )
|
|
|
|
this.queue[type] = [];
|
|
|
|
|
|
|
|
this.queue[type].push( fn );
|
|
|
|
|
|
|
|
if ( this.queue[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-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(){
|
|
|
|
jQuery.dequeue(this, "fx");
|
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
|
|
|
|
|
|
|
queue: {},
|
|
|
|
|
|
|
|
dequeue: function(elem,type){
|
|
|
|
type = type || "fx";
|
|
|
|
|
|
|
|
if ( elem.queue && elem.queue[type] ) {
|
|
|
|
// Remove self
|
|
|
|
elem.queue[type].shift();
|
|
|
|
|
|
|
|
// Get next function
|
|
|
|
var f = elem.queue[type][0];
|
|
|
|
|
|
|
|
if ( f ) f.apply( elem );
|
|
|
|
}
|
2007-01-07 01:28:31 +01:00
|
|
|
},
|
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-08-25 05:03:27 +02:00
|
|
|
var z = this, y = elem.style,
|
|
|
|
isprop = elem[prop] != null && y[prop] == null;
|
2007-01-07 22:43:38 +01:00
|
|
|
|
|
|
|
// Simple function for setting a style value
|
|
|
|
z.a = function(){
|
|
|
|
if ( options.step )
|
|
|
|
options.step.apply( elem, [ z.now ] );
|
|
|
|
|
|
|
|
if ( prop == "opacity" )
|
|
|
|
jQuery.attr(y, "opacity", z.now); // Let attr handle opacity
|
2007-03-15 17:54:13 +01:00
|
|
|
else {
|
2007-08-25 05:03:27 +02:00
|
|
|
if ( isprop )
|
|
|
|
elem[prop] = parseInt(z.now);
|
|
|
|
else
|
|
|
|
y[prop] = parseInt(z.now) + "px";
|
2007-07-15 04:42:11 +02:00
|
|
|
|
|
|
|
// Set display property to block for height/width animations
|
|
|
|
if ( prop == "height" || prop == "width" )
|
|
|
|
y.display = "block";
|
2007-03-15 17:54:13 +01:00
|
|
|
}
|
2007-01-07 22:43:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// Figure out the maximum number to run to
|
|
|
|
z.max = function(){
|
|
|
|
return parseFloat( jQuery.css(elem,prop) );
|
|
|
|
};
|
|
|
|
|
|
|
|
// Get the current size
|
|
|
|
z.cur = function(){
|
2007-08-25 05:03:27 +02:00
|
|
|
if ( isprop ) return elem[prop];
|
2007-01-07 22:43:38 +01:00
|
|
|
var r = parseFloat( jQuery.curCSS(elem, prop) );
|
|
|
|
return r && r > -10000 ? r : z.max();
|
|
|
|
};
|
|
|
|
|
|
|
|
// Start an animation from one number to another
|
|
|
|
z.custom = function(from,to){
|
|
|
|
z.startTime = (new Date()).getTime();
|
|
|
|
z.now = from;
|
|
|
|
z.a();
|
|
|
|
|
2007-09-04 02:28:22 +02:00
|
|
|
function t(){
|
2007-03-17 03:02:01 +01:00
|
|
|
return z.step(from, to);
|
2007-09-04 02:28:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
t.elem = elem;
|
|
|
|
|
|
|
|
jQuery.timers.push(t);
|
2007-03-17 03:02:01 +01:00
|
|
|
|
|
|
|
if ( jQuery.timers.length == 1 ) {
|
|
|
|
var timer = setInterval(function(){
|
2007-05-20 10:40:13 +02:00
|
|
|
var timers = jQuery.timers;
|
|
|
|
|
|
|
|
for ( var i = 0; i < timers.length; i++ )
|
|
|
|
if ( !timers[i]() )
|
|
|
|
timers.splice(i--, 1);
|
2007-03-17 03:02:01 +01:00
|
|
|
|
2007-05-20 10:40:13 +02:00
|
|
|
if ( !timers.length )
|
2007-03-17 03:02:01 +01:00
|
|
|
clearInterval( timer );
|
|
|
|
}, 13);
|
|
|
|
}
|
2007-01-07 22:43:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// Simple 'show' function
|
|
|
|
z.show = function(){
|
|
|
|
if ( !elem.orig ) elem.orig = {};
|
|
|
|
|
|
|
|
// Remember where we started, so that we can go back to it later
|
2007-03-16 21:37:10 +01:00
|
|
|
elem.orig[prop] = jQuery.attr( elem.style, prop );
|
2007-01-07 22:43:38 +01:00
|
|
|
|
|
|
|
options.show = true;
|
|
|
|
|
|
|
|
// Begin the animation
|
2007-03-15 17:54:13 +01:00
|
|
|
z.custom(0, this.cur());
|
2007-01-07 22:43:38 +01:00
|
|
|
|
2007-05-20 10:40:13 +02:00
|
|
|
// Make sure that we start at a small width/height to avoid any
|
|
|
|
// flash of content
|
2007-01-07 22:43:38 +01:00
|
|
|
if ( prop != "opacity" )
|
|
|
|
y[prop] = "1px";
|
2007-05-20 10:40:13 +02:00
|
|
|
|
|
|
|
// Start by showing the element
|
|
|
|
jQuery(elem).show();
|
2007-01-07 22:43:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// Simple 'hide' function
|
|
|
|
z.hide = function(){
|
|
|
|
if ( !elem.orig ) elem.orig = {};
|
|
|
|
|
|
|
|
// Remember where we started, so that we can go back to it later
|
2007-03-16 21:37:10 +01:00
|
|
|
elem.orig[prop] = jQuery.attr( elem.style, prop );
|
2007-01-07 22:43:38 +01:00
|
|
|
|
|
|
|
options.hide = true;
|
|
|
|
|
|
|
|
// Begin the animation
|
2007-03-15 17:54:13 +01:00
|
|
|
z.custom(this.cur(), 0);
|
2007-01-07 22:43:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// Each step of an animation
|
|
|
|
z.step = function(firstNum, lastNum){
|
|
|
|
var t = (new Date()).getTime();
|
|
|
|
|
|
|
|
if (t > options.duration + z.startTime) {
|
|
|
|
z.now = lastNum;
|
|
|
|
z.a();
|
|
|
|
|
|
|
|
if (elem.curAnim) elem.curAnim[ prop ] = true;
|
|
|
|
|
|
|
|
var done = true;
|
|
|
|
for ( var i in elem.curAnim )
|
|
|
|
if ( elem.curAnim[i] !== true )
|
|
|
|
done = false;
|
|
|
|
|
|
|
|
if ( done ) {
|
2007-07-05 06:27:46 +02:00
|
|
|
if ( options.display != null ) {
|
2007-03-15 17:54:13 +01:00
|
|
|
// Reset the overflow
|
2007-07-05 06:27:46 +02:00
|
|
|
y.overflow = options.overflow;
|
2007-01-07 22:43:38 +01:00
|
|
|
|
2007-03-15 17:54:13 +01:00
|
|
|
// Reset the display
|
2007-07-05 06:27:46 +02:00
|
|
|
y.display = options.display;
|
2007-05-20 10:40:13 +02:00
|
|
|
if ( jQuery.css(elem, "display") == "none" )
|
2007-03-15 17:54:13 +01:00
|
|
|
y.display = "block";
|
|
|
|
}
|
2007-01-07 22:43:38 +01:00
|
|
|
|
|
|
|
// Hide the element if the "hide" operation was done
|
2007-05-20 10:40:13 +02:00
|
|
|
if ( options.hide )
|
2007-01-14 07:22:20 +01:00
|
|
|
y.display = "none";
|
2007-01-07 22:43:38 +01:00
|
|
|
|
|
|
|
// Reset the properties, if the item has been hidden or shown
|
|
|
|
if ( options.hide || options.show )
|
|
|
|
for ( var p in elem.curAnim )
|
2007-03-15 17:54:13 +01:00
|
|
|
jQuery.attr(y, p, elem.orig[p]);
|
2007-01-07 22:43:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// If a callback was provided, execute it
|
2007-01-14 07:22:20 +01:00
|
|
|
if ( done && jQuery.isFunction( options.complete ) )
|
2007-01-07 22:43:38 +01:00
|
|
|
// Execute the complete function
|
|
|
|
options.complete.apply( elem );
|
2007-03-17 03:02:01 +01:00
|
|
|
|
|
|
|
return false;
|
2007-01-07 22:43:38 +01:00
|
|
|
} else {
|
|
|
|
var n = t - this.startTime;
|
|
|
|
// Figure out where in the animation we are and set the number
|
2007-01-07 01:28:31 +01:00
|
|
|
var p = n / options.duration;
|
2007-01-07 22:43:38 +01:00
|
|
|
|
2007-03-24 04:12:12 +01:00
|
|
|
// Perform the easing function, defaults to swing
|
2007-07-20 22:05:20 +02:00
|
|
|
z.now = jQuery.easing[options.easing || (jQuery.easing.swing ? "swing" : "linear")](p, n, firstNum, (lastNum-firstNum), options.duration);
|
2007-01-07 22:43:38 +01:00
|
|
|
|
|
|
|
// Perform the next step of the animation
|
|
|
|
z.a();
|
|
|
|
}
|
2007-03-17 03:02:01 +01:00
|
|
|
|
|
|
|
return true;
|
2007-01-07 22:43:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|