Upgrade to ExtJS 4.0.7 - Released 10/19/2011
[extjs.git] / docs / source / TextArea2.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5   <title>The source code</title>
6   <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
7   <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8   <style type="text/css">
9     .highlight { display: block; background-color: #ddd; }
10   </style>
11   <script type="text/javascript">
12     function highlight() {
13       document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
14     }
15   </script>
16 </head>
17 <body onload="prettyPrint(); highlight();">
18   <pre class="prettyprint lang-js"><span id='Ext-layout-component-field-TextArea'>/**
19 </span> * @private
20  * @class Ext.layout.component.field.TextArea
21  * @extends Ext.layout.component.field.Field
22  * Layout class for {@link Ext.form.field.TextArea} fields. Handles sizing the textarea field.
23  */
24 Ext.define('Ext.layout.component.field.TextArea', {
25     extend: 'Ext.layout.component.field.Text',
26     alias: 'layout.textareafield',
27
28     type: 'textareafield',
29
30
31 <span id='Ext-layout-component-field-TextArea-method-adjustForGrow'>    /**
32 </span>     * Given the target bodyEl dimensions, adjust them if necessary to return the correct final
33      * size based on the text field's {@link Ext.form.field.Text#grow grow config}. Overrides the
34      * textfield layout's implementation to handle height rather than width.
35      * @param {Number} width The bodyEl width
36      * @param {Number} height The bodyEl height
37      * @return {Number[]} [inputElWidth, inputElHeight]
38      */
39     adjustForGrow: function(width, height) {
40         var me = this,
41             owner = me.owner,
42             inputEl, value, max,
43             curWidth, curHeight, calcHeight,
44             result = [width, height];
45
46         if (owner.grow) {
47             inputEl = owner.inputEl;
48             curWidth = inputEl.getWidth(true); //subtract border/padding to get the available width for the text
49             curHeight = inputEl.getHeight();
50
51             // Get and normalize the field value for measurement
52             value = inputEl.dom.value || '&amp;#160;';
53             value += owner.growAppend;
54
55             // Translate newlines to &lt;br&gt; tags
56             value = value.replace(/\n/g, '&lt;br&gt;');
57
58             // Find the height that contains the whole text value
59             calcHeight = Ext.util.TextMetrics.measure(inputEl, value, curWidth).height +
60                          inputEl.getBorderWidth(&quot;tb&quot;) + inputEl.getPadding(&quot;tb&quot;);
61
62             // Constrain
63             max = owner.growMax;
64             if (Ext.isNumber(height)) {
65                 max = Math.min(max, height);
66             }
67             result[1] = Ext.Number.constrain(calcHeight, owner.growMin, max);
68         }
69
70         return result;
71     }
72
73 });</pre>
74 </body>
75 </html>