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