3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.2.0
11 * Copyright(c) 2006-2010 Ext JS, Inc.
13 * http://www.extjs.com/license
15 <div id="cls-Ext.form.TextArea"></div>/**
16 * @class Ext.form.TextArea
17 * @extends Ext.form.TextField
18 * Multiline text field. Can be used as a direct replacement for traditional textarea fields, plus adds
19 * support for auto-sizing.
21 * Creates a new TextArea
22 * @param {Object} config Configuration options
25 Ext.form.TextArea = Ext.extend(Ext.form.TextField, {
26 <div id="cfg-Ext.form.TextArea-growMin"></div>/**
27 * @cfg {Number} growMin The minimum height to allow when <tt>{@link Ext.form.TextField#grow grow}=true</tt>
28 * (defaults to <tt>60</tt>)
31 <div id="cfg-Ext.form.TextArea-growMax"></div>/**
32 * @cfg {Number} growMax The maximum height to allow when <tt>{@link Ext.form.TextField#grow grow}=true</tt>
33 * (defaults to <tt>1000</tt>)
36 growAppend : ' \n ',
38 enterIsSpecial : false,
40 <div id="cfg-Ext.form.TextArea-preventScrollbars"></div>/**
41 * @cfg {Boolean} preventScrollbars <tt>true</tt> to prevent scrollbars from appearing regardless of how much text is
42 * in the field. This option is only relevant when {@link #grow} is <tt>true</tt>. Equivalent to setting overflow: hidden, defaults to
45 preventScrollbars: false,
46 <div id="cfg-Ext.form.TextArea-autoCreate"></div>/**
47 * @cfg {String/Object} autoCreate <p>A {@link Ext.DomHelper DomHelper} element spec, or true for a default
48 * element spec. Used to create the {@link Ext.Component#getEl Element} which will encapsulate this Component.
49 * See <tt>{@link Ext.Component#autoEl autoEl}</tt> for details. Defaults to:</p>
50 * <pre><code>{tag: "textarea", style: "width:100px;height:60px;", autocomplete: "off"}</code></pre>
54 onRender : function(ct, position){
56 this.defaultAutoCreate = {
58 style:"width:100px;height:60px;",
62 Ext.form.TextArea.superclass.onRender.call(this, ct, position);
64 this.textSizeEl = Ext.DomHelper.append(document.body, {
65 tag: "pre", cls: "x-form-grow-sizer"
67 if(this.preventScrollbars){
68 this.el.setStyle("overflow", "hidden");
70 this.el.setHeight(this.growMin);
74 onDestroy : function(){
75 Ext.removeNode(this.textSizeEl);
76 Ext.form.TextArea.superclass.onDestroy.call(this);
79 fireKey : function(e){
80 if(e.isSpecialKey() && (this.enterIsSpecial || (e.getKey() != e.ENTER || e.hasModifier()))){
81 this.fireEvent("specialkey", this, e);
86 doAutoSize : function(e){
87 return !e.isNavKeyPress() || e.getKey() == e.ENTER;
90 <div id="method-Ext.form.TextArea-autoSize"></div>/**
91 * Automatically grows the field to accomodate the height of the text up to the maximum field height allowed.
92 * This only takes effect if grow = true, and fires the {@link #autosize} event if the height changes.
95 if(!this.grow || !this.textSizeEl){
99 v = Ext.util.Format.htmlEncode(el.dom.value),
100 ts = this.textSizeEl,
103 Ext.fly(ts).setWidth(this.el.getWidth());
107 v += this.growAppend;
109 v = v.replace(/\n/g, ' <br />');
113 h = Math.min(this.growMax, Math.max(ts.offsetHeight, this.growMin));
114 if(h != this.lastHeight){
116 this.el.setHeight(h);
117 this.fireEvent("autosize", this, h);
121 Ext.reg('textarea', Ext.form.TextArea);</pre>