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

📄 combo.js

📁 Ext JS是一个创建丰富互联网应用程序的跨浏览器的JavaScrip库。它包含:高效率
💻 JS
📖 第 1 页 / 共 3 页
字号:
            return;        }        this.innerList.update(this.loadingText ?               '<div class="loading-indicator">'+this.loadingText+'</div>' : '');        this.restrictHeight();        this.selectedIndex = -1;    },    // private    onLoad : function(){        if(!this.hasFocus){            return;        }        if(this.store.getCount() > 0){            this.expand();            this.restrictHeight();            if(this.lastQuery == this.allQuery){                if(this.editable){                    this.el.dom.select();                }                if(!this.selectByValue(this.value, true)){                    this.select(0, true);                }            }else{                this.selectNext();                if(this.typeAhead && this.lastKey != Ext.EventObject.BACKSPACE && this.lastKey != Ext.EventObject.DELETE){                    this.taTask.delay(this.typeAheadDelay);                }            }        }else{            this.onEmptyResults();        }        //this.el.focus();    },    // private    onTypeAhead : function(){        if(this.store.getCount() > 0){            var r = this.store.getAt(0);            var newValue = r.data[this.displayField];            var len = newValue.length;            var selStart = this.getRawValue().length;            if(selStart != len){                this.setRawValue(newValue);                this.selectText(selStart, newValue.length);            }        }    },    // private    onSelect : function(record, index){        if(this.fireEvent('beforeselect', this, record, index) !== false){            this.setValue(record.data[this.valueField || this.displayField]);            this.collapse();            this.fireEvent('select', this, record, index);        }    },    /**     * Returns the currently selected field value or empty string if no value is set.     * @return {String} value The selected value     */    getValue : function(){        if(this.valueField){            return typeof this.value != 'undefined' ? this.value : '';        }else{            return Ext.form.ComboBox.superclass.getValue.call(this);        }    },    /**     * Clears any text/value currently set in the field     */    clearValue : function(){        if(this.hiddenField){            this.hiddenField.value = '';        }        this.setRawValue('');        this.lastSelectionText = '';        this.applyEmptyText();        this.value = '';    },    /**     * Sets the specified value into the field.  If the value finds a match, the corresponding record text     * will be displayed in the field.  If the value does not match the data value of an existing item,     * and the valueNotFoundText config option is defined, it will be displayed as the default field text.     * Otherwise the field will be blank (although the value will still be set).     * @param {String} value The value to match     * @return {Ext.form.Field} this     */    setValue : function(v){        var text = v;        if(this.valueField){            var r = this.findRecord(this.valueField, v);            if(r){                text = r.data[this.displayField];            }else if(this.valueNotFoundText !== undefined){                text = this.valueNotFoundText;            }        }        this.lastSelectionText = text;        if(this.hiddenField){            this.hiddenField.value = v;        }        Ext.form.ComboBox.superclass.setValue.call(this, text);        this.value = v;        return this;    },    // private    findRecord : function(prop, value){        var record;        if(this.store.getCount() > 0){            this.store.each(function(r){                if(r.data[prop] == value){                    record = r;                    return false;                }            });        }        return record;    },    // private    onViewMove : function(e, t){        this.inKeyMode = false;    },    // private    onViewOver : function(e, t){        if(this.inKeyMode){ // prevent key nav and mouse over conflicts            return;        }        var item = this.view.findItemFromChild(t);        if(item){            var index = this.view.indexOf(item);            this.select(index, false);        }    },    // private    onViewClick : function(doFocus){        var index = this.view.getSelectedIndexes()[0];        var r = this.store.getAt(index);        if(r){            this.onSelect(r, index);        }        if(doFocus !== false){            this.el.focus();        }    },    // private    restrictHeight : function(){        this.innerList.dom.style.height = '';        var inner = this.innerList.dom;        var pad = this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight;        var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);        var ha = this.getPosition()[1]-Ext.getBody().getScroll().top;        var hb = Ext.lib.Dom.getViewHeight()-ha-this.getSize().height;        var space = Math.max(ha, hb, this.minHeight || 0)-this.list.shadowOffset-pad-5;        h = Math.min(h, space, this.maxHeight);        this.innerList.setHeight(h);        this.list.beginUpdate();        this.list.setHeight(h+pad);        this.list.alignTo(this.wrap, this.listAlign);        this.list.endUpdate();    },    // private    onEmptyResults : function(){        this.collapse();    },    /**     * Returns true if the dropdown list is expanded, else false.     */    isExpanded : function(){        return this.list && this.list.isVisible();    },    /**     * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.     * The store must be loaded and the list expanded for this function to work, otherwise use setValue.     * @param {String} value The data value of the item to select     * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the     * selected item if it is not currently in view (defaults to true)     * @return {Boolean} True if the value matched an item in the list, else false     */    selectByValue : function(v, scrollIntoView){        if(v !== undefined && v !== null){            var r = this.findRecord(this.valueField || this.displayField, v);            if(r){                this.select(this.store.indexOf(r), scrollIntoView);                return true;            }        }        return false;    },    /**     * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.     * The store must be loaded and the list expanded for this function to work, otherwise use setValue.     * @param {Number} index The zero-based index of the list item to select     * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the     * selected item if it is not currently in view (defaults to true)     */    select : function(index, scrollIntoView){        this.selectedIndex = index;        this.view.select(index);        if(scrollIntoView !== false){            var el = this.view.getNode(index);            if(el){                this.innerList.scrollChildIntoView(el, false);            }        }    },    // private    selectNext : function(){        var ct = this.store.getCount();        if(ct > 0){            if(this.selectedIndex == -1){                this.select(0);            }else if(this.selectedIndex < ct-1){                this.select(this.selectedIndex+1);            }        }    },    // private    selectPrev : function(){        var ct = this.store.getCount();        if(ct > 0){            if(this.selectedIndex == -1){                this.select(0);            }else if(this.selectedIndex != 0){                this.select(this.selectedIndex-1);            }        }    },    // private    onKeyUp : function(e){        if(this.editable !== false && !e.isSpecialKey()){            this.lastKey = e.getKey();            this.dqTask.delay(this.queryDelay);        }    },    // private    validateBlur : function(){        return !this.list || !this.list.isVisible();    },    // private    initQuery : function(){        this.doQuery(this.getRawValue());    },    // private    doForce : function(){        if(this.el.dom.value.length > 0){            this.el.dom.value =                this.lastSelectionText === undefined ? '' : this.lastSelectionText;            this.applyEmptyText();        }    },    /**     * Execute a query to filter the dropdown list.  Fires the {@link #beforequery} event prior to performing the     * query allowing the query action to be canceled if needed.     * @param {String} query The SQL query to execute     * @param {Boolean} forceAll <tt>true</tt> to force the query to execute even if there are currently fewer     * characters in the field than the minimum specified by the <tt>{@link #minChars}</tt> config option.  It     * also clears any filter previously saved in the current store (defaults to <tt>false</tt>)     */    doQuery : function(q, forceAll){        if(q === undefined || q === null){            q = '';        }        var qe = {            query: q,            forceAll: forceAll,            combo: this,            cancel:false        };        if(this.fireEvent('beforequery', qe)===false || qe.cancel){            return false;        }        q = qe.query;        forceAll = qe.forceAll;        if(forceAll === true || (q.length >= this.minChars)){            if(this.lastQuery !== q){                this.lastQuery = q;                if(this.mode == 'local'){                    this.selectedIndex = -1;                    if(forceAll){                        this.store.clearFilter();                    }else{                        this.store.filter(this.displayField, q);                    }                    this.onLoad();                }else{                    this.store.baseParams[this.queryParam] = q;                    this.store.load({                        params: this.getParams(q)                    });                    this.expand();                }            }else{                this.selectedIndex = -1;                this.onLoad();            }        }    },    // private    getParams : function(q){        var p = {};        //p[this.queryParam] = q;        if(this.pageSize){            p.start = 0;            p.limit = this.pageSize;        }        return p;    },    /**     * Hides the dropdown list if it is currently expanded. Fires the {@link #collapse} event on completion.     */    collapse : function(){        if(!this.isExpanded()){            return;        }        this.list.hide();        Ext.getDoc().un('mousewheel', this.collapseIf, this);        Ext.getDoc().un('mousedown', this.collapseIf, this);        this.fireEvent('collapse', this);    },    // private    collapseIf : function(e){        if(!e.within(this.wrap) && !e.within(this.list)){            this.collapse();        }    },    /**     * Expands the dropdown list if it is currently hidden. Fires the {@link #expand} event on completion.     */    expand : function(){        if(this.isExpanded() || !this.hasFocus){            return;        }        this.list.alignTo(this.wrap, this.listAlign);        this.list.show();        this.innerList.setOverflow('auto'); // necessary for FF 2.0/Mac        Ext.getDoc().on('mousewheel', this.collapseIf, this);        Ext.getDoc().on('mousedown', this.collapseIf, this);        this.fireEvent('expand', this);    },    /**     * @method onTriggerClick     * @hide     */    // private    // Implements the default empty TriggerField.onTriggerClick function    onTriggerClick : function(){        if(this.disabled){            return;        }        if(this.isExpanded()){            this.collapse();            this.el.focus();        }else {            this.onFocus({});            if(this.triggerAction == 'all') {                this.doQuery(this.allQuery, true);            } else {                this.doQuery(this.getRawValue());            }            this.el.focus();        }    }    /**     * @hide     * @method autoSize     */    /**     * @cfg {Boolean} grow @hide     */    /**     * @cfg {Number} growMin @hide     */    /**     * @cfg {Number} growMax @hide     */});Ext.reg('combo', Ext.form.ComboBox);

⌨️ 快捷键说明

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