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");
18 hide: function(speed,callback){
21 height: "hide", width: "hide", opacity: "hide"
24 this.filter(":visible").each(function(){
25 this.oldblock = this.oldblock || jQuery.css(this,"display");
26 this.style.display = "none";
30 // Save the old toggle function
31 _toggle: jQuery.fn.toggle,
33 toggle: function( fn, fn2 ){
34 return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ?
35 this._toggle( fn, fn2 ) :
38 height: "toggle", width: "toggle", opacity: "toggle"
41 jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ]();
45 slideDown: function(speed,callback){
46 return this.animate({height: "show"}, speed, callback);
49 slideUp: function(speed,callback){
50 return this.animate({height: "hide"}, speed, callback);
53 slideToggle: function(speed, callback){
54 return this.animate({height: "toggle"}, speed, callback);
57 fadeIn: function(speed, callback){
58 return this.animate({opacity: "show"}, speed, callback);
61 fadeOut: function(speed, callback){
62 return this.animate({opacity: "hide"}, speed, callback);
65 fadeTo: function(speed,to,callback){
66 return this.animate({opacity: to}, speed, callback);
69 animate: function( prop, speed, easing, callback ) {
70 var optall = jQuery.speed(speed, easing, callback);
72 return this[ optall.queue === false ? "each" : "queue" ](function(){
73 if ( this.nodeType != 1)
76 var opt = jQuery.extend({}, optall);
77 var hidden = jQuery(this).is(":hidden"), self = this;
79 for ( var p in prop ) {
80 if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden )
81 return jQuery.isFunction(opt.complete) && opt.complete.apply(this);
83 if ( p == "height" || p == "width" ) {
84 // Store display property
85 opt.display = jQuery.css(this, "display");
87 // Make sure that nothing sneaks out
88 opt.overflow = this.style.overflow;
92 if ( opt.overflow != null )
93 this.style.overflow = "hidden";
95 opt.curAnim = jQuery.extend({}, prop);
97 jQuery.each( prop, function(name, val){
98 var e = new jQuery.fx( self, opt, name );
100 if ( /toggle|show|hide/.test(val) )
101 e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop );
103 var parts = val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),
104 start = e.cur(true) || 0;
107 var end = parseFloat(parts[2]),
108 unit = parts[3] || "px";
110 // We need to compute starting value
111 if ( unit != "px" ) {
112 self.style[ name ] = (end || 1) + unit;
113 start = ((end || 1) / e.cur(true)) * start;
114 self.style[ name ] = start + unit;
117 // If a +=/-= token was provided, we're doing a relative animation
119 end = ((parts[1] == "-=" ? -1 : 1) * end) + start;
121 e.custom( start, end, unit );
123 e.custom( start, val, "" );
127 // For JS strict compliance
132 queue: function(type, fn){
133 if ( jQuery.isFunction(type) || ( type && type.constructor == Array )) {
138 if ( !type || (typeof type == "string" && !fn) )
139 return queue( this[0], type );
141 return this.each(function(){
142 if ( this.nodeType != 1)
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 ) {
188 var q = jQuery.data( elem, type + "queue" );
191 q = jQuery.data( elem, type + "queue",
192 array ? jQuery.makeArray(array) : [] );
197 jQuery.fn.dequeue = function(type){
200 return this.each(function(){
201 var q = queue(this, type);
212 speed: function(speed, easing, fn) {
213 var opt = speed && speed.constructor == Object ? speed : {
214 complete: fn || !fn && easing ||
215 jQuery.isFunction( speed ) && speed,
217 easing: fn && easing || easing && easing.constructor != Function && easing
220 opt.duration = (opt.duration && opt.duration.constructor == Number ?
222 { slow: 600, fast: 200 }[opt.duration]) || 400;
225 opt.old = opt.complete;
226 opt.complete = function(){
227 if ( opt.queue !== false )
228 jQuery(this).dequeue();
229 if ( jQuery.isFunction( opt.old ) )
230 opt.old.apply( this );
237 linear: function( p, n, firstNum, diff ) {
238 return firstNum + diff * p;
240 swing: function( p, n, firstNum, diff ) {
241 return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
248 fx: function( elem, options, prop ){
249 this.options = options;
259 jQuery.fx.prototype = {
261 // Simple function for setting a style value
263 if ( this.options.step )
264 this.options.step.apply( this.elem, [ this.now, this ] );
266 (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
268 // Set display property to block for height/width animations
269 if ( this.prop == "height" || this.prop == "width" )
270 this.elem.style.display = "block";
273 // Get the current size
274 cur: function(force){
275 if ( this.elem[this.prop] != null && this.elem.style[this.prop] == null )
276 return this.elem[ this.prop ];
278 var r = parseFloat(jQuery.css(this.elem, this.prop, force));
279 return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0;
282 // Start an animation from one number to another
283 custom: function(from, to, unit){
284 this.startTime = (new Date()).getTime();
287 this.unit = unit || this.unit || "px";
288 this.now = this.start;
289 this.pos = this.state = 0;
294 return self.step(gotoEnd);
299 jQuery.timers.push(t);
301 if ( jQuery.timerId == null ) {
302 jQuery.timerId = setInterval(function(){
303 var timers = jQuery.timers;
305 for ( var i = 0; i < timers.length; i++ )
307 timers.splice(i--, 1);
309 if ( !timers.length ) {
310 clearInterval( jQuery.timerId );
311 jQuery.timerId = null;
317 // Simple 'show' function
319 // Remember where we started, so that we can go back to it later
320 this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
321 this.options.show = true;
323 // Begin the animation
324 this.custom(0, this.cur());
326 // Make sure that we start at a small width/height to avoid any
328 if ( this.prop == "width" || this.prop == "height" )
329 this.elem.style[this.prop] = "1px";
331 // Start by showing the element
332 jQuery(this.elem).show();
335 // Simple 'hide' function
337 // Remember where we started, so that we can go back to it later
338 this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
339 this.options.hide = true;
341 // Begin the animation
342 this.custom(this.cur(), 0);
345 // Each step of an animation
346 step: function(gotoEnd){
347 var t = (new Date()).getTime();
349 if ( gotoEnd || t > this.options.duration + this.startTime ) {
351 this.pos = this.state = 1;
354 this.options.curAnim[ this.prop ] = true;
357 for ( var i in this.options.curAnim )
358 if ( this.options.curAnim[i] !== true )
362 if ( this.options.display != null ) {
363 // Reset the overflow
364 this.elem.style.overflow = this.options.overflow;
367 this.elem.style.display = this.options.display;
368 if ( jQuery.css(this.elem, "display") == "none" )
369 this.elem.style.display = "block";
372 // Hide the element if the "hide" operation was done
373 if ( this.options.hide )
374 this.elem.style.display = "none";
376 // Reset the properties, if the item has been hidden or shown
377 if ( this.options.hide || this.options.show )
378 for ( var p in this.options.curAnim )
379 jQuery.attr(this.elem.style, p, this.options.orig[p]);
382 // If a callback was provided, execute it
383 if ( done && jQuery.isFunction( this.options.complete ) )
384 // Execute the complete function
385 this.options.complete.apply( this.elem );
389 var n = t - this.startTime;
390 this.state = n / this.options.duration;
392 // Perform the easing function, defaults to swing
393 this.pos = jQuery.easing[this.options.easing || (jQuery.easing.swing ? "swing" : "linear")](this.state, n, 0, 1, this.options.duration);
394 this.now = this.start + ((this.end - this.start) * this.pos);
396 // Perform the next step of the animation
406 scrollLeft: function(fx){
407 fx.elem.scrollLeft = fx.now;
410 scrollTop: function(fx){
411 fx.elem.scrollTop = fx.now;
414 opacity: function(fx){
415 jQuery.attr(fx.elem.style, "opacity", fx.now);
418 _default: function(fx){
419 fx.elem.style[ fx.prop ] = fx.now + fx.unit;