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; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-layout-component-field-TextArea'>/**
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.
24 Ext.define('Ext.layout.component.field.TextArea', {
25 extend: 'Ext.layout.component.field.Text',
26 alias: 'layout.textareafield',
28 type: 'textareafield',
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]
39 adjustForGrow: function(width, height) {
43 curWidth, curHeight, calcHeight,
44 result = [width, height];
47 inputEl = owner.inputEl;
48 curWidth = inputEl.getWidth(true); //subtract border/padding to get the available width for the text
49 curHeight = inputEl.getHeight();
51 // Get and normalize the field value for measurement
52 value = inputEl.dom.value || '&#160;';
53 value += owner.growAppend;
55 // Translate newlines to <br> tags
56 value = value.replace(/\n/g, '<br>');
58 // Find the height that contains the whole text value
59 calcHeight = Ext.util.TextMetrics.measure(inputEl, value, curWidth).height +
60 inputEl.getBorderWidth("tb") + inputEl.getPadding("tb");
64 if (Ext.isNumber(height)) {
65 max = Math.min(max, height);
67 result[1] = Ext.Number.constrain(calcHeight, owner.growMin, max);