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