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