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 ( fn.constructor == Array )
143 queue(this, type, fn);
145 queue(this, type).push( fn );
147 if ( queue(this, type).length == 1 )
153 stop: function(clearQueue, gotoEnd){
154 var timers = jQuery.timers;
159 this.each(function(){
160 // go in reverse order so anything added to the queue during the loop is ignored
161 for ( var i = timers.length - 1; i >= 0; i-- )
162 if ( timers[i].elem == this ) {
164 // force the next step to be the last
170 // start the next in the queue if the last step wasn't forced
179 var queue = function( elem, type, array ) {
185 var q = jQuery.data( elem, type + "queue" );
188 q = jQuery.data( elem, type + "queue",
189 array ? 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 { slow: 600, fast: 200 }[opt.duration]) || 400;
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.apply( 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.apply( 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.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 = (new Date()).getTime();
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){
344 var t = (new Date()).getTime();
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]);
379 // If a callback was provided, execute it
380 if ( done && jQuery.isFunction( this.options.complete ) )
381 // Execute the complete function
382 this.options.complete.apply( 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
403 scrollLeft: function(fx){
404 fx.elem.scrollLeft = fx.now;
407 scrollTop: function(fx){
408 fx.elem.scrollTop = fx.now;
411 opacity: function(fx){
412 jQuery.attr(fx.elem.style, "opacity", fx.now);
415 _default: function(fx){
416 fx.elem.style[ fx.prop ] = fx.now + fx.unit;