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>
7 <body onload="prettyPrint();">
8 <pre class="prettyprint lang-js">/*!
10 * Copyright(c) 2006-2009 Ext JS, LLC
12 * http://www.extjs.com/license
15 * @class Ext.Element
\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
27 autoHeight : function(animate, duration, onComplete, easing){
\r
28 var oldHeight = this.getHeight();
\r
30 this.setHeight(1); // force clipping
\r
31 setTimeout(function(){
\r
32 var height = parseInt(this.dom.scrollHeight, 10); // parseInt for Safari
\r
34 this.setHeight(height);
\r
36 if(typeof onComplete == "function"){
\r
40 this.setHeight(oldHeight); // restore original height
\r
41 this.setHeight(height, animate, duration, function(){
\r
43 if(typeof onComplete == "function") onComplete();
\r
44 }.createDelegate(this), easing);
\r
46 }.createDelegate(this), 0);
\r