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

📄 form-debug.js

📁 ext js demo ext学习资料
💻 JS
📖 第 1 页 / 共 5 页
字号:
        }        return true;    },    getValue : function(){        return this.fixPrecision(this.parseValue(Ext.form.NumberField.superclass.getValue.call(this)));    },        parseValue : function(value){        return parseFloat(String(value).replace(this.decimalSeparator, ".")) || '';    },        fixPrecision : function(value){        var nan = isNaN(value);        if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){           return nan ? '' : value;       }                                                 var scale = Math.pow(10, this.decimalPrecision+1);       var fixed = this.decimalPrecisionFcn(value * scale);       fixed = this.decimalPrecisionFcn(fixed/10);       return fixed / (scale/10);    },        decimalPrecisionFcn : function(v){        return Math.floor(v);    },    beforeBlur : function(){        var v = this.parseValue(this.getRawValue());        if(v){            this.setValue(this.fixPrecision(v));        }    }});Ext.form.DateField = function(config){    Ext.form.DateField.superclass.constructor.call(this, config);    if(typeof this.minValue == "string") this.minValue = this.parseDate(this.minValue);    if(typeof this.maxValue == "string") this.maxValue = this.parseDate(this.maxValue);    this.ddMatch = null;    if(this.disabledDates){        var dd = this.disabledDates;        var re = "(?:";        for(var i = 0; i < dd.length; i++){            re += dd[i];            if(i != dd.length-1) re += "|";        }        this.ddMatch = new RegExp(re + ")");    }};Ext.extend(Ext.form.DateField, Ext.form.TriggerField,  {        format : "m/d/y",        altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",        disabledDays : null,        disabledDaysText : "Disabled",        disabledDates : null,        disabledDatesText : "Disabled",        minValue : null,        maxValue : null,        minText : "The date in this field must be equal to or after {0}",        maxText : "The date in this field must be equal to or before {0}",        invalidText : "{0} is not a valid date - it must be in the format {1}",        triggerClass : 'x-form-date-trigger',            defaultAutoCreate : {tag: "input", type: "text", size: "10", autocomplete: "off"},        validateValue : function(value){        value = this.formatDate(value);        if(!Ext.form.DateField.superclass.validateValue.call(this, value)){            return false;        }        if(value.length < 1){              return true;        }        var svalue = value;        value = this.parseDate(value);        if(!value){            this.markInvalid(String.format(this.invalidText, svalue, this.format));            return false;        }        var time = value.getTime();        if(this.minValue && time < this.minValue.getTime()){            this.markInvalid(String.format(this.minText, this.formatDate(this.minValue)));            return false;        }        if(this.maxValue && time > this.maxValue.getTime()){            this.markInvalid(String.format(this.maxText, this.formatDate(this.maxValue)));            return false;        }        if(this.disabledDays){            var day = value.getDay();            for(var i = 0; i < this.disabledDays.length; i++) {            	if(day === this.disabledDays[i]){            	    this.markInvalid(this.disabledDaysText);                    return false;            	}            }        }        var fvalue = this.formatDate(value);        if(this.ddMatch && this.ddMatch.test(fvalue)){            this.markInvalid(String.format(this.disabledDatesText, fvalue));            return false;        }        return true;    },            validateBlur : function(){        return !this.menu || !this.menu.isVisible();    },        getValue : function(){        return this.parseDate(Ext.form.DateField.superclass.getValue.call(this)) || "";    },        setValue : function(date){        Ext.form.DateField.superclass.setValue.call(this, this.formatDate(this.parseDate(date)));    },        parseDate : function(value){        if(!value || value instanceof Date){            return value;        }        var v = Date.parseDate(value, this.format);        if(!v && this.altFormats){            if(!this.altFormatsArray){                this.altFormatsArray = this.altFormats.split("|");            }            for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){                v = Date.parseDate(value, this.altFormatsArray[i]);            }        }        return v;    },        formatDate : function(date){        return (!date || !(date instanceof Date)) ?               date : date.dateFormat(this.format);    },        menuListeners : {        select: function(m, d){            this.setValue(d);        },        show : function(){             this.onFocus();        },        hide : function(){            this.focus.defer(10, this);            var ml = this.menuListeners;            this.menu.un("select", ml.select,  this);            this.menu.un("show", ml.show,  this);            this.menu.un("hide", ml.hide,  this);        }    },            onTriggerClick : function(){        if(this.disabled){            return;        }        if(this.menu == null){            this.menu = new Ext.menu.DateMenu();        }        Ext.apply(this.menu.picker,  {            minDate : this.minValue,            maxDate : this.maxValue,            disabledDatesRE : this.ddMatch,            disabledDatesText : this.disabledDatesText,            disabledDays : this.disabledDays,            disabledDaysText : this.disabledDaysText,            format : this.format,            minText : String.format(this.minText, this.formatDate(this.minValue)),            maxText : String.format(this.maxText, this.formatDate(this.maxValue))        });        this.menu.on(Ext.apply({}, this.menuListeners, {            scope:this        }));        this.menu.picker.setValue(this.getValue() || new Date());        this.menu.show(this.el, "tl-bl?");    },    beforeBlur : function(){        var v = this.parseDate(this.getRawValue());        if(v){            this.setValue(v);        }    }                });Ext.form.Checkbox = function(config){    Ext.form.Checkbox.superclass.constructor.call(this, config);    this.addEvents({                check : true    });};Ext.extend(Ext.form.Checkbox, Ext.form.Field,  {        focusClass : "x-form-check-focus",        fieldClass: "x-form-field",        checked: false,        defaultAutoCreate : { tag: "input", type: 'checkbox', autocomplete: "off"},        boxLabel : undefined,            onResize : function(){        Ext.form.Checkbox.superclass.onResize.apply(this, arguments);        if(!this.boxLabel){            this.el.alignTo(this.wrap, 'c-c');        }    },    initEvents : function(){        Ext.form.Checkbox.superclass.initEvents.call(this);        this.el.on("click", this.onClick,  this);        this.el.on("change", this.onClick,  this);    },    getResizeEl : function(){        return this.wrap;    },    getPositionEl : function(){        return this.wrap;    },        onRender : function(ct, position){        Ext.form.Checkbox.superclass.onRender.call(this, ct, position);        if(this.inputValue !== undefined){            this.el.dom.value = this.inputValue;        }        this.wrap = this.el.wrap({cls: "x-form-check-wrap"});        if(this.boxLabel){            this.wrap.createChild({tag: 'label', htmlFor: this.el.id, cls: 'x-form-cb-label', html: this.boxLabel});        }        if(this.checked){            this.setValue(true);        }    },        initValue : Ext.emptyFn,        getValue : function(){        if(this.rendered){            return this.el.dom.checked;        }        return false;    },	    onClick : function(){        if(this.el.dom.checked != this.checked){            this.setValue(this.el.dom.checked);        }    },        setValue : function(v){        this.checked = (v === true || v === 'true' || v == '1' || String(v).toLowerCase() == 'on');        if(this.el && this.el.dom){            this.el.dom.checked = this.checked;        }        this.fireEvent("check", this, this.checked);    }});Ext.form.Radio = function(){    Ext.form.Radio.superclass.constructor.apply(this, arguments);};Ext.extend(Ext.form.Radio, Ext.form.Checkbox, {    inputType: 'radio',        getGroupValue : function(){        return this.el.up('form').child('input[name='+this.el.dom.name+']:checked', true).value;    }});Ext.form.ComboBox = function(config){    Ext.form.ComboBox.superclass.constructor.call(this, config);    this.addEvents({                'expand' : true,                'collapse' : true,                'beforeselect' : true,                'select' : true,                'beforequery': true    });    if(this.transform){        this.allowDomMove = false;        var s = Ext.getDom(this.transform);        if(!this.hiddenName){            this.hiddenName = s.name;        }        if(!this.store){            this.mode = 'local';            var d = [], opts = s.options;            for(var i = 0, len = opts.length;i < len; i++){                var o = opts[i];                var value = (Ext.isIE ? o.getAttributeNode('value').specified : o.hasAttribute('value')) ? o.value : o.text;                if(o.selected) {                    this.value = value;                }                d.push([value, o.text]);            }            this.store = new Ext.data.SimpleStore({                'id': 0,                fields: ['value', 'text'],                data : d            });            this.valueField = 'value';            this.displayField = 'text';        }        s.name = Ext.id();         if(!this.lazyRender){            this.target = true;            this.el = Ext.DomHelper.insertBefore(s, this.autoCreate || this.defaultAutoCreate);            s.parentNode.removeChild(s);             this.render(this.el.parentNode);        }else{            s.parentNode.removeChild(s);         }    }    this.selectedIndex = -1;    if(this.mode == 'local'){        if(config.queryDelay === undefined){            this.queryDelay = 10;        }        if(config.minChars === undefined){            this.minChars = 0;        }    }};Ext.extend(Ext.form.ComboBox, Ext.form.TriggerField, {                    defaultAutoCreate : {tag: "input", type: "text", size: "24", autocomplete: "off"},        listWidth: undefined,        displayField: undefined,        valueField: undefined,        hiddenName: undefined,        listClass: '',        selectedClass: 'x-combo-selected',        triggerClass : 'x-form-arrow-trigger',        shadow:'sides',        listAlign: 'tl-bl?',        maxHeight: 300,        triggerAction: 'query',        minChars : 4,        typeAhead: false,        queryDelay: 500,        pageSize: 0,        selectOnFocus:false,        queryParam: 'query',        loadingText: 'Loading...',        resizable: false,        handleHeight : 8,        editable: true,        allQuery: '',        mode: 'remote',        minListWidth : 70,        forceSelection:false,        typeAheadDelay : 250,        valueNotFoundText : undefined,        onRender : function(ct, position){        Ext.form.ComboBox.superclass.onRender.call(this, ct, position);        if(this.hiddenName){            this.hiddenField = this.el.insertSibling({tag:'input', type:'hidden', name: this.hiddenName, id:  (this.hiddenId||this.hiddenName)},                    'before', true);            this.hiddenField.value =                this.hiddenValue !== undefined ? this.hiddenValue :                this.value !== undefined ? this.value : '';                        this.el.dom.removeAttribute('name');        }        if(Ext.isGecko){            this.el.dom.setAttribute('autocomplete', 'off');        }        var cls = 'x-combo-list';        this.list = new Ext.Layer({            shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false        });        var lw = this.listWidth || Math.max(this.wrap.getWidth(), this.minListWidth);        this.list.setWidth(lw);        this.list.swallowEvent('mousewheel');        this.assetHeight = 0;        if(this.title){            this.header = this.list.createChild({cls:cls+'-hd', html: this.title});            this.assetHeight += this.header.getHeight();        }        this.innerList = this.list.createChild({cls:cls+'-inner'});        this.innerList.on('mouseover', this.onViewOver, this);        this.innerList.on('mousemove', this.onViewMove, this);        this.innerList.setWidth(lw - this.list.getFrameWidth('lr'))        if(this.pageSize){            this.footer = this.list.createChild({cls:cls+'-ft'});            this.pageTb = new Ext.PagingToolbar(this.footer, this.store,                    {pageSize: this.pageSize});            this.assetHeight += this.footer.getHeight();        }        if(!this.tpl){            this.tpl = '<div class="'+cls+'-item">{' + this.displayField + '}</div>';        }        this.view = new Ext.View(this.innerList, this.tpl, {            singleSelect:true, store: this.store, selectedClass: this.selectedClass        });        this.view.on('click', this.onViewClick, this);        this.store.on('beforeload', this.onBeforeLoad, this);        this.store.on('load', this.onLoad, this);

⌨️ 快捷键说明

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