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