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

📄 form-debug.js

📁 最强的js界面,超前卫的显示方式 把AJAX运用得淋漓尽致。
💻 JS
📖 第 1 页 / 共 5 页
字号:
            }        }        return value;    },    filterValidation : function(e){        if(!e.isNavKeyPress()){            this.validationTask.delay(this.validationDelay);        }    },        onKeyUp : function(e){        if(!e.isNavKeyPress()){            this.autoSize();        }    },        reset : function(){        Ext.form.TextField.superclass.reset.call(this);        this.applyEmptyText();    },    applyEmptyText : function(){        if(this.rendered && this.emptyText && this.getRawValue().length < 1){            this.setRawValue(this.emptyText);            this.el.addClass(this.emptyClass);        }    },        preFocus : function(){        if(this.emptyText){            if(this.el.dom.value == this.emptyText){                this.setRawValue('');            }            this.el.removeClass(this.emptyClass);        }        if(this.selectOnFocus){            this.el.dom.select();        }    },        postBlur : function(){        this.applyEmptyText();    },        filterKeys : function(e){        var k = e.getKey();        if(!Ext.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){            return;        }        var c = e.getCharCode(), cc = String.fromCharCode(c);        if(Ext.isIE && (e.isSpecialKey() || !cc)){            return;        }        if(!this.maskRe.test(cc)){            e.stopEvent();        }    },    setValue : function(v){        if(this.emptyText && this.el && v !== undefined && v !== null && v !== ''){            this.el.removeClass(this.emptyClass);        }        Ext.form.TextField.superclass.setValue.apply(this, arguments);        this.applyEmptyText();        this.autoSize();    },        validateValue : function(value){        if(value.length < 1 || value === this.emptyText){              if(this.allowBlank){                 this.clearInvalid();                 return true;             }else{                 this.markInvalid(this.blankText);                 return false;             }        }        if(value.length < this.minLength){            this.markInvalid(String.format(this.minLengthText, this.minLength));            return false;        }        if(value.length > this.maxLength){            this.markInvalid(String.format(this.maxLengthText, this.maxLength));            return false;        }        if(this.vtype){            var vt = Ext.form.VTypes;            if(!vt[this.vtype](value, this)){                this.markInvalid(this.vtypeText || vt[this.vtype +'Text']);                return false;            }        }        if(typeof this.validator == "function"){            var msg = this.validator(value);            if(msg !== true){                this.markInvalid(msg);                return false;            }        }        if(this.regex && !this.regex.test(value)){            this.markInvalid(this.regexText);            return false;        }        return true;    },        selectText : function(start, end){        var v = this.getRawValue();        if(v.length > 0){            start = start === undefined ? 0 : start;            end = end === undefined ? v.length : end;            var d = this.el.dom;            if(d.setSelectionRange){                d.setSelectionRange(start, end);            }else if(d.createTextRange){                var range = d.createTextRange();                range.moveStart("character", start);                range.moveEnd("character", end-v.length);                range.select();            }        }    },        autoSize : function(){        if(!this.grow || !this.rendered){            return;        }        if(!this.metrics){            this.metrics = Ext.util.TextMetrics.createInstance(this.el);        }        var el = this.el;        var v = el.dom.value;        var d = document.createElement('div');        d.appendChild(document.createTextNode(v));        v = d.innerHTML;        d = null;        v += "&#160;";        var w = Math.min(this.growMax, Math.max(this.metrics.getWidth(v) +  10, this.growMin));        this.el.setWidth(w);        this.fireEvent("autosize", this, w);    }});Ext.reg('textfield', Ext.form.TextField);Ext.form.TriggerField = Ext.extend(Ext.form.TextField,  {            defaultAutoCreate : {tag: "input", type: "text", size: "16", autocomplete: "off"},        hideTrigger:false,        autoSize: Ext.emptyFn,        monitorTab : true,        deferHeight : true,        mimicing : false,        onResize : function(w, h){        Ext.form.TriggerField.superclass.onResize.call(this, w, h);        if(typeof w == 'number'){            this.el.setWidth(this.adjustWidth('input', w - this.trigger.getWidth()));        }        this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());    },        adjustSize : Ext.BoxComponent.prototype.adjustSize,        getResizeEl : function(){        return this.wrap;    },        getPositionEl : function(){        return this.wrap;    },        alignErrorIcon : function(){        this.errorIcon.alignTo(this.wrap, 'tl-tr', [2, 0]);    },        onRender : function(ct, position){        Ext.form.TriggerField.superclass.onRender.call(this, ct, position);        this.wrap = this.el.wrap({cls: "x-form-field-wrap"});        this.trigger = this.wrap.createChild(this.triggerConfig ||                {tag: "img", src: Ext.BLANK_IMAGE_URL, cls: "x-form-trigger " + this.triggerClass});        if(this.hideTrigger){            this.trigger.setDisplayed(false);        }        this.initTrigger();        if(!this.width){            this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());        }    },        initTrigger : function(){        this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});        this.trigger.addClassOnOver('x-form-trigger-over');        this.trigger.addClassOnClick('x-form-trigger-click');    },        onDestroy : function(){        if(this.trigger){            this.trigger.removeAllListeners();            this.trigger.remove();        }        if(this.wrap){            this.wrap.remove();        }        Ext.form.TriggerField.superclass.onDestroy.call(this);    },        onFocus : function(){        Ext.form.TriggerField.superclass.onFocus.call(this);        if(!this.mimicing){            this.wrap.addClass('x-trigger-wrap-focus');            this.mimicing = true;            Ext.get(Ext.isIE ? document.body : document).on("mousedown", this.mimicBlur, this, {delay: 10});            if(this.monitorTab){                this.el.on("keydown", this.checkTab, this);            }        }    },        checkTab : function(e){        if(e.getKey() == e.TAB){            this.triggerBlur();        }    },        onBlur : function(){            },        mimicBlur : function(e){        if(!this.wrap.contains(e.target) && this.validateBlur(e)){            this.triggerBlur();        }    },        triggerBlur : function(){        this.mimicing = false;        Ext.get(Ext.isIE ? document.body : document).un("mousedown", this.mimicBlur);        if(this.monitorTab){            this.el.un("keydown", this.checkTab, this);        }        this.beforeBlur();        this.wrap.removeClass('x-trigger-wrap-focus');        Ext.form.TriggerField.superclass.onBlur.call(this);    },    beforeBlur : Ext.emptyFn,             validateBlur : function(e){        return true;    },        onDisable : function(){        Ext.form.TriggerField.superclass.onDisable.call(this);        if(this.wrap){            this.wrap.addClass('x-item-disabled');        }    },        onEnable : function(){        Ext.form.TriggerField.superclass.onEnable.call(this);        if(this.wrap){            this.wrap.removeClass('x-item-disabled');        }    },        onShow : function(){        if(this.wrap){            this.wrap.dom.style.display = '';            this.wrap.dom.style.visibility = 'visible';        }    },        onHide : function(){        this.wrap.dom.style.display = 'none';    },        onTriggerClick : Ext.emptyFn            });Ext.form.TwinTriggerField = Ext.extend(Ext.form.TriggerField, {    initComponent : function(){        Ext.form.TwinTriggerField.superclass.initComponent.call(this);        this.triggerConfig = {            tag:'span', cls:'x-form-twin-triggers', cn:[            {tag: "img", src: Ext.BLANK_IMAGE_URL, cls: "x-form-trigger " + this.trigger1Class},            {tag: "img", src: Ext.BLANK_IMAGE_URL, cls: "x-form-trigger " + this.trigger2Class}        ]};    },    getTrigger : function(index){        return this.triggers[index];    },    initTrigger : function(){        var ts = this.trigger.select('.x-form-trigger', true);        this.wrap.setStyle('overflow', 'hidden');        var triggerField = this;        ts.each(function(t, all, index){            t.hide = function(){                var w = triggerField.wrap.getWidth();                this.dom.style.display = 'none';                triggerField.el.setWidth(w-triggerField.trigger.getWidth());            };            t.show = function(){                var w = triggerField.wrap.getWidth();                this.dom.style.display = '';                triggerField.el.setWidth(w-triggerField.trigger.getWidth());            };            var triggerIndex = 'Trigger'+(index+1);            if(this['hide'+triggerIndex]){                t.dom.style.display = 'none';            }            t.on("click", this['on'+triggerIndex+'Click'], this, {preventDefault:true});            t.addClassOnOver('x-form-trigger-over');            t.addClassOnClick('x-form-trigger-click');        }, this);        this.triggers = ts.elements;    },    onTrigger1Click : Ext.emptyFn,    onTrigger2Click : Ext.emptyFn});Ext.reg('trigger', Ext.form.TriggerField);Ext.form.TextArea = Ext.extend(Ext.form.TextField,  {        growMin : 60,        growMax: 1000,    growAppend : '&#160;\n&#160;',    growPad : 0,    enterIsSpecial : false,        preventScrollbars: false,            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){            Ext.removeNode(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);        }    },        onKeyUp : function(e){        if(!e.isNavKeyPress() || e.getKey() == e.ENTER){            this.autoSize();        }    },        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);Ext.form.NumberField = Ext.extend(Ext.form.TextField,  {        fieldClass: "x-form-field x-form-num-field",        allowDecimals : true,        decimalSeparator : ".",        decimalPrecision : 2,        allowNegative : true,        minValue : Number.NEGATIVE_INFINITY,        maxValue : Number.MAX_VALUE,        minText : "The minimum value for this field is {0}",        maxText : "The maximum value for this field is {0}",        nanText : "{0} is not a valid number",        baseChars : "0123456789",        initEvents : function(){        Ext.form.NumberField.superclass.initEvents.call(this);        var allowed = this.baseChars+'';        if(this.allowDecimals){            allowed += this.decimalSeparator;        }        if(this.allowNegative){            allowed += "-";        }        this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');        var keyPress = function(e){            var k = e.getKey();            if(!Ext.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){                return;            }            var c = e.getCharCode();            if(allowed.indexOf(String.fromCharCode(c)) === -1){                e.stopEvent();            }        };        this.el.on("keypress", keyPress, this);    },        validateValue : function(value){        if(!Ext.form.NumberField.superclass.validateValue.call(this, value)){            return false;        }

⌨️ 快捷键说明

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