Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / docs / source / Element.legacy.html
1 <html>\r
2 <head>\r
3   <title>The source code</title>\r
4     <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
5     <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
6 </head>\r
7 <body  onload="prettyPrint();">\r
8     <pre class="prettyprint lang-js">/**\r
9  * @class Ext.Element\r
10  */\r
11 Ext.Element.addMethods({\r
12     <div id="method-Ext.Element-autoHeight"></div>/**\r
13      * Measures the element's content height and updates height to match. Note: this function uses setTimeout so\r
14      * the new height may not be available immediately.\r
15      * @param {Boolean} animate (optional) Animate the transition (defaults to false)\r
16      * @param {Float} duration (optional) Length of the animation in seconds (defaults to .35)\r
17      * @param {Function} onComplete (optional) Function to call when animation completes\r
18      * @param {String} easing (optional) Easing method to use (defaults to easeOut)\r
19      * @return {Ext.Element} this\r
20      */\r
21     autoHeight : function(animate, duration, onComplete, easing){\r
22         var oldHeight = this.getHeight();\r
23         this.clip();\r
24         this.setHeight(1); // force clipping\r
25         setTimeout(function(){\r
26             var height = parseInt(this.dom.scrollHeight, 10); // parseInt for Safari\r
27             if(!animate){\r
28                 this.setHeight(height);\r
29                 this.unclip();\r
30                 if(typeof onComplete == "function"){\r
31                     onComplete();\r
32                 }\r
33             }else{\r
34                 this.setHeight(oldHeight); // restore original height\r
35                 this.setHeight(height, animate, duration, function(){\r
36                     this.unclip();\r
37                     if(typeof onComplete == "function") onComplete();\r
38                 }.createDelegate(this), easing);\r
39             }\r
40         }.createDelegate(this), 0);\r
41         return this;\r
42     }\r
43 });</pre>    \r
44 </body>\r
45 </html>