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-Text'>/**
20 * @class Ext.layout.component.field.Text
21 * @extends Ext.layout.component.field.Field
22 * Layout class for {@link Ext.form.field.Text} fields. Handles sizing the input field.
24 Ext.define('Ext.layout.component.field.Text', {
25 extend: 'Ext.layout.component.field.Field',
26 alias: 'layout.textfield',
27 requires: ['Ext.util.TextMetrics'],
32 <span id='Ext-layout-component-field-Text-method-beforeLayout'> /**
33 </span> * Allow layout to proceed if the {@link Ext.form.field.Text#grow} config is enabled and the value has
34 * changed since the last layout.
36 beforeLayout: function(width, height) {
39 lastValue = this.lastValue,
40 value = owner.getRawValue();
41 this.lastValue = value;
42 return me.callParent(arguments) || (owner.grow && value !== lastValue);
46 <span id='Ext-layout-component-field-Text-method-sizeBodyContents'> /**
47 </span> * Size the field body contents given the total dimensions of the bodyEl, taking into account the optional
48 * {@link Ext.form.field.Text#grow} configurations.
49 * @param {Number} width The bodyEl width
50 * @param {Number} height The bodyEl height
52 sizeBodyContents: function(width, height) {
53 var size = this.adjustForGrow(width, height);
54 this.setElementSize(this.owner.inputEl, size[0], size[1]);
58 <span id='Ext-layout-component-field-Text-method-adjustForGrow'> /**
59 </span> * Given the target bodyEl dimensions, adjust them if necessary to return the correct final
60 * size based on the text field's {@link Ext.form.field.Text#grow grow config}.
61 * @param {Number} width The bodyEl width
62 * @param {Number} height The bodyEl height
63 * @return {Number[]} [inputElWidth, inputElHeight]
65 adjustForGrow: function(width, height) {
68 inputEl, value, calcWidth,
69 result = [width, height];
72 inputEl = owner.inputEl;
74 // Find the width that contains the whole text value
75 value = (inputEl.dom.value || (owner.hasFocus ? '' : owner.emptyText) || '') + owner.growAppend;
76 calcWidth = inputEl.getTextWidth(value) + inputEl.getBorderWidth("lr") + inputEl.getPadding("lr");
79 result[0] = Ext.Number.constrain(calcWidth, owner.growMin,
80 Math.max(owner.growMin, Math.min(owner.growMax, Ext.isNumber(width) ? width : Infinity)));