Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / src / core / Element.legacy.js
diff --git a/src/core/Element.legacy.js b/src/core/Element.legacy.js
new file mode 100644 (file)
index 0000000..75883f5
--- /dev/null
@@ -0,0 +1,42 @@
+/*!
+ * Ext JS Library 3.0.0
+ * Copyright(c) 2006-2009 Ext JS, LLC
+ * licensing@extjs.com
+ * http://www.extjs.com/license
+ */
+/**\r
+ * @class Ext.Element\r
+ */\r
+Ext.Element.addMethods({\r
+    /**\r
+     * Measures the element's content height and updates height to match. Note: this function uses setTimeout so\r
+     * the new height may not be available immediately.\r
+     * @param {Boolean} animate (optional) Animate the transition (defaults to false)\r
+     * @param {Float} duration (optional) Length of the animation in seconds (defaults to .35)\r
+     * @param {Function} onComplete (optional) Function to call when animation completes\r
+     * @param {String} easing (optional) Easing method to use (defaults to easeOut)\r
+     * @return {Ext.Element} this\r
+     */\r
+    autoHeight : function(animate, duration, onComplete, easing){\r
+        var oldHeight = this.getHeight();\r
+        this.clip();\r
+        this.setHeight(1); // force clipping\r
+        setTimeout(function(){\r
+            var height = parseInt(this.dom.scrollHeight, 10); // parseInt for Safari\r
+            if(!animate){\r
+                this.setHeight(height);\r
+                this.unclip();\r
+                if(typeof onComplete == "function"){\r
+                    onComplete();\r
+                }\r
+            }else{\r
+                this.setHeight(oldHeight); // restore original height\r
+                this.setHeight(height, animate, duration, function(){\r
+                    this.unclip();\r
+                    if(typeof onComplete == "function") onComplete();\r
+                }.createDelegate(this), easing);\r
+            }\r
+        }.createDelegate(this), 0);\r
+        return this;\r
+    }\r
+});
\ No newline at end of file