2 show: function(speed,callback){
5 height: "show", width: "show", opacity: "show"
8 this.filter(":hidden").each(function(){
9 this.style.display = this.oldblock ? this.oldblock : "";
10 if ( jQuery.css(this,"display") == "none" )
11 this.style.display = "block";
15 hide: function(speed,callback){
18 height: "hide", width: "hide", opacity: "hide"
21 this.filter(":visible").each(function(){
22 this.oldblock = this.oldblock || jQuery.css(this,"display");
23 if ( this.oldblock == "none" )
24 this.oldblock = "block";
25 this.style.display = "none";
29 // Save the old toggle function
30 _toggle: jQuery.fn.toggle,
32 toggle: function( fn, fn2 ){
33 return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ?
34 this._toggle( fn, fn2 ) :
37 height: "toggle", width: "toggle", opacity: "toggle"
40 jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ]();
44 slideDown: function(speed,callback){
45 return this.animate({height: "show"}, speed, callback);
48 slideUp: function(speed,callback){
49 return this.animate({height: "hide"}, speed, callback);
52 slideToggle: function(speed, callback){
53 return this.animate({height: "toggle"}, speed, callback);
56 fadeIn: function(speed, callback){
57 return this.animate({opacity: "show"}, speed, callback);
60 fadeOut: function(speed, callback){
61 return this.animate({opacity: "hide"}, speed, callback);
64 fadeTo: function(speed,to,callback){
65 return this.animate({opacity: to}, speed, callback);
68 animate: function( prop, speed, easing, callback ) {
69 return this.queue(function(){
70 var hidden = jQuery(this).is(":hidden"),
71 opt = jQuery.speed(speed, easing, callback),
74 for ( var p in prop ) {
75 if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden )
76 return jQuery.isFunction(opt.complete) && opt.complete.apply(this);
78 if ( p == "height" || p == "width" ) {
79 // Store display property
80 opt.display = jQuery.css(this, "display");
82 // Make sure that nothing sneaks out
83 opt.overflow = this.style.overflow;
87 if ( opt.overflow != null )
88 this.style.overflow = "hidden";
90 this.curAnim = jQuery.extend({}, prop);
92 jQuery.each( prop, function(name, val){
93 var e = new jQuery.fx( self, opt, name );
94 if ( val.constructor == Number )
95 e.custom( e.cur() || 0, val );
97 e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop );
100 // For JS strict compliance
105 queue: function(type,fn){
111 return this.each(function(){
115 if ( !this.queue[type] )
116 this.queue[type] = [];
118 this.queue[type].push( fn );
120 if ( this.queue[type].length == 1 )
126 var timers = jQuery.timers;
128 return this.each(function(){
129 for ( var i = 0; i < timers.length; i++ )
130 if ( timers[i].elem == this )
131 timers.splice(i--, 1);
139 speed: function(speed, easing, fn) {
140 var opt = speed && speed.constructor == Object ? speed : {
141 complete: fn || !fn && easing ||
142 jQuery.isFunction( speed ) && speed,
144 easing: fn && easing || easing && easing.constructor != Function && easing
147 opt.duration = (opt.duration && opt.duration.constructor == Number ?
149 { slow: 600, fast: 200 }[opt.duration]) || 400;
152 opt.old = opt.complete;
153 opt.complete = function(){
154 jQuery.dequeue(this, "fx");
155 if ( jQuery.isFunction( opt.old ) )
156 opt.old.apply( this );
163 linear: function( p, n, firstNum, diff ) {
164 return firstNum + diff * p;
166 swing: function( p, n, firstNum, diff ) {
167 return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
173 dequeue: function(elem,type){
176 if ( elem.queue && elem.queue[type] ) {
178 elem.queue[type].shift();
181 var f = elem.queue[type][0];
183 if ( f ) f.apply( elem );
189 fx: function( elem, options, prop ){
191 var z = this, y = elem.style,
192 isprop = elem[prop] != null && y[prop] == null;
194 // Simple function for setting a style value
197 options.step.apply( elem, [ z.now ] );
199 if ( prop == "opacity" )
200 jQuery.attr(y, "opacity", z.now); // Let attr handle opacity
203 elem[prop] = parseInt(z.now);
205 y[prop] = parseInt(z.now) + "px";
207 // Set display property to block for height/width animations
208 if ( prop == "height" || prop == "width" )
213 // Figure out the maximum number to run to
215 return parseFloat( jQuery.css(elem,prop) );
218 // Get the current size
220 if ( isprop ) return elem[prop];
221 var r = parseFloat( jQuery.curCSS(elem, prop) );
222 return r && r > -10000 ? r : z.max();
225 // Start an animation from one number to another
226 z.custom = function(from,to){
227 z.startTime = (new Date()).getTime();
232 return z.step(from, to);
237 jQuery.timers.push(t);
239 if ( jQuery.timers.length == 1 ) {
240 var timer = setInterval(function(){
241 var timers = jQuery.timers;
243 for ( var i = 0; i < timers.length; i++ )
245 timers.splice(i--, 1);
247 if ( !timers.length )
248 clearInterval( timer );
253 // Simple 'show' function
255 if ( !elem.orig ) elem.orig = {};
257 // Remember where we started, so that we can go back to it later
258 elem.orig[prop] = jQuery.attr( elem.style, prop );
262 // Begin the animation
263 z.custom(0, this.cur());
265 // Make sure that we start at a small width/height to avoid any
267 if ( prop != "opacity" )
270 // Start by showing the element
274 // Simple 'hide' function
276 if ( !elem.orig ) elem.orig = {};
278 // Remember where we started, so that we can go back to it later
279 elem.orig[prop] = jQuery.attr( elem.style, prop );
283 // Begin the animation
284 z.custom(this.cur(), 0);
287 // Each step of an animation
288 z.step = function(firstNum, lastNum){
289 var t = (new Date()).getTime();
291 if (t > options.duration + z.startTime) {
295 if (elem.curAnim) elem.curAnim[ prop ] = true;
298 for ( var i in elem.curAnim )
299 if ( elem.curAnim[i] !== true )
303 if ( options.display != null ) {
304 // Reset the overflow
305 y.overflow = options.overflow;
308 y.display = options.display;
309 if ( jQuery.css(elem, "display") == "none" )
313 // Hide the element if the "hide" operation was done
317 // Reset the properties, if the item has been hidden or shown
318 if ( options.hide || options.show )
319 for ( var p in elem.curAnim )
320 jQuery.attr(y, p, elem.orig[p]);
323 // If a callback was provided, execute it
324 if ( done && jQuery.isFunction( options.complete ) )
325 // Execute the complete function
326 options.complete.apply( elem );
330 var n = t - this.startTime;
331 // Figure out where in the animation we are and set the number
332 var p = n / options.duration;
334 // Perform the easing function, defaults to swing
335 z.now = jQuery.easing[options.easing || (jQuery.easing.swing ? "swing" : "linear")](p, n, firstNum, (lastNum-firstNum), options.duration);
337 // Perform the next step of the animation