animate: function(prop,speed,callback) {\r
return this.queue(function(){\r
\r
- this.curAnim = prop;\r
+ this.curAnim = jQuery.extend({}, prop);\r
\r
for ( var p in prop ) {\r
var e = new jQuery.fx( this, jQuery.speed(speed,callback), p );\r
});\r
\r
jQuery.extend({\r
-\r
- setAuto: function(e,p) {\r
- if ( e.notAuto ) return;\r
-\r
- if ( p == "height" && e.scrollHeight != parseInt(jQuery.curCSS(e,p)) ) return;\r
- if ( p == "width" && e.scrollWidth != parseInt(jQuery.curCSS(e,p)) ) return;\r
-\r
- // Remember the original height\r
- var a = e.style[p];\r
-\r
- // Figure out the size of the height right now\r
- var o = jQuery.curCSS(e,p,1);\r
-\r
- if ( p == "height" && e.scrollHeight != o ||\r
- p == "width" && e.scrollWidth != o ) return;\r
-\r
- // Set the height to auto\r
- e.style[p] = e.currentStyle ? "" : "auto";\r
-\r
- // See what the size of "auto" is\r
- var n = jQuery.curCSS(e,p,1);\r
-\r
- // Revert back to the original size\r
- if ( o != n && n != "auto" ) {\r
- e.style[p] = a;\r
- e.notAuto = true;\r
- }\r
- },\r
\r
speed: function(s,o) {\r
o = o || {};\r
*/\r
\r
fx: function( elem, options, prop ){\r
- \r
+\r
var z = this;\r
- \r
+\r
// The users options\r
z.o = {\r
duration: options.duration || 400,\r
complete: options.complete,\r
step: options.step\r
};\r
- \r
+\r
// The element\r
z.el = elem;\r
- \r
+\r
// The styles\r
var y = z.el.style;\r
- \r
+ \r
+ // Store display property\r
+ var oldDisplay = jQuery.css(z.el, 'display');\r
+ // Set display property to block for animation\r
+ y.display = "block";\r
+ // Make sure that nothing sneaks out\r
+ y.overflow = "hidden";\r
+\r
// Simple function for setting a style value\r
z.a = function(){\r
if ( options.step )\r
options.step.apply( elem, [ z.now ] );\r
\r
- if ( prop == "opacity" ) {\r
- if (jQuery.browser.mozilla && z.now == 1) z.now = 0.9999;\r
- if (window.ActiveXObject)\r
- y.filter = "alpha(opacity=" + z.now*100 + ")";\r
- else\r
- y.opacity = z.now;\r
-\r
- // My hate for IE will never die\r
- } else if ( parseInt(z.now) )\r
+ if ( prop == "opacity" )\r
+ jQuery.attr(y, "opacity", z.now); // Let attr handle opacity\r
+ else if ( parseInt(z.now) ) // My hate for IE will never die\r
y[prop] = parseInt(z.now) + "px";\r
- \r
- y.display = "block";\r
};\r
- \r
+\r
// Figure out the maximum number to run to\r
z.max = function(){\r
return parseFloat( jQuery.css(z.el,prop) );\r
};\r
- \r
+\r
// Get the current size\r
z.cur = function(){\r
var r = parseFloat( jQuery.curCSS(z.el, prop) );\r
return r && r > -10000 ? r : z.max();\r
};\r
- \r
+\r
// Start an animation from one number to another\r
z.custom = function(from,to){\r
z.startTime = (new Date()).getTime();\r
z.now = from;\r
z.a();\r
- \r
+\r
z.timer = setInterval(function(){\r
z.step(from, to);\r
}, 13);\r
};\r
- \r
+\r
// Simple 'show' function\r
- z.show = function( p ){\r
+ z.show = function(){\r
if ( !z.el.orig ) z.el.orig = {};\r
\r
// Remember where we started, so that we can go back to it later\r
z.el.orig[prop] = this.cur();\r
\r
- z.custom( 0, z.el.orig[prop] );\r
+ z.o.show = true;\r
+\r
+ // Begin the animation\r
+ z.custom(0, z.el.orig[prop]);\r
\r
// Stupid IE, look what you made me do\r
if ( prop != "opacity" )\r
y[prop] = "1px";\r
};\r
- \r
+\r
// Simple 'hide' function\r
z.hide = function(){\r
if ( !z.el.orig ) z.el.orig = {};\r
// Begin the animation\r
z.custom(z.el.orig[prop], 0);\r
};\r
- \r
- // IE has trouble with opacity if it does not have layout\r
- if ( jQuery.browser.msie && !z.el.currentStyle.hasLayout )\r
- y.zoom = "1";\r
- \r
- // Remember the overflow of the element\r
- if ( !z.el.oldOverlay )\r
- z.el.oldOverflow = jQuery.css( z.el, "overflow" );\r
- \r
- // Make sure that nothing sneaks out\r
- y.overflow = "hidden";\r
- \r
+ \r
+ //Simple 'toggle' function\r
+ z.toggle = function() {\r
+ if ( !z.el.orig ) z.el.orig = {};\r
+\r
+ // Remember where we started, so that we can go back to it later\r
+ z.el.orig[prop] = this.cur();\r
+\r
+ if(oldDisplay == 'none') {\r
+ z.o.show = true;\r
+ \r
+ // Stupid IE, look what you made me do\r
+ if ( prop != "opacity" )\r
+ y[prop] = "1px";\r
+\r
+ // Begin the animation\r
+ z.custom(0, z.el.orig[prop]); \r
+ } else {\r
+ z.o.hide = true;\r
+\r
+ // Begin the animation\r
+ z.custom(z.el.orig[prop], 0);\r
+ } \r
+ };\r
+\r
// Each step of an animation\r
z.step = function(firstNum, lastNum){\r
var t = (new Date()).getTime();\r
- \r
+\r
if (t > z.o.duration + z.startTime) {\r
// Stop the timer\r
clearInterval(z.timer);\r
z.now = lastNum;\r
z.a();\r
\r
- z.el.curAnim[ prop ] = true;\r
- \r
+ if (z.el.curAnim) z.el.curAnim[ prop ] = true;\r
+\r
var done = true;\r
for ( var i in z.el.curAnim )\r
if ( z.el.curAnim[i] !== true )\r
done = false;\r
- \r
+\r
if ( done ) {\r
// Reset the overflow\r
- y.overflow = z.el.oldOverflow;\r
- \r
+ y.overflow = '';\r
+ \r
+ // Reset the display\r
+ y.display = oldDisplay;\r
+ if (jQuery.css(z.el, 'display') == 'none')\r
+ y.display = 'block';\r
+\r
// Hide the element if the "hide" operation was done\r
if ( z.o.hide ) \r
y.display = 'none';\r
- \r
- // Reset the property, if the item has been hidden\r
- if ( z.o.hide ) {\r
- for ( var p in z.el.curAnim ) {\r
- y[ p ] = z.el.orig[p] + ( p == "opacity" ? "" : "px" );\r
- \r
- // set its height and/or width to auto\r
- if ( p == 'height' || p == 'width' )\r
- jQuery.setAuto( z.el, p );\r
- }\r
- }\r
+\r
+ // Reset the properties, if the item has been hidden or shown\r
+ if ( z.o.hide || z.o.show )\r
+ for ( var p in z.el.curAnim )\r
+ if (p == "opacity")\r
+ jQuery.attr(y, p, z.el.orig[p]);\r
+ else\r
+ y[p] = '';\r
}\r
\r
// If a callback was provided, execute it\r
// Figure out where in the animation we are and set the number\r
var p = (t - this.startTime) / z.o.duration;\r
z.now = ((-Math.cos(p*Math.PI)/2) + 0.5) * (lastNum-firstNum) + firstNum;\r
- \r
+\r
// Perform the next step of the animation\r
z.a();\r
}\r