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

📄 combo.js

📁 Ext JS是一个创建丰富互联网应用程序的跨浏览器的JavaScrip库。它包含:高效率
💻 JS
📖 第 1 页 / 共 3 页
字号:
        if(this.transform){            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 = (o.hasAttribute ? o.hasAttribute('value') : o.getAttribute('value') !== null) ? o.value : o.text;                    if(o.selected && Ext.isEmpty(this.value, true)) {                        this.value = value;                    }                    d.push([value, o.text]);                }                this.store = new Ext.data.ArrayStore({                    'id': 0,                    fields: ['value', 'text'],                    data : d,                    autoDestroy: true                });                this.valueField = 'value';                this.displayField = 'text';            }            s.name = Ext.id(); // wipe out the name in case somewhere else they have a reference            if(!this.lazyRender){                this.target = true;                this.el = Ext.DomHelper.insertBefore(s, this.autoCreate || this.defaultAutoCreate);                Ext.removeNode(s); // remove it                this.render(this.el.parentNode);            }else{                Ext.removeNode(s); // remove it            }        }        //auto-configure store from local array data        else if(Ext.isArray(this.store)){            if (Ext.isArray(this.store[0])){                this.store = new Ext.data.ArrayStore({                    fields: ['value','text'],                    data: this.store,                    autoDestroy: true                });                this.valueField = 'value';            }else{                this.store = new Ext.data.ArrayStore({                    fields: ['text'],                    data: this.store,                    expandData: true,                    autoDestroy: true                });                this.valueField = 'text';            }            this.displayField = 'text';            this.mode = 'local';        }        this.selectedIndex = -1;        if(this.mode == 'local'){            if(this.initialConfig.queryDelay === undefined){                this.queryDelay = 10;            }            if(this.initialConfig.minChars === undefined){                this.minChars = 0;            }        }    },    // private    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);            // prevent input submission            this.el.dom.removeAttribute('name');        }        if(Ext.isGecko){            this.el.dom.setAttribute('autocomplete', 'off');        }        if(!this.lazyInit){            this.initList();        }else{            this.on('focus', this.initList, this, {single: true});        }    },    // private    initValue : function(){        Ext.form.ComboBox.superclass.initValue.call(this);        if(this.hiddenField){            this.hiddenField.value =                this.hiddenValue !== undefined ? this.hiddenValue :                this.value !== undefined ? this.value : '';        }    },    // private    initList : function(){        if(!this.list){            var cls = 'x-combo-list';            this.list = new Ext.Layer({				parentEl: this.getListParent(),                shadow: this.shadow, 				cls: [cls, this.listClass].join(' '), 				constrain:false            });            var lw = this.listWidth || Math.max(this.wrap.getWidth(), this.minListWidth);            this.list.setSize(lw, 0);            this.list.swallowEvent('mousewheel');            this.assetHeight = 0;            if(this.syncFont !== false){                this.list.setStyle('font-size', this.el.getStyle('font-size'));            }            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.mon(this.innerList, 'mouseover', this.onViewOver, this);            this.mon(this.innerList, '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({                    store: this.store,                    pageSize: this.pageSize,                    renderTo:this.footer                });                this.assetHeight += this.footer.getHeight();            }            if(!this.tpl){                /**                * @cfg {String/Ext.XTemplate} tpl <p>The template string, or {@link Ext.XTemplate} instance to                * use to display each item in the dropdown list. The dropdown list is displayed in a                * DataView. See {@link #view}.</p>                * <p>The default template string is:</p><pre><code>                  '&lt;tpl for=".">&lt;div class="x-combo-list-item">{' + this.displayField + '}&lt;/div>&lt;/tpl>'                * </code></pre>                * <p>Override the default value to create custom UI layouts for items in the list.                * For example:</p><pre><code>                  '&lt;tpl for=".">&lt;div ext:qtip="{state}. {nick}" class="x-combo-list-item">{state}&lt;/div>&lt;/tpl>'                * </code></pre>                * <p>The template <b>must</b> contain one or more substitution parameters using field                * names from the Combo's</b> {@link #store Store}. In the example above an                * <pre>ext:qtip</pre> attribute is added to display other fields from the Store.</p>                * <p>To preserve the default visual look of list items, add the CSS class name                * <pre>x-combo-list-item</pre> to the template's container element.</p>                * <p>Also see {@link #itemSelector} for additional details.</p>                */                this.tpl = '<tpl for="."><div class="'+cls+'-item">{' + this.displayField + '}</div></tpl>';                /**                 * @cfg {String} itemSelector                 * <p>A simple CSS selector (e.g. div.some-class or span:first-child) that will be                 * used to determine what nodes the {@link #view Ext.DataView} which handles the dropdown                 * display will be working with.</p>                 * <p><b>Note</b>: this setting is <b>required</b> if a custom XTemplate has been                 * specified in {@link #tpl} which assigns a class other than <pre>'x-combo-list-item'</pre>                 * to dropdown list items</b>                 */            }            /**            * The {@link Ext.DataView DataView} used to display the ComboBox's options.            * @type Ext.DataView            */            this.view = new Ext.DataView({                applyTo: this.innerList,                tpl: this.tpl,                singleSelect: true,                selectedClass: this.selectedClass,                itemSelector: this.itemSelector || '.' + cls + '-item',                emptyText: this.listEmptyText            });			            this.mon(this.view, 'click', this.onViewClick, this);            this.bindStore(this.store, true);            if(this.resizable){                this.resizer = new Ext.Resizable(this.list,  {                   pinned:true, handles:'se'                });                this.mon(this.resizer, 'resize', function(r, w, h){                    this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;                    this.listWidth = w;                    this.innerList.setWidth(w - this.list.getFrameWidth('lr'));                    this.restrictHeight();                }, this);                this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');            }        }    },    /**     * <p>Returns the element used to house this ComboBox's pop-up list. Defaults to the document body.</p>     * A custom implementation may be provided as a configuration option if the floating list needs to be rendered     * to a different Element. An example might be rendering the list inside a Menu so that clicking     * the list does not hide the Menu:<pre><code>var store = new Ext.data.ArrayStore({    autoDestroy: true,    fields: ['initials', 'fullname'],    data : [        ['FF', 'Fred Flintstone'],        ['BR', 'Barney Rubble']    ]});var combo = new Ext.form.ComboBox({    store: store,    displayField: 'fullname',    emptyText: 'Select a name...',    forceSelection: true,    getListParent: function() {        return this.el.up('.x-menu');    },    iconCls: 'no-icon', //use iconCls if placing within menu to shift to right side of menu    mode: 'local',    selectOnFocus: true,    triggerAction: 'all',    typeAhead: true,    width: 135});var menu = new Ext.menu.Menu({    id: 'mainMenu',    items: [        combo // A Field in a Menu    ]});</code></pre>     */    getListParent : function() {        return document.body;    },        /**     * Returns the store associated with this combo.     * @return {Ext.data.Store} The store     */    getStore : function(){        return this.store;    },    // private    bindStore : function(store, initial){        if(this.store && !initial){            this.store.un('beforeload', this.onBeforeLoad, this);            this.store.un('load', this.onLoad, this);            this.store.un('loadexception', this.collapse, this);            if(this.store !== store && this.store.autoDestroy){                this.store.destroy();            }            if(!store){                this.store = null;                if(this.view){                    this.view.bindStore(null);                }            }        }        if(store){			if(!initial) {				this.lastQuery = null;				if(this.pageTb) {					this.pageTb.bindStore(store);				}							}					            this.store = Ext.StoreMgr.lookup(store);            this.store.on('beforeload', this.onBeforeLoad, this);            this.store.on('load', this.onLoad, this);            this.store.on('loadexception', this.collapse, this);            if(this.view){                this.view.bindStore(store);            }        }    },    // private    initEvents : function(){        Ext.form.ComboBox.superclass.initEvents.call(this);        this.keyNav = new Ext.KeyNav(this.el, {            "up" : function(e){                this.inKeyMode = true;                this.selectPrev();            },            "down" : function(e){                if(!this.isExpanded()){                    this.onTriggerClick();                }else{                    this.inKeyMode = true;                    this.selectNext();                }            },            "enter" : function(e){                this.onViewClick();                this.delayedCheck = true;                this.unsetDelayCheck.defer(10, this);            },            "esc" : function(e){                this.collapse();            },            "tab" : function(e){                this.onViewClick(false);                return true;            },            scope : this,            doRelay : function(foo, bar, hname){                if(hname == 'down' || this.scope.isExpanded()){                   return Ext.KeyNav.prototype.doRelay.apply(this, arguments);                }                return true;            },            forceKeyDown : true        });        this.queryDelay = Math.max(this.queryDelay || 10,                this.mode == 'local' ? 10 : 250);        this.dqTask = new Ext.util.DelayedTask(this.initQuery, this);        if(this.typeAhead){            this.taTask = new Ext.util.DelayedTask(this.onTypeAhead, this);        }        if(this.editable !== false){        	this.mon(this.el, 'keyup', this.onKeyUp, this);        }        if(this.forceSelection){            this.on('blur', this.doForce, this);        }    },    // private    onDestroy : function(){        if (this.dqTask){            this.dqTask.cancel();            this.dqTask = null;        }        this.bindStore(null);        if(this.resizer){            this.resizer.destroy(true);        }        Ext.destroy(            this.view,            this.pageTb,            this.list        );        Ext.form.ComboBox.superclass.onDestroy.call(this);    },    // private    unsetDelayCheck : function(){        delete this.delayedCheck;    },    // private    fireKey : function(e){        if(e.isNavKeyPress() && !this.isExpanded() && !this.delayedCheck){            this.fireEvent("specialkey", this, e);        }    },    // private    onResize : function(w, h){        Ext.form.ComboBox.superclass.onResize.apply(this, arguments);        if(this.list && this.listWidth === undefined){            var lw = Math.max(w, this.minListWidth);            this.list.setWidth(lw);            this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));        }    },    // private    onEnable : function(){        Ext.form.ComboBox.superclass.onEnable.apply(this, arguments);        if(this.hiddenField){            this.hiddenField.disabled = false;        }    },    // private    onDisable : function(){        Ext.form.ComboBox.superclass.onDisable.apply(this, arguments);        if(this.hiddenField){            this.hiddenField.disabled = true;        }    },    // private    onBeforeLoad : function(){        if(!this.hasFocus){

⌨️ 快捷键说明

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