4 show: function(speed,callback){
7 height: "show", width: "show", opacity: "show"
10 for ( var i = 0, l = this.length; i < l; i++ ){
11 var old = jQuery.data(this[i], "olddisplay");
13 this[i].style.display = old || "";
15 if ( jQuery.css(this[i], "display") === "none" ) {
16 var tagName = this[i].tagName, display;
18 if ( elemdisplay[ tagName ] ) {
19 display = elemdisplay[ tagName ];
21 var elem = jQuery("<" + tagName + " />").appendTo("body");
23 display = elem.css("display");
24 if ( display === "none" )
29 elemdisplay[ tagName ] = display;
32 this[i].style.display = jQuery.data(this[i], "olddisplay", display);
40 hide: function(speed,callback){
43 height: "hide", width: "hide", opacity: "hide"
46 for ( var i = 0, l = this.length; i < l; i++ ){
47 var old = jQuery.data(this[i], "olddisplay");
48 if ( !old && old !== "none" )
49 jQuery.data(this[i], "olddisplay", jQuery.css(this[i], "display"));
50 this[i].style.display = "none";
56 // Save the old toggle function
57 _toggle: jQuery.fn.toggle,
59 toggle: function( fn, fn2 ){
60 var bool = typeof fn === "boolean";
62 return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ?
63 this._toggle.apply( this, arguments ) :
66 var state = bool ? fn : jQuery(this).is(":hidden");
67 jQuery(this)[ state ? "show" : "hide" ]();
70 height: "toggle", width: "toggle", opacity: "toggle"
74 fadeTo: function(speed,to,callback){
75 return this.animate({opacity: to}, speed, callback);
78 animate: function( prop, speed, easing, callback ) {
79 var optall = jQuery.speed(speed, easing, callback);
81 return this[ optall.queue === false ? "each" : "queue" ](function(){
83 var opt = jQuery.extend({}, optall), p,
84 hidden = this.nodeType == 1 && jQuery(this).is(":hidden"),
88 if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden )
89 return opt.complete.call(this);
91 if ( ( p == "height" || p == "width" ) && this.style ) {
92 // Store display property
93 opt.display = jQuery.css(this, "display");
95 // Make sure that nothing sneaks out
96 opt.overflow = this.style.overflow;
100 if ( opt.overflow != null )
101 this.style.overflow = "hidden";
103 opt.curAnim = jQuery.extend({}, prop);
105 jQuery.each( prop, function(name, val){
106 var e = new jQuery.fx( self, opt, name );
108 if ( /toggle|show|hide/.test(val) )
109 e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop );
111 var parts = val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),
112 start = e.cur(true) || 0;
115 var end = parseFloat(parts[2]),
116 unit = parts[3] || "px";
118 // We need to compute starting value
119 if ( unit != "px" ) {
120 self.style[ name ] = (end || 1) + unit;
121 start = ((end || 1) / e.cur(true)) * start;
122 self.style[ name ] = start + unit;
125 // If a +=/-= token was provided, we're doing a relative animation
127 end = ((parts[1] == "-=" ? -1 : 1) * end) + start;
129 e.custom( start, end, unit );
131 e.custom( start, val, "" );
135 // For JS strict compliance
140 stop: function(clearQueue, gotoEnd){
141 var timers = jQuery.timers;
146 this.each(function(){
147 // go in reverse order so anything added to the queue during the loop is ignored
148 for ( var i = timers.length - 1; i >= 0; i-- )
149 if ( timers[i].elem == this ) {
151 // force the next step to be the last
157 // start the next in the queue if the last step wasn't forced
166 // Generate shortcuts for custom animations
168 slideDown: { height:"show" },
169 slideUp: { height: "hide" },
170 slideToggle: { height: "toggle" },
171 fadeIn: { opacity: "show" },
172 fadeOut: { opacity: "hide" }
173 }, function( name, props ){
174 jQuery.fn[ name ] = function( speed, callback ){
175 return this.animate( props, speed, callback );
181 speed: function(speed, easing, fn) {
182 var opt = typeof speed === "object" ? speed : {
183 complete: fn || !fn && easing ||
184 jQuery.isFunction( speed ) && speed,
186 easing: fn && easing || easing && !jQuery.isFunction(easing) && easing
189 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
190 jQuery.fx.speeds[opt.duration] || jQuery.fx.speeds._default;
193 opt.old = opt.complete;
194 opt.complete = function(){
195 if ( opt.queue !== false )
196 jQuery(this).dequeue();
197 if ( jQuery.isFunction( opt.old ) )
198 opt.old.call( this );
205 linear: function( p, n, firstNum, diff ) {
206 return firstNum + diff * p;
208 swing: function( p, n, firstNum, diff ) {
209 return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
216 fx: function( elem, options, prop ){
217 this.options = options;
227 jQuery.fx.prototype = {
229 // Simple function for setting a style value
231 if ( this.options.step )
232 this.options.step.call( this.elem, this.now, this );
234 (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
236 // Set display property to block for height/width animations
237 if ( ( this.prop == "height" || this.prop == "width" ) && this.elem.style )
238 this.elem.style.display = "block";
241 // Get the current size
242 cur: function(force){
243 if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) )
244 return this.elem[ this.prop ];
246 var r = parseFloat(jQuery.css(this.elem, this.prop, force));
247 return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0;
250 // Start an animation from one number to another
251 custom: function(from, to, unit){
252 this.startTime = now();
255 this.unit = unit || this.unit || "px";
256 this.now = this.start;
257 this.pos = this.state = 0;
261 return self.step(gotoEnd);
266 jQuery.timers.push(t);
268 if ( t() && jQuery.timerId == null ) {
269 jQuery.timerId = setInterval(function(){
270 var timers = jQuery.timers;
272 for ( var i = 0; i < timers.length; i++ )
274 timers.splice(i--, 1);
276 if ( !timers.length ) {
277 clearInterval( jQuery.timerId );
278 jQuery.timerId = null;
284 // Simple 'show' function
286 // Remember where we started, so that we can go back to it later
287 this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
288 this.options.show = true;
290 // Begin the animation
291 // Make sure that we start at a small width/height to avoid any
293 this.custom(this.prop == "width" || this.prop == "height" ? 1 : 0, this.cur());
295 // Start by showing the element
296 jQuery(this.elem).show();
299 // Simple 'hide' function
301 // Remember where we started, so that we can go back to it later
302 this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
303 this.options.hide = true;
305 // Begin the animation
306 this.custom(this.cur(), 0);
309 // Each step of an animation
310 step: function(gotoEnd){
313 if ( gotoEnd || t >= this.options.duration + this.startTime ) {
315 this.pos = this.state = 1;
318 this.options.curAnim[ this.prop ] = true;
321 for ( var i in this.options.curAnim )
322 if ( this.options.curAnim[i] !== true )
326 if ( this.options.display != null ) {
327 // Reset the overflow
328 this.elem.style.overflow = this.options.overflow;
331 this.elem.style.display = this.options.display;
332 if ( jQuery.css(this.elem, "display") == "none" )
333 this.elem.style.display = "block";
336 // Hide the element if the "hide" operation was done
337 if ( this.options.hide )
338 jQuery(this.elem).hide();
340 // Reset the properties, if the item has been hidden or shown
341 if ( this.options.hide || this.options.show )
342 for ( var p in this.options.curAnim )
343 jQuery.attr(this.elem.style, p, this.options.orig[p]);
347 // Execute the complete function
348 this.options.complete.call( this.elem );
352 var n = t - this.startTime;
353 this.state = n / this.options.duration;
355 // Perform the easing function, defaults to swing
356 this.pos = jQuery.easing[this.options.easing || (jQuery.easing.swing ? "swing" : "linear")](this.state, n, 0, 1, this.options.duration);
357 this.now = this.start + ((this.end - this.start) * this.pos);
359 // Perform the next step of the animation
368 jQuery.extend( jQuery.fx, {
377 opacity: function(fx){
378 jQuery.attr(fx.elem.style, "opacity", fx.now);
381 _default: function(fx){
382 if ( fx.elem.style && fx.elem.style[ fx.prop ] != null )
383 fx.elem.style[ fx.prop ] = fx.now + fx.unit;
385 fx.elem[ fx.prop ] = fx.now;