2 show: function(speed,callback){
5 height: "show", width: "show", opacity: "show"
8 this.filter(":hidden").each(function(){
9 this.style.display = this.oldblock ? this.oldblock : "";
10 if ( jQuery.css(this,"display") == "none" )
11 this.style.display = "block";
15 hide: function(speed,callback){
18 height: "hide", width: "hide", opacity: "hide"
21 this.filter(":visible").each(function(){
22 this.oldblock = this.oldblock || jQuery.css(this,"display");
23 if ( this.oldblock == "none" )
24 this.oldblock = "block";
25 this.style.display = "none";
29 // Save the old toggle function
30 _toggle: jQuery.fn.toggle,
32 toggle: function( fn, fn2 ){
33 return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ?
34 this._toggle( fn, fn2 ) :
37 height: "toggle", width: "toggle", opacity: "toggle"
40 jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ]();
44 slideDown: function(speed,callback){
45 return this.animate({height: "show"}, speed, callback);
48 slideUp: function(speed,callback){
49 return this.animate({height: "hide"}, speed, callback);
52 slideToggle: function(speed, callback){
53 return this.animate({height: "toggle"}, speed, callback);
56 fadeIn: function(speed, callback){
57 return this.animate({opacity: "show"}, speed, callback);
60 fadeOut: function(speed, callback){
61 return this.animate({opacity: "hide"}, speed, callback);
64 fadeTo: function(speed,to,callback){
65 return this.animate({opacity: to}, speed, callback);
68 animate: function( prop, speed, easing, callback ) {
69 var optall = jQuery.speed(speed, easing, callback);
71 return this[ optall.queue === false ? "each" : "queue" ](function(){
72 var opt = jQuery.extend({}, optall);
73 var hidden = jQuery(this).is(":hidden"), self = this;
75 for ( var p in prop ) {
76 if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden )
77 return jQuery.isFunction(opt.complete) && opt.complete.apply(this);
79 if ( p == "height" || p == "width" ) {
80 // Store display property
81 opt.display = jQuery.css(this, "display");
83 // Make sure that nothing sneaks out
84 opt.overflow = this.style.overflow;
88 if ( opt.overflow != null )
89 this.style.overflow = "hidden";
91 opt.curAnim = jQuery.extend({}, prop);
93 jQuery.each( prop, function(name, val){
94 var e = new jQuery.fx( self, opt, name );
96 if ( /toggle|show|hide/.test(val) )
97 e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop );
99 var parts = val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),
100 start = e.cur(true) || 0;
103 var end = parseFloat(parts[2]),
104 unit = parts[3] || "px";
106 // We need to compute starting value
107 if ( unit != "px" ) {
108 self.style[ name ] = (end || 1) + unit;
109 start = ((end || 1) / e.cur(true)) * start;
110 self.style[ name ] = start + unit;
113 // If a +=/-= token was provided, we're doing a relative animation
115 end = ((parts[1] == "-=" ? -1 : 1) * end) + start;
117 e.custom( start, end, unit );
119 e.custom( start, val, "" );
123 // For JS strict compliance
128 queue: function(type, fn){
129 if ( jQuery.isFunction(type) || ( type && type.constructor == Array )) {
134 if ( !type || (typeof type == "string" && !fn) )
135 return queue( this[0], type );
137 return this.each(function(){
138 if ( fn.constructor == Array )
139 queue(this, type, fn);
141 queue(this, type).push( fn );
143 if ( queue(this, type).length == 1 )
150 var timers = jQuery.timers;
152 return this.each(function(){
153 for ( var i = 0; i < timers.length; i++ )
154 if ( timers[i].elem == this )
155 timers.splice(i--, 1);
161 var queue = function( elem, type, array ) {
167 var q = jQuery.data( elem, type + "queue" );
170 q = jQuery.data( elem, type + "queue",
171 array ? jQuery.makeArray(array) : [] );
176 jQuery.fn.dequeue = function(type){
179 return this.each(function(){
180 var q = queue(this, type);
191 speed: function(speed, easing, fn) {
192 var opt = speed && speed.constructor == Object ? speed : {
193 complete: fn || !fn && easing ||
194 jQuery.isFunction( speed ) && speed,
196 easing: fn && easing || easing && easing.constructor != Function && easing
199 opt.duration = (opt.duration && opt.duration.constructor == Number ?
201 { slow: 600, fast: 200 }[opt.duration]) || 400;
204 opt.old = opt.complete;
205 opt.complete = function(){
206 if ( opt.queue !== false )
207 jQuery(this).dequeue();
208 if ( jQuery.isFunction( opt.old ) )
209 opt.old.apply( this );
216 linear: function( p, n, firstNum, diff ) {
217 return firstNum + diff * p;
219 swing: function( p, n, firstNum, diff ) {
220 return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
227 fx: function( elem, options, prop ){
228 this.options = options;
238 jQuery.fx.prototype = {
240 // Simple function for setting a style value
242 if ( this.options.step )
243 this.options.step.apply( this.elem, [ this.now, this ] );
245 (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
247 // Set display property to block for height/width animations
248 if ( this.prop == "height" || this.prop == "width" )
249 this.elem.style.display = "block";
252 // Get the current size
253 cur: function(force){
254 if ( this.elem[this.prop] != null && this.elem.style[this.prop] == null )
255 return this.elem[ this.prop ];
257 var r = parseFloat(jQuery.css(this.elem, this.prop, force));
258 return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0;
261 // Start an animation from one number to another
262 custom: function(from, to, unit){
263 this.startTime = (new Date()).getTime();
266 this.unit = unit || this.unit || "px";
267 this.now = this.start;
268 this.pos = this.state = 0;
278 jQuery.timers.push(t);
280 if ( jQuery.timerId == null ) {
281 jQuery.timerId = setInterval(function(){
282 var timers = jQuery.timers;
284 for ( var i = 0; i < timers.length; i++ )
286 timers.splice(i--, 1);
288 if ( !timers.length ) {
289 clearInterval( jQuery.timerId );
290 jQuery.timerId = null;
296 // Simple 'show' function
298 // Remember where we started, so that we can go back to it later
299 this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
300 this.options.show = true;
302 // Begin the animation
303 this.custom(0, this.cur());
305 // Make sure that we start at a small width/height to avoid any
307 if ( this.prop == "width" || this.prop == "height" )
308 this.elem.style[this.prop] = "1px";
310 // Start by showing the element
311 jQuery(this.elem).show();
314 // Simple 'hide' 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.hide = true;
320 // Begin the animation
321 this.custom(this.cur(), 0);
324 // Each step of an animation
326 var t = (new Date()).getTime();
328 if ( t > this.options.duration + this.startTime ) {
330 this.pos = this.state = 1;
333 this.options.curAnim[ this.prop ] = true;
336 for ( var i in this.options.curAnim )
337 if ( this.options.curAnim[i] !== true )
341 if ( this.options.display != null ) {
342 // Reset the overflow
343 this.elem.style.overflow = this.options.overflow;
346 this.elem.style.display = this.options.display;
347 if ( jQuery.css(this.elem, "display") == "none" )
348 this.elem.style.display = "block";
351 // Hide the element if the "hide" operation was done
352 if ( this.options.hide )
353 this.elem.style.display = "none";
355 // Reset the properties, if the item has been hidden or shown
356 if ( this.options.hide || this.options.show )
357 for ( var p in this.options.curAnim )
358 jQuery.attr(this.elem.style, p, this.options.orig[p]);
361 // If a callback was provided, execute it
362 if ( done && jQuery.isFunction( this.options.complete ) )
363 // Execute the complete function
364 this.options.complete.apply( this.elem );
368 var n = t - this.startTime;
369 this.state = n / this.options.duration;
371 // Perform the easing function, defaults to swing
372 this.pos = jQuery.easing[this.options.easing || (jQuery.easing.swing ? "swing" : "linear")](this.state, n, 0, 1, this.options.duration);
373 this.now = this.start + ((this.end - this.start) * this.pos);
375 // Perform the next step of the animation
385 scrollLeft: function(fx){
386 fx.elem.scrollLeft = fx.now;
389 scrollTop: function(fx){
390 fx.elem.scrollTop = fx.now;
393 opacity: function(fx){
394 jQuery.attr(fx.elem.style, "opacity", fx.now);
397 _default: function(fx){
398 fx.elem.style[ fx.prop ] = fx.now + fx.unit;