+++ /dev/null
-/*\r
- * Ext JS Library 2.2.1\r
- * Copyright(c) 2006-2009, Ext JS, LLC.\r
- * licensing@extjs.com\r
- * \r
- * http://extjs.com/license\r
- */\r
-\r
-/**\r
- * @class Ext.form.TextArea\r
- * @extends Ext.form.TextField\r
- * Multiline text field. Can be used as a direct replacement for traditional textarea fields, plus adds\r
- * support for auto-sizing.\r
- * @constructor\r
- * Creates a new TextArea\r
- * @param {Object} config Configuration options\r
- */\r
-Ext.form.TextArea = Ext.extend(Ext.form.TextField, {\r
- /**\r
- * @cfg {Number} growMin The minimum height to allow when grow = true (defaults to 60)\r
- */\r
- growMin : 60,\r
- /**\r
- * @cfg {Number} growMax The maximum height to allow when grow = true (defaults to 1000)\r
- */\r
- growMax: 1000,\r
- growAppend : ' \n ',\r
- growPad : 0,\r
-\r
- enterIsSpecial : false,\r
-\r
- /**\r
- * @cfg {Boolean} preventScrollbars True to prevent scrollbars from appearing regardless of how much text is\r
- * in the field (equivalent to setting overflow: hidden, defaults to false)\r
- */\r
- preventScrollbars: false,\r
- /**\r
- * @cfg {String/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to\r
- * {tag: "textarea", style: "width:100px;height:60px;", autocomplete: "off"})\r
- */\r
-\r
- // private\r
- onRender : function(ct, position){\r
- if(!this.el){\r
- this.defaultAutoCreate = {\r
- tag: "textarea",\r
- style:"width:100px;height:60px;",\r
- autocomplete: "off"\r
- };\r
- }\r
- Ext.form.TextArea.superclass.onRender.call(this, ct, position);\r
- if(this.grow){\r
- this.textSizeEl = Ext.DomHelper.append(document.body, {\r
- tag: "pre", cls: "x-form-grow-sizer"\r
- });\r
- if(this.preventScrollbars){\r
- this.el.setStyle("overflow", "hidden");\r
- }\r
- this.el.setHeight(this.growMin);\r
- }\r
- },\r
-\r
- onDestroy : function(){\r
- if(this.textSizeEl){\r
- Ext.removeNode(this.textSizeEl);\r
- }\r
- Ext.form.TextArea.superclass.onDestroy.call(this);\r
- },\r
-\r
- fireKey : function(e){\r
- if(e.isSpecialKey() && (this.enterIsSpecial || (e.getKey() != e.ENTER || e.hasModifier()))){\r
- this.fireEvent("specialkey", this, e);\r
- }\r
- },\r
-\r
- // private\r
- onKeyUp : function(e){\r
- if(!e.isNavKeyPress() || e.getKey() == e.ENTER){\r
- this.autoSize();\r
- }\r
- Ext.form.TextArea.superclass.onKeyUp.call(this, e);\r
- },\r
-\r
- /**\r
- * Automatically grows the field to accomodate the height of the text up to the maximum field height allowed.\r
- * This only takes effect if grow = true, and fires the {@link #autosize} event if the height changes.\r
- */\r
- autoSize : function(){\r
- if(!this.grow || !this.textSizeEl){\r
- return;\r
- }\r
- var el = this.el;\r
- var v = el.dom.value;\r
- var ts = this.textSizeEl;\r
- ts.innerHTML = '';\r
- ts.appendChild(document.createTextNode(v));\r
- v = ts.innerHTML;\r
-\r
- Ext.fly(ts).setWidth(this.el.getWidth());\r
- if(v.length < 1){\r
- v = "  ";\r
- }else{\r
- if(Ext.isIE){\r
- v = v.replace(/\n/g, '<p> </p>');\r
- }\r
- v += this.growAppend;\r
- }\r
- ts.innerHTML = v;\r
- var h = Math.min(this.growMax, Math.max(ts.offsetHeight, this.growMin)+this.growPad);\r
- if(h != this.lastHeight){\r
- this.lastHeight = h;\r
- this.el.setHeight(h);\r
- this.fireEvent("autosize", this, h);\r
- }\r
- }\r
-});\r
-Ext.reg('textarea', Ext.form.TextArea);
\ No newline at end of file