3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js"><div id="cls-Ext.form.TextArea"></div>/**
9 * @class Ext.form.TextArea
10 * @extends Ext.form.TextField
11 * Multiline text field. Can be used as a direct replacement for traditional textarea fields, plus adds
12 * support for auto-sizing.
14 * Creates a new TextArea
15 * @param {Object} config Configuration options
18 Ext.form.TextArea = Ext.extend(Ext.form.TextField, {
19 <div id="cfg-Ext.form.TextArea-growMin"></div>/**
20 * @cfg {Number} growMin The minimum height to allow when <tt>{@link Ext.form.TextField#grow grow}=true</tt>
21 * (defaults to <tt>60</tt>)
24 <div id="cfg-Ext.form.TextArea-growMax"></div>/**
25 * @cfg {Number} growMax The maximum height to allow when <tt>{@link Ext.form.TextField#grow grow}=true</tt>
26 * (defaults to <tt>1000</tt>)
29 growAppend : ' \n ',
30 growPad : Ext.isWebKit ? -6 : 0,
32 enterIsSpecial : false,
34 <div id="cfg-Ext.form.TextArea-preventScrollbars"></div>/**
35 * @cfg {Boolean} preventScrollbars <tt>true</tt> to prevent scrollbars from appearing regardless of how much text is
36 * in the field (equivalent to setting overflow: hidden, defaults to <tt>false</tt>)
38 preventScrollbars: false,
39 <div id="cfg-Ext.form.TextArea-autoCreate"></div>/**
40 * @cfg {String/Object} autoCreate <p>A {@link Ext.DomHelper DomHelper} element spec, or true for a default
41 * element spec. Used to create the {@link Ext.Component#getEl Element} which will encapsulate this Component.
42 * See <tt>{@link Ext.Component#autoEl autoEl}</tt> for details. Defaults to:</p>
43 * <pre><code>{tag: "textarea", style: "width:100px;height:60px;", autocomplete: "off"}</code></pre>
47 onRender : function(ct, position){
49 this.defaultAutoCreate = {
51 style:"width:100px;height:60px;",
55 Ext.form.TextArea.superclass.onRender.call(this, ct, position);
57 this.textSizeEl = Ext.DomHelper.append(document.body, {
58 tag: "pre", cls: "x-form-grow-sizer"
60 if(this.preventScrollbars){
61 this.el.setStyle("overflow", "hidden");
63 this.el.setHeight(this.growMin);
67 onDestroy : function(){
68 Ext.destroy(this.textSizeEl);
69 Ext.form.TextArea.superclass.onDestroy.call(this);
72 fireKey : function(e){
73 if(e.isSpecialKey() && (this.enterIsSpecial || (e.getKey() != e.ENTER || e.hasModifier()))){
74 this.fireEvent("specialkey", this, e);
79 onKeyUp : function(e){
80 if(!e.isNavKeyPress() || e.getKey() == e.ENTER){
83 Ext.form.TextArea.superclass.onKeyUp.call(this, e);
86 <div id="method-Ext.form.TextArea-autoSize"></div>/**
87 * Automatically grows the field to accomodate the height of the text up to the maximum field height allowed.
88 * This only takes effect if grow = true, and fires the {@link #autosize} event if the height changes.
91 if(!this.grow || !this.textSizeEl){
96 var ts = this.textSizeEl;
98 ts.appendChild(document.createTextNode(v));
100 Ext.fly(ts).setWidth(this.el.getWidth());
104 v += this.growAppend;
106 v = v.replace(/\n/g, '<br />');
110 var h = Math.min(this.growMax, Math.max(ts.offsetHeight, this.growMin) + this.growPad);
111 if(h != this.lastHeight){
113 this.el.setHeight(h);
114 this.fireEvent("autosize", this, h);
118 Ext.reg('textarea', Ext.form.TextArea);</pre>
\r