X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/0494b8d9b9bb03ab6c22b34dae81261e3cd7e3e6..7a654f8d43fdb43d78b63d90528bed6e86b608cc:/src/layout/component/field/TextArea.js?ds=sidebyside
diff --git a/src/layout/component/field/TextArea.js b/src/layout/component/field/TextArea.js
new file mode 100644
index 00000000..49715f69
--- /dev/null
+++ b/src/layout/component/field/TextArea.js
@@ -0,0 +1,56 @@
+/**
+ * @private
+ * @class Ext.layout.component.field.TextArea
+ * @extends Ext.layout.component.field.Field
+ * Layout class for {@link Ext.form.field.TextArea} fields. Handles sizing the textarea field.
+ */
+Ext.define('Ext.layout.component.field.TextArea', {
+ extend: 'Ext.layout.component.field.Text',
+ alias: 'layout.textareafield',
+
+ type: 'textareafield',
+
+
+ /**
+ * Given the target bodyEl dimensions, adjust them if necessary to return the correct final
+ * size based on the text field's {@link Ext.form.field.Text#grow grow config}. Overrides the
+ * textfield layout's implementation to handle height rather than width.
+ * @param {Number} width The bodyEl width
+ * @param {Number} height The bodyEl height
+ * @return {Array} [inputElWidth, inputElHeight]
+ */
+ adjustForGrow: function(width, height) {
+ var me = this,
+ owner = me.owner,
+ inputEl, value, max,
+ curWidth, curHeight, calcHeight,
+ result = [width, height];
+
+ if (owner.grow) {
+ inputEl = owner.inputEl;
+ curWidth = inputEl.getWidth(true); //subtract border/padding to get the available width for the text
+ curHeight = inputEl.getHeight();
+
+ // Get and normalize the field value for measurement
+ value = inputEl.dom.value || ' ';
+ value += owner.growAppend;
+
+ // Translate newlines to
tags
+ value = value.replace(/\n/g, '
');
+
+ // Find the height that contains the whole text value
+ calcHeight = Ext.util.TextMetrics.measure(inputEl, value, curWidth).height +
+ inputEl.getBorderWidth("tb") + inputEl.getPadding("tb");
+
+ // Constrain
+ max = owner.growMax;
+ if (Ext.isNumber(height)) {
+ max = Math.min(max, height);
+ }
+ result[1] = Ext.Number.constrain(calcHeight, owner.growMin, max);
+ }
+
+ return result;
+ }
+
+});
\ No newline at end of file