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 && jQuery(this).is(":hidden"),
82 if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden )
83 return opt.complete.call(this);
85 if ( p == "height" || p == "width" ) {
86 // Store display property
87 opt.display = jQuery.css(this, "display");
89 // Make sure that nothing sneaks out
90 opt.overflow = this.style.overflow;
94 if ( opt.overflow != null )
95 this.style.overflow = "hidden";
97 opt.curAnim = jQuery.extend({}, prop);
99 jQuery.each( prop, function(name, val){
100 var e = new jQuery.fx( self, opt, name );
102 if ( /toggle|show|hide/.test(val) )
103 e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop );
105 var parts = val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),
106 start = e.cur(true) || 0;
109 var end = parseFloat(parts[2]),
110 unit = parts[3] || "px";
112 // We need to compute starting value
113 if ( unit != "px" ) {
114 self.style[ name ] = (end || 1) + unit;
115 start = ((end || 1) / e.cur(true)) * start;
116 self.style[ name ] = start + unit;
119 // If a +=/-= token was provided, we're doing a relative animation
121 end = ((parts[1] == "-=" ? -1 : 1) * end) + start;
123 e.custom( start, end, unit );
125 e.custom( start, val, "" );
129 // For JS strict compliance
134 queue: function(type, fn){
135 if ( jQuery.isFunction(type) || ( type && type.constructor == Array )) {
140 if ( !type || (typeof type == "string" && !fn) )
141 return queue( this[0], type );
143 return this.each(function(){
144 if ( fn.constructor == Array )
145 queue(this, type, fn);
147 queue(this, type).push( fn );
149 if ( queue(this, type).length == 1 )
155 stop: function(clearQueue, gotoEnd){
156 var timers = jQuery.timers;
161 this.each(function(){
162 // go in reverse order so anything added to the queue during the loop is ignored
163 for ( var i = timers.length - 1; i >= 0; i-- )
164 if ( timers[i].elem == this ) {
166 // force the next step to be the last
172 // start the next in the queue if the last step wasn't forced
181 var queue = function( elem, type, array ) {
186 var q = jQuery.data( elem, type + "queue" );
189 q = jQuery.data( elem, type + "queue", jQuery.makeArray(array) );
195 jQuery.fn.dequeue = function(type){
198 return this.each(function(){
199 var q = queue(this, type);
210 speed: function(speed, easing, fn) {
211 var opt = speed && speed.constructor == Object ? speed : {
212 complete: fn || !fn && easing ||
213 jQuery.isFunction( speed ) && speed,
215 easing: fn && easing || easing && easing.constructor != Function && easing
218 opt.duration = (opt.duration && opt.duration.constructor == Number ?
220 jQuery.fx.speeds[opt.duration]) || jQuery.fx.speeds.def;
223 opt.old = opt.complete;
224 opt.complete = function(){
225 if ( opt.queue !== false )
226 jQuery(this).dequeue();
227 if ( jQuery.isFunction( opt.old ) )
228 opt.old.call( this );
235 linear: function( p, n, firstNum, diff ) {
236 return firstNum + diff * p;
238 swing: function( p, n, firstNum, diff ) {
239 return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
246 fx: function( elem, options, prop ){
247 this.options = options;
257 jQuery.fx.prototype = {
259 // Simple function for setting a style value
261 if ( this.options.step )
262 this.options.step.call( this.elem, this.now, this );
264 (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
266 // Set display property to block for height/width animations
267 if ( this.prop == "height" || this.prop == "width" )
268 this.elem.style.display = "block";
271 // Get the current size
272 cur: function(force){
273 if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) )
274 return this.elem[ this.prop ];
276 var r = parseFloat(jQuery.css(this.elem, this.prop, force));
277 return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0;
280 // Start an animation from one number to another
281 custom: function(from, to, unit){
282 this.startTime = now();
285 this.unit = unit || this.unit || "px";
286 this.now = this.start;
287 this.pos = this.state = 0;
292 return self.step(gotoEnd);
297 jQuery.timers.push(t);
299 if ( jQuery.timerId == null ) {
300 jQuery.timerId = setInterval(function(){
301 var timers = jQuery.timers;
303 for ( var i = 0; i < timers.length; i++ )
305 timers.splice(i--, 1);
307 if ( !timers.length ) {
308 clearInterval( jQuery.timerId );
309 jQuery.timerId = null;
315 // Simple 'show' function
317 // Remember where we started, so that we can go back to it later
318 this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
319 this.options.show = true;
321 // Begin the animation
322 this.custom(0, this.cur());
324 // Make sure that we start at a small width/height to avoid any
326 if ( this.prop == "width" || this.prop == "height" )
327 this.elem.style[this.prop] = "1px";
329 // Start by showing the element
330 jQuery(this.elem).show();
333 // Simple 'hide' function
335 // Remember where we started, so that we can go back to it later
336 this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
337 this.options.hide = true;
339 // Begin the animation
340 this.custom(this.cur(), 0);
343 // Each step of an animation
344 step: function(gotoEnd){
347 if ( gotoEnd || t > this.options.duration + this.startTime ) {
349 this.pos = this.state = 1;
352 this.options.curAnim[ this.prop ] = true;
355 for ( var i in this.options.curAnim )
356 if ( this.options.curAnim[i] !== true )
360 if ( this.options.display != null ) {
361 // Reset the overflow
362 this.elem.style.overflow = this.options.overflow;
365 this.elem.style.display = this.options.display;
366 if ( jQuery.css(this.elem, "display") == "none" )
367 this.elem.style.display = "block";
370 // Hide the element if the "hide" operation was done
371 if ( this.options.hide )
372 this.elem.style.display = "none";
374 // Reset the properties, if the item has been hidden or shown
375 if ( this.options.hide || this.options.show )
376 for ( var p in this.options.curAnim )
377 jQuery.attr(this.elem.style, p, this.options.orig[p]);
381 // Execute the complete function
382 this.options.complete.call( this.elem );
386 var n = t - this.startTime;
387 this.state = n / this.options.duration;
389 // Perform the easing function, defaults to swing
390 this.pos = jQuery.easing[this.options.easing || (jQuery.easing.swing ? "swing" : "linear")](this.state, n, 0, 1, this.options.duration);
391 this.now = this.start + ((this.end - this.start) * this.pos);
393 // Perform the next step of the animation
402 jQuery.extend( jQuery.fx, {
410 scrollLeft: function(fx){
411 fx.elem.scrollLeft = fx.now;
414 scrollTop: function(fx){
415 fx.elem.scrollTop = fx.now;
418 opacity: function(fx){
419 jQuery.attr(fx.elem.style, "opacity", fx.now);
422 _default: function(fx){
423 ( fx.elem.style && ( fx.elem.style[ fx.prop ] = fx.now + fx.unit ) ) || ( fx.elem[ fx.prop ] = fx.now );