2 show: function(speed,callback){
5 height: "show", width: "show", opacity: "show"
8 this.filter(":hidden").each(function(){
9 this.style.display = this.oldblock || "";
10 if ( jQuery.css(this,"display") == "none" ) {
11 var elem = jQuery("<" + this.tagName + " />").appendTo("body");
12 this.style.display = elem.css("display");
13 // handle an edge condition where css is - div { display:none; } or similar
14 if (this.style.display == "none")
15 this.style.display = "block";
21 hide: function(speed,callback){
24 height: "hide", width: "hide", opacity: "hide"
27 this.filter(":visible").each(function(){
28 this.oldblock = this.oldblock || jQuery.css(this,"display");
29 this.style.display = "none";
33 // Save the old toggle function
34 _toggle: jQuery.fn.toggle,
36 toggle: function( fn, fn2 ){
37 return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ?
38 this._toggle.apply( this, arguments ) :
41 height: "toggle", width: "toggle", opacity: "toggle"
44 jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ]();
48 slideDown: function(speed,callback){
49 return this.animate({height: "show"}, speed, callback);
52 slideUp: function(speed,callback){
53 return this.animate({height: "hide"}, speed, callback);
56 slideToggle: function(speed, callback){
57 return this.animate({height: "toggle"}, speed, callback);
60 fadeIn: function(speed, callback){
61 return this.animate({opacity: "show"}, speed, callback);
64 fadeOut: function(speed, callback){
65 return this.animate({opacity: "hide"}, speed, callback);
68 fadeTo: function(speed,to,callback){
69 return this.animate({opacity: to}, speed, callback);
72 animate: function( prop, speed, easing, callback ) {
73 var optall = jQuery.speed(speed, easing, callback);
75 return this[ optall.queue === false ? "each" : "queue" ](function(){
76 if ( this.nodeType != 1)
79 var opt = jQuery.extend({}, optall), p,
80 hidden = jQuery(this).is(":hidden"), self = this;
83 if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden )
84 return jQuery.isFunction(opt.complete) && opt.complete.call(this);
86 if ( p == "height" || p == "width" ) {
87 // Store display property
88 opt.display = jQuery.css(this, "display");
90 // Make sure that nothing sneaks out
91 opt.overflow = this.style.overflow;
95 if ( opt.overflow != null )
96 this.style.overflow = "hidden";
98 opt.curAnim = jQuery.extend({}, prop);
100 jQuery.each( prop, function(name, val){
101 var e = new jQuery.fx( self, opt, name );
103 if ( /toggle|show|hide/.test(val) )
104 e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop );
106 var parts = val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),
107 start = e.cur(true) || 0;
110 var end = parseFloat(parts[2]),
111 unit = parts[3] || "px";
113 // We need to compute starting value
114 if ( unit != "px" ) {
115 self.style[ name ] = (end || 1) + unit;
116 start = ((end || 1) / e.cur(true)) * start;
117 self.style[ name ] = start + unit;
120 // If a +=/-= token was provided, we're doing a relative animation
122 end = ((parts[1] == "-=" ? -1 : 1) * end) + start;
124 e.custom( start, end, unit );
126 e.custom( start, val, "" );
130 // For JS strict compliance
135 queue: function(type, fn){
136 if ( jQuery.isFunction(type) || ( type && type.constructor == Array )) {
141 if ( !type || (typeof type == "string" && !fn) )
142 return queue( this[0], type );
144 return this.each(function(){
145 if ( fn.constructor == Array )
146 queue(this, type, fn);
148 queue(this, type).push( fn );
150 if ( queue(this, type).length == 1 )
156 stop: function(clearQueue, gotoEnd){
157 var timers = jQuery.timers;
162 this.each(function(){
163 // go in reverse order so anything added to the queue during the loop is ignored
164 for ( var i = timers.length - 1; i >= 0; i-- )
165 if ( timers[i].elem == this ) {
167 // force the next step to be the last
173 // start the next in the queue if the last step wasn't forced
182 var queue = function( elem, type, array ) {
187 var q = jQuery.data( elem, type + "queue" );
190 q = jQuery.data( elem, type + "queue", jQuery.makeArray(array) );
196 jQuery.fn.dequeue = function(type){
199 return this.each(function(){
200 var q = queue(this, type);
211 speed: function(speed, easing, fn) {
212 var opt = speed && speed.constructor == Object ? speed : {
213 complete: fn || !fn && easing ||
214 jQuery.isFunction( speed ) && speed,
216 easing: fn && easing || easing && easing.constructor != Function && easing
219 opt.duration = (opt.duration && opt.duration.constructor == Number ?
221 jQuery.fx.speeds[opt.duration]) || jQuery.fx.speeds.def;
224 opt.old = opt.complete;
225 opt.complete = function(){
226 if ( opt.queue !== false )
227 jQuery(this).dequeue();
228 if ( jQuery.isFunction( opt.old ) )
229 opt.old.call( this );
236 linear: function( p, n, firstNum, diff ) {
237 return firstNum + diff * p;
239 swing: function( p, n, firstNum, diff ) {
240 return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
247 fx: function( elem, options, prop ){
248 this.options = options;
258 jQuery.fx.prototype = {
260 // Simple function for setting a style value
262 if ( this.options.step )
263 this.options.step.call( this.elem, this.now, this );
265 (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
267 // Set display property to block for height/width animations
268 if ( this.prop == "height" || this.prop == "width" )
269 this.elem.style.display = "block";
272 // Get the current size
273 cur: function(force){
274 if ( this.elem[this.prop] != null && this.elem.style[this.prop] == null )
275 return this.elem[ this.prop ];
277 var r = parseFloat(jQuery.css(this.elem, this.prop, force));
278 return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0;
281 // Start an animation from one number to another
282 custom: function(from, to, unit){
283 this.startTime = now();
286 this.unit = unit || this.unit || "px";
287 this.now = this.start;
288 this.pos = this.state = 0;
293 return self.step(gotoEnd);
298 jQuery.timers.push(t);
300 if ( jQuery.timerId == null ) {
301 jQuery.timerId = setInterval(function(){
302 var timers = jQuery.timers;
304 for ( var i = 0; i < timers.length; i++ )
306 timers.splice(i--, 1);
308 if ( !timers.length ) {
309 clearInterval( jQuery.timerId );
310 jQuery.timerId = null;
316 // Simple 'show' function
318 // Remember where we started, so that we can go back to it later
319 this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
320 this.options.show = true;
322 // Begin the animation
323 this.custom(0, this.cur());
325 // Make sure that we start at a small width/height to avoid any
327 if ( this.prop == "width" || this.prop == "height" )
328 this.elem.style[this.prop] = "1px";
330 // Start by showing the element
331 jQuery(this.elem).show();
334 // Simple 'hide' function
336 // Remember where we started, so that we can go back to it later
337 this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
338 this.options.hide = true;
340 // Begin the animation
341 this.custom(this.cur(), 0);
344 // Each step of an animation
345 step: function(gotoEnd){
348 if ( gotoEnd || t > this.options.duration + this.startTime ) {
350 this.pos = this.state = 1;
353 this.options.curAnim[ this.prop ] = true;
356 for ( var i in this.options.curAnim )
357 if ( this.options.curAnim[i] !== true )
361 if ( this.options.display != null ) {
362 // Reset the overflow
363 this.elem.style.overflow = this.options.overflow;
366 this.elem.style.display = this.options.display;
367 if ( jQuery.css(this.elem, "display") == "none" )
368 this.elem.style.display = "block";
371 // Hide the element if the "hide" operation was done
372 if ( this.options.hide )
373 this.elem.style.display = "none";
375 // Reset the properties, if the item has been hidden or shown
376 if ( this.options.hide || this.options.show )
377 for ( var p in this.options.curAnim )
378 jQuery.attr(this.elem.style, p, this.options.orig[p]);
381 // If a callback was provided, execute it
382 if ( done && jQuery.isFunction( this.options.complete ) )
383 // Execute the complete function
384 this.options.complete.call( this.elem );
388 var n = t - this.startTime;
389 this.state = n / this.options.duration;
391 // Perform the easing function, defaults to swing
392 this.pos = jQuery.easing[this.options.easing || (jQuery.easing.swing ? "swing" : "linear")](this.state, n, 0, 1, this.options.duration);
393 this.now = this.start + ((this.end - this.start) * this.pos);
395 // Perform the next step of the animation
404 jQuery.extend( jQuery.fx, {
412 scrollLeft: function(fx){
413 fx.elem.scrollLeft = fx.now;
416 scrollTop: function(fx){
417 fx.elem.scrollTop = fx.now;
420 opacity: function(fx){
421 jQuery.attr(fx.elem.style, "opacity", fx.now);
424 _default: function(fx){
425 fx.elem.style[ fx.prop ] = fx.now + fx.unit;