2
* Ext JS Library 3.0 RC2
3
* Copyright(c) 2006-2009, Ext JS, LLC.
6
* http://extjs.com/license
10
* @class Ext.form.TextArea
11
* @extends Ext.form.TextField
12
* Multiline text field. Can be used as a direct replacement for traditional textarea fields, plus adds
13
* support for auto-sizing.
15
* Creates a new TextArea
16
* @param {Object} config Configuration options
19
Ext.form.TextArea = Ext.extend(Ext.form.TextField, {
21
* @cfg {Number} growMin The minimum height to allow when <tt>{@link Ext.form.TextField#grow grow}=true</tt>
22
* (defaults to <tt>60</tt>)
26
* @cfg {Number} growMax The maximum height to allow when <tt>{@link Ext.form.TextField#grow grow}=true</tt>
27
* (defaults to <tt>1000</tt>)
30
growAppend : ' \n ',
31
growPad : Ext.isWebKit ? -6 : 0,
33
enterIsSpecial : false,
36
* @cfg {Boolean} preventScrollbars <tt>true</tt> to prevent scrollbars from appearing regardless of how much text is
37
* in the field (equivalent to setting overflow: hidden, defaults to <tt>false</tt>)
39
preventScrollbars: false,
41
* @cfg {String/Object} autoCreate <p>A {@link Ext.DomHelper DomHelper} element spec, or true for a default
42
* element spec. Used to create the {@link Ext.Component#getEl Element} which will encapsulate this Component.
43
* See <tt>{@link Ext.Component#autoEl autoEl}</tt> for details. Defaults to:</p>
44
* <pre><code>{tag: "textarea", style: "width:100px;height:60px;", autocomplete: "off"}</code></pre>
48
onRender : function(ct, position){
50
this.defaultAutoCreate = {
52
style:"width:100px;height:60px;",
56
Ext.form.TextArea.superclass.onRender.call(this, ct, position);
58
this.textSizeEl = Ext.DomHelper.append(document.body, {
59
tag: "pre", cls: "x-form-grow-sizer"
61
if(this.preventScrollbars){
62
this.el.setStyle("overflow", "hidden");
64
this.el.setHeight(this.growMin);
68
onDestroy : function(){
69
Ext.destroy(this.textSizeEl);
70
Ext.form.TextArea.superclass.onDestroy.call(this);
73
fireKey : function(e){
74
if(e.isSpecialKey() && (this.enterIsSpecial || (e.getKey() != e.ENTER || e.hasModifier()))){
75
this.fireEvent("specialkey", this, e);
80
onKeyUp : function(e){
81
if(!e.isNavKeyPress() || e.getKey() == e.ENTER){
84
Ext.form.TextArea.superclass.onKeyUp.call(this, e);
88
* Automatically grows the field to accomodate the height of the text up to the maximum field height allowed.
89
* This only takes effect if grow = true, and fires the {@link #autosize} event if the height changes.
92
if(!this.grow || !this.textSizeEl){
97
var ts = this.textSizeEl;
99
ts.appendChild(document.createTextNode(v));
101
Ext.fly(ts).setWidth(this.el.getWidth());
105
v += this.growAppend;
107
v = v.replace(/\n/g, '<br />');
111
var h = Math.min(this.growMax, Math.max(ts.offsetHeight, this.growMin) + this.growPad);
112
if(h != this.lastHeight){
114
this.el.setHeight(h);
115
this.fireEvent("autosize", this, h);
119
Ext.reg('textarea', Ext.form.TextArea);
b'\\ No newline at end of file'