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(){
77 var opt = jQuery.extend({}, optall), p,
78 hidden = this.nodeType != 1 ? false : jQuery(this).is(":hidden"), self = this;
81 if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden )
82 return opt.complete.call(this);
84 if ( p == "height" || p == "width" ) {
85 // Store display property
86 opt.display = jQuery.css(this, "display");
88 // Make sure that nothing sneaks out
89 opt.overflow = this.style.overflow;
93 if ( opt.overflow != null )
94 this.style.overflow = "hidden";
96 opt.curAnim = jQuery.extend({}, prop);
98 jQuery.each( prop, function(name, val){
99 var e = new jQuery.fx( self, opt, name );
101 if ( /toggle|show|hide/.test(val) )
102 e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop );
104 var parts = val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),
105 start = e.cur(true) || 0;
108 var end = parseFloat(parts[2]),
109 unit = parts[3] || "px";
111 // We need to compute starting value
112 if ( unit != "px" ) {
113 self.style[ name ] = (end || 1) + unit;
114 start = ((end || 1) / e.cur(true)) * start;
115 self.style[ name ] = start + unit;
118 // If a +=/-= token was provided, we're doing a relative animation
120 end = ((parts[1] == "-=" ? -1 : 1) * end) + start;
122 e.custom( start, end, unit );
124 e.custom( start, val, "" );
128 // For JS strict compliance
133 queue: function(type, fn){
134 if ( jQuery.isFunction(type) || ( type && type.constructor == Array )) {
139 if ( !type || (typeof type == "string" && !fn) )
140 return queue( this[0], type );
142 return this.each(function(){
143 if ( fn.constructor == Array )
144 queue(this, type, fn);
146 queue(this, type).push( fn );
148 if ( queue(this, type).length == 1 )
154 stop: function(clearQueue, gotoEnd){
155 var timers = jQuery.timers;
160 this.each(function(){
161 // go in reverse order so anything added to the queue during the loop is ignored
162 for ( var i = timers.length - 1; i >= 0; i-- )
163 if ( timers[i].elem == this ) {
165 // force the next step to be the last
171 // start the next in the queue if the last step wasn't forced
180 var queue = function( elem, type, array ) {
185 var q = jQuery.data( elem, type + "queue" );
188 q = jQuery.data( elem, type + "queue", jQuery.makeArray(array) );
194 jQuery.fn.dequeue = function(type){
197 return this.each(function(){
198 var q = queue(this, type);
209 speed: function(speed, easing, fn) {
210 var opt = speed && speed.constructor == Object ? speed : {
211 complete: fn || !fn && easing ||
212 jQuery.isFunction( speed ) && speed,
214 easing: fn && easing || easing && easing.constructor != Function && easing
217 opt.duration = (opt.duration && opt.duration.constructor == Number ?
219 jQuery.fx.speeds[opt.duration]) || jQuery.fx.speeds.def;
222 opt.old = opt.complete;
223 opt.complete = function(){
224 if ( opt.queue !== false )
225 jQuery(this).dequeue();
226 if ( jQuery.isFunction( opt.old ) )
227 opt.old.call( this );
234 linear: function( p, n, firstNum, diff ) {
235 return firstNum + diff * p;
237 swing: function( p, n, firstNum, diff ) {
238 return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
245 fx: function( elem, options, prop ){
246 this.options = options;
256 jQuery.fx.prototype = {
258 // Simple function for setting a style value
260 if ( this.options.step )
261 this.options.step.call( this.elem, this.now, this );
263 (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
265 // Set display property to block for height/width animations
266 if ( this.prop == "height" || this.prop == "width" )
267 this.elem.style.display = "block";
270 // Get the current size
271 cur: function(force){
272 if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) )
273 return this.elem[ this.prop ];
275 var r = parseFloat(jQuery.css(this.elem, this.prop, force));
276 return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0;
279 // Start an animation from one number to another
280 custom: function(from, to, unit){
281 this.startTime = now();
284 this.unit = unit || this.unit || "px";
285 this.now = this.start;
286 this.pos = this.state = 0;
291 return self.step(gotoEnd);
296 jQuery.timers.push(t);
298 if ( jQuery.timerId == null ) {
299 jQuery.timerId = setInterval(function(){
300 var timers = jQuery.timers;
302 for ( var i = 0; i < timers.length; i++ )
304 timers.splice(i--, 1);
306 if ( !timers.length ) {
307 clearInterval( jQuery.timerId );
308 jQuery.timerId = null;
314 // Simple 'show' function
316 // Remember where we started, so that we can go back to it later
317 this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
318 this.options.show = true;
320 // Begin the animation
321 this.custom(0, this.cur());
323 // Make sure that we start at a small width/height to avoid any
325 if ( this.prop == "width" || this.prop == "height" )
326 this.elem.style[this.prop] = "1px";
328 // Start by showing the element
329 jQuery(this.elem).show();
332 // Simple 'hide' function
334 // Remember where we started, so that we can go back to it later
335 this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
336 this.options.hide = true;
338 // Begin the animation
339 this.custom(this.cur(), 0);
342 // Each step of an animation
343 step: function(gotoEnd){
346 if ( gotoEnd || t > this.options.duration + this.startTime ) {
348 this.pos = this.state = 1;
351 this.options.curAnim[ this.prop ] = true;
354 for ( var i in this.options.curAnim )
355 if ( this.options.curAnim[i] !== true )
359 if ( this.options.display != null ) {
360 // Reset the overflow
361 this.elem.style.overflow = this.options.overflow;
364 this.elem.style.display = this.options.display;
365 if ( jQuery.css(this.elem, "display") == "none" )
366 this.elem.style.display = "block";
369 // Hide the element if the "hide" operation was done
370 if ( this.options.hide )
371 this.elem.style.display = "none";
373 // Reset the properties, if the item has been hidden or shown
374 if ( this.options.hide || this.options.show )
375 for ( var p in this.options.curAnim )
376 jQuery.attr(this.elem.style, p, this.options.orig[p]);
380 // Execute the complete function
381 this.options.complete.call( this.elem );
385 var n = t - this.startTime;
386 this.state = n / this.options.duration;
388 // Perform the easing function, defaults to swing
389 this.pos = jQuery.easing[this.options.easing || (jQuery.easing.swing ? "swing" : "linear")](this.state, n, 0, 1, this.options.duration);
390 this.now = this.start + ((this.end - this.start) * this.pos);
392 // Perform the next step of the animation
401 jQuery.extend( jQuery.fx, {
409 scrollLeft: function(fx){
410 fx.elem.scrollLeft = fx.now;
413 scrollTop: function(fx){
414 fx.elem.scrollTop = fx.now;
417 opacity: function(fx){
418 jQuery.attr(fx.elem.style, "opacity", fx.now);
421 _default: function(fx){
422 ( fx.elem.style && ( fx.elem.style[ fx.prop ] = fx.now + fx.unit ) ) || ( fx.elem[ fx.prop ] = fx.now );