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 )
149 stop: function(clearQueue, gotoEnd){
150 var timers = jQuery.timers;
155 this.each(function(){
156 // go in reverse order so anything added to the queue during the loop is ignored
157 for ( var i = timers.length - 1; i >= 0; i-- )
158 if ( timers[i].elem == this ) {
160 // force the next step to be the last
166 // start the next in the queue if the last step wasn't forced
175 var queue = function( elem, type, array ) {
181 var q = jQuery.data( elem, type + "queue" );
184 q = jQuery.data( elem, type + "queue",
185 array ? jQuery.makeArray(array) : [] );
190 jQuery.fn.dequeue = function(type){
193 return this.each(function(){
194 var q = queue(this, type);
205 speed: function(speed, easing, fn) {
206 var opt = speed && speed.constructor == Object ? speed : {
207 complete: fn || !fn && easing ||
208 jQuery.isFunction( speed ) && speed,
210 easing: fn && easing || easing && easing.constructor != Function && easing
213 opt.duration = (opt.duration && opt.duration.constructor == Number ?
215 { slow: 600, fast: 200 }[opt.duration]) || 400;
218 opt.old = opt.complete;
219 opt.complete = function(){
220 if ( opt.queue !== false )
221 jQuery(this).dequeue();
222 if ( jQuery.isFunction( opt.old ) )
223 opt.old.apply( this );
230 linear: function( p, n, firstNum, diff ) {
231 return firstNum + diff * p;
233 swing: function( p, n, firstNum, diff ) {
234 return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
241 fx: function( elem, options, prop ){
242 this.options = options;
252 jQuery.fx.prototype = {
254 // Simple function for setting a style value
256 if ( this.options.step )
257 this.options.step.apply( this.elem, [ this.now, this ] );
259 (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
261 // Set display property to block for height/width animations
262 if ( this.prop == "height" || this.prop == "width" )
263 this.elem.style.display = "block";
266 // Get the current size
267 cur: function(force){
268 if ( this.elem[this.prop] != null && this.elem.style[this.prop] == null )
269 return this.elem[ this.prop ];
271 var r = parseFloat(jQuery.css(this.elem, this.prop, force));
272 return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0;
275 // Start an animation from one number to another
276 custom: function(from, to, unit){
277 this.startTime = (new Date()).getTime();
280 this.unit = unit || this.unit || "px";
281 this.now = this.start;
282 this.pos = this.state = 0;
287 return self.step(gotoEnd);
292 jQuery.timers.push(t);
294 if ( jQuery.timerId == null ) {
295 jQuery.timerId = setInterval(function(){
296 var timers = jQuery.timers;
298 for ( var i = 0; i < timers.length; i++ )
300 timers.splice(i--, 1);
302 if ( !timers.length ) {
303 clearInterval( jQuery.timerId );
304 jQuery.timerId = null;
310 // Simple 'show' function
312 // Remember where we started, so that we can go back to it later
313 this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
314 this.options.show = true;
316 // Begin the animation
317 this.custom(0, this.cur());
319 // Make sure that we start at a small width/height to avoid any
321 if ( this.prop == "width" || this.prop == "height" )
322 this.elem.style[this.prop] = "1px";
324 // Start by showing the element
325 jQuery(this.elem).show();
328 // Simple 'hide' function
330 // Remember where we started, so that we can go back to it later
331 this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
332 this.options.hide = true;
334 // Begin the animation
335 this.custom(this.cur(), 0);
338 // Each step of an animation
339 step: function(gotoEnd){
340 var t = (new Date()).getTime();
342 if ( gotoEnd || t > this.options.duration + this.startTime ) {
344 this.pos = this.state = 1;
347 this.options.curAnim[ this.prop ] = true;
350 for ( var i in this.options.curAnim )
351 if ( this.options.curAnim[i] !== true )
355 if ( this.options.display != null ) {
356 // Reset the overflow
357 this.elem.style.overflow = this.options.overflow;
360 this.elem.style.display = this.options.display;
361 if ( jQuery.css(this.elem, "display") == "none" )
362 this.elem.style.display = "block";
365 // Hide the element if the "hide" operation was done
366 if ( this.options.hide )
367 this.elem.style.display = "none";
369 // Reset the properties, if the item has been hidden or shown
370 if ( this.options.hide || this.options.show )
371 for ( var p in this.options.curAnim )
372 jQuery.attr(this.elem.style, p, this.options.orig[p]);
375 // If a callback was provided, execute it
376 if ( done && jQuery.isFunction( this.options.complete ) )
377 // Execute the complete function
378 this.options.complete.apply( this.elem );
382 var n = t - this.startTime;
383 this.state = n / this.options.duration;
385 // Perform the easing function, defaults to swing
386 this.pos = jQuery.easing[this.options.easing || (jQuery.easing.swing ? "swing" : "linear")](this.state, n, 0, 1, this.options.duration);
387 this.now = this.start + ((this.end - this.start) * this.pos);
389 // Perform the next step of the animation
399 scrollLeft: function(fx){
400 fx.elem.scrollLeft = fx.now;
403 scrollTop: function(fx){
404 fx.elem.scrollTop = fx.now;
407 opacity: function(fx){
408 jQuery.attr(fx.elem.style, "opacity", fx.now);
411 _default: function(fx){
412 fx.elem.style[ fx.prop ] = fx.now + fx.unit;