⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 textarea.js

📁 EXT2.0的中文API源代码
💻 JS
字号:
/** * @class Ext.form.TextArea * @extends Ext.form.TextField * 多行文本域。可以直接用于替代textarea,支持自动调整大小。 * @constructor * 创建一个新的TextArea对象 * @param {Object} config 配置选项 *//** * @class Ext.form.TextArea * @extends Ext.form.TextField * Multiline text field.  Can be used as a direct replacement for traditional textarea fields, plus adds * support for auto-sizing. * @constructor * Creates a new TextArea * @param {Object} config Configuration options */Ext.form.TextArea = function(config){    Ext.form.TextArea.superclass.constructor.call(this, config);    // these are provided exchanges for backwards compat    // minHeight/maxHeight were replaced by growMin/growMax to be    // compatible with TextField growing config values    if(this.minHeight !== undefined){        this.growMin = this.minHeight;    }    if(this.maxHeight !== undefined){        this.growMax = this.maxHeight;    }};Ext.extend(Ext.form.TextArea, Ext.form.TextField,  {    /**     * @cfg {Number} growMin 当grow = true时允许的高度下限(默认为60)     */    /**     * @cfg {Number} growMin The minimum height to allow when grow = true (defaults to 60)     */    growMin : 60,    /**     * @cfg {Number} growMax 当grow = true时允许的高度上限(默认为1000)     */    /**     * @cfg {Number} growMax The maximum height to allow when grow = true (defaults to 1000)     */    growMax: 1000,    growAppend : '&#160;\n&#160;',    growPad : 0,    enterIsSpecial : false,    /**     * @cfg {Boolean} preventScrollbars 为True时在为本域中将禁止滑动条,不论域中文本的数量(相当于设置overflow为hidden,默认值为false)     */    /**     * @cfg {Boolean} preventScrollbars True to prevent scrollbars from appearing regardless of how much text is     * in the field (equivalent to setting overflow: hidden, defaults to false)     */    preventScrollbars: false,    /**     * @cfg {String/Object} autoCreate 一个DomHelper创建元素的对象,或者为true,表示采用默认的方式创建元素。(默认为     * {tag: "textarea", style: "width:300px;height:60px;", autocomplete: "off"})     */    /**     * @cfg {String/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to     * {tag: "textarea", style: "width:100px;height:60px;", autocomplete: "off"})     */    // private    onRender : function(ct, position){        if(!this.el){            this.defaultAutoCreate = {                tag: "textarea",                style:"width:100px;height:60px;",                autocomplete: "off"            };        }        Ext.form.TextArea.superclass.onRender.call(this, ct, position);        if(this.grow){            this.textSizeEl = Ext.DomHelper.append(document.body, {                tag: "pre", cls: "x-form-grow-sizer"            });            if(this.preventScrollbars){                this.el.setStyle("overflow", "hidden");            }            this.el.setHeight(this.growMin);        }    },    onDestroy : function(){        if(this.textSizeEl){            this.textSizeEl.parentNode.removeChild(this.textSizeEl);        }        Ext.form.TextArea.superclass.onDestroy.call(this);    },    fireKey : function(e){        if(e.isSpecialKey() && (this.enterIsSpecial || (e.getKey() != e.ENTER || e.hasModifier()))){            this.fireEvent("specialkey", this, e);        }    },    // private    onKeyUp : function(e){        if(!e.isNavKeyPress() || e.getKey() == e.ENTER){            this.autoSize();        }    },    /**	 * 自动适应文本行数,直到所设置的最大行数。	 * 仅当grow = true时触发自适应高度事件。     */    /**     * Automatically grows the field to accomodate the height of the text up to the maximum field height allowed.     * This only takes effect if grow = true, and fires the autosize event if the height changes.     */    autoSize : function(){        if(!this.grow || !this.textSizeEl){            return;        }        var el = this.el;        var v = el.dom.value;        var ts = this.textSizeEl;        ts.innerHTML = '';        ts.appendChild(document.createTextNode(v));        v = ts.innerHTML;        Ext.fly(ts).setWidth(this.el.getWidth());        if(v.length < 1){            v = "&#160;&#160;";        }else{            if(Ext.isIE){                v = v.replace(/\n/g, '<p>&#160;</p>');            }            v += this.growAppend;        }        ts.innerHTML = v;        var h = Math.min(this.growMax, Math.max(ts.offsetHeight, this.growMin)+this.growPad);        if(h != this.lastHeight){            this.lastHeight = h;            this.el.setHeight(h);            this.fireEvent("autosize", this, h);        }    }});Ext.reg('textarea', Ext.form.TextArea);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -