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
18
Ext.form.TextArea = Ext.extend(Ext.form.TextField, {
20
* @cfg {Number} growMin The minimum height to allow when grow = true (defaults to 60)
24
* @cfg {Number} growMax The maximum height to allow when grow = true (defaults to 1000)
27
growAppend : ' \n ',
30
enterIsSpecial : false,
33
* @cfg {Boolean} preventScrollbars True to prevent scrollbars from appearing regardless of how much text is
34
* in the field (equivalent to setting overflow: hidden, defaults to false)
36
preventScrollbars: false,
38
* @cfg {String/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to
39
* {tag: "textarea", style: "width:100px;height:60px;", autocomplete: "off"})
43
onRender : function(ct, position){
45
this.defaultAutoCreate = {
47
style:"width:100px;height:60px;",
51
Ext.form.TextArea.superclass.onRender.call(this, ct, position);
53
this.textSizeEl = Ext.DomHelper.append(document.body, {
54
tag: "pre", cls: "x-form-grow-sizer"
56
if(this.preventScrollbars){
57
this.el.setStyle("overflow", "hidden");
59
this.el.setHeight(this.growMin);
63
onDestroy : function(){
65
Ext.removeNode(this.textSizeEl);
67
Ext.form.TextArea.superclass.onDestroy.call(this);
70
fireKey : function(e){
71
if(e.isSpecialKey() && (this.enterIsSpecial || (e.getKey() != e.ENTER || e.hasModifier()))){
72
this.fireEvent("specialkey", this, e);
77
onKeyUp : function(e){
78
if(!e.isNavKeyPress() || e.getKey() == e.ENTER){
81
Ext.form.TextArea.superclass.onKeyUp.call(this, e);
85
* Automatically grows the field to accomodate the height of the text up to the maximum field height allowed.
86
* This only takes effect if grow = true, and fires the {@link #autosize} event if the height changes.
88
autoSize : function(){
89
if(!this.grow || !this.textSizeEl){
94
var ts = this.textSizeEl;
96
ts.appendChild(document.createTextNode(v));
99
Ext.fly(ts).setWidth(this.el.getWidth());
104
v = v.replace(/\n/g, '<p> </p>');
106
v += this.growAppend;
109
var h = Math.min(this.growMax, Math.max(ts.offsetHeight, this.growMin)+this.growPad);
110
if(h != this.lastHeight){
112
this.el.setHeight(h);
113
this.fireEvent("autosize", this, h);
117
Ext.reg('textarea', Ext.form.TextArea);
b'\\ No newline at end of file'