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

📄 tabpanel.js

📁 当前比较流行的,漂亮的JS框架,这里面用到的API文档
💻 JS
📖 第 1 页 / 共 3 页
字号:
    initEvents : function(){        Ext.TabPanel.superclass.initEvents.call(this);        this.on('add', this.onAdd, this);        this.on('remove', this.onRemove, this);        this.strip.on('mousedown', this.onStripMouseDown, this);        this.strip.on('click', this.onStripClick, this);        this.strip.on('contextmenu', this.onStripContextMenu, this);        if(this.enableTabScroll){            this.strip.on('mousewheel', this.onWheel, this);        }    },    // private    findTargets : function(e){        var item = null;        var itemEl = e.getTarget('li', this.strip);        if(itemEl){            item = this.getComponent(itemEl.id.split(this.idDelimiter)[1]);            if(item.disabled){                return {                    close : null,                    item : null,                    el : null                };            }        }        return {            close : e.getTarget('.x-tab-strip-close', this.strip),            item : item,            el : itemEl        };    },    // private    onStripMouseDown : function(e){        e.preventDefault();        if(e.button != 0){            return;        }        var t = this.findTargets(e);        if(t.close){            this.remove(t.item);            return;        }        if(t.item && t.item != this.activeTab){            this.setActiveTab(t.item);        }    },    // private    onStripClick : function(e){        var t = this.findTargets(e);        if(!t.close && t.item && t.item != this.activeTab){            this.setActiveTab(t.item);        }    },    // private    onStripContextMenu : function(e){        e.preventDefault();        var t = this.findTargets(e);        if(t.item){            this.fireEvent('contextmenu', this, t.item, e);        }    },    /**     * True to scan the markup in this tab panel for autoTabs using the autoTabSelector     * @param {Boolean} removeExisting True to remove existing tabs     */    readTabs : function(removeExisting){        if(removeExisting === true){            this.items.each(function(item){                this.remove(item);            }, this);        }        var tabs = this.el.query(this.autoTabSelector);        for(var i = 0, len = tabs.length; i < len; i++){            var tab = tabs[i];            var title = tab.getAttribute('title');            tab.removeAttribute('title');            this.add({                title: title,                el: tab            });        }    },    // private    initTab : function(item, index){        var before = this.strip.dom.childNodes[index];        var cls = item.closable ? 'x-tab-strip-closable' : '';        if(item.disabled){            cls += ' x-item-disabled';        }        if(item.iconCls){            cls += ' x-tab-with-icon';        }        if(item.tabCls){            cls += ' ' + item.tabCls;        }                var p = {            id: this.id + this.idDelimiter + item.getItemId(),            text: item.title,            cls: cls,            iconCls: item.iconCls || ''        };        var el = before ?                 this.itemTpl.insertBefore(before, p) :                 this.itemTpl.append(this.strip, p);        Ext.fly(el).addClassOnOver('x-tab-strip-over');        if(item.tabTip){            Ext.fly(el).child('span.x-tab-strip-text', true).qtip = item.tabTip;        }        item.on('disable', this.onItemDisabled, this);        item.on('enable', this.onItemEnabled, this);        item.on('titlechange', this.onItemTitleChanged, this);        item.on('beforeshow', this.onBeforeShowItem, this);    },    // private    onAdd : function(tp, item, index){        this.initTab(item, index);        if(this.items.getCount() == 1){            this.syncSize();        }        this.delegateUpdates();    },    // private    onBeforeAdd : function(item){        var existing = item.events ? (this.items.containsKey(item.getItemId()) ? item : null) : this.items.get(item);        if(existing){            this.setActiveTab(item);            return false;        }        Ext.TabPanel.superclass.onBeforeAdd.apply(this, arguments);        var es = item.elements;        item.elements = es ? es.replace(',header', '') : es;        item.border = (item.border === true);    },    // private    onRemove : function(tp, item){        Ext.removeNode(this.getTabEl(item));        this.stack.remove(item);        if(item == this.activeTab){            var next = this.stack.next();            if(next){                this.setActiveTab(next);            }else{                this.setActiveTab(0);            }        }        this.delegateUpdates();    },    // private    onBeforeShowItem : function(item){        if(item != this.activeTab){            this.setActiveTab(item);            return false;        }    },    // private    onItemDisabled : function(item){        var el = this.getTabEl(item);        if(el){            Ext.fly(el).addClass('x-item-disabled');        }        this.stack.remove(item);    },    // private    onItemEnabled : function(item){        var el = this.getTabEl(item);        if(el){            Ext.fly(el).removeClass('x-item-disabled');        }    },    // private    onItemTitleChanged : function(item){        var el = this.getTabEl(item);        if(el){            Ext.fly(el).child('span.x-tab-strip-text', true).innerHTML = item.title;        }    },    /**     * Gets the DOM element for tab strip item which activates the     * child panel with the specified ID. Access this to change the visual treatment of the     * item, for example by changing the CSS class name.     * @param {Panel} tab The tab     * @return {HTMLElement} The DOM node     */    getTabEl : function(item){        var itemId = (typeof item === 'number')?this.items.items[item].getItemId() : item.getItemId();        return document.getElementById(this.id+this.idDelimiter+itemId);    },    // private    onResize : function(){        Ext.TabPanel.superclass.onResize.apply(this, arguments);        this.delegateUpdates();    },    /**     * Suspends any internal calculations or scrolling while doing a bulk operation. See {@link #endUpdate}     */    beginUpdate : function(){        this.suspendUpdates = true;    },    /**     * Resumes calculations and scrolling at the end of a bulk operation. See {@link #beginUpdate}     */    endUpdate : function(){        this.suspendUpdates = false;        this.delegateUpdates();    },    /**     * Hides the tab strip item for the passed tab     * @param {Number/String/Panel} item The tab index, id or item     */    hideTabStripItem : function(item){        item = this.getComponent(item);        var el = this.getTabEl(item);        if(el){            el.style.display = 'none';            this.delegateUpdates();        }    },    /**     * Unhides the tab strip item for the passed tab     * @param {Number/String/Panel} item The tab index, id or item     */    unhideTabStripItem : function(item){        item = this.getComponent(item);        var el = this.getTabEl(item);        if(el){            el.style.display = '';            this.delegateUpdates();        }    },    // private    delegateUpdates : function(){        if(this.suspendUpdates){            return;        }        if(this.resizeTabs && this.rendered){            this.autoSizeTabs();        }        if(this.enableTabScroll && this.rendered){            this.autoScrollTabs();        }    },    // private    autoSizeTabs : function(){        var count = this.items.length;        var ce = this.tabPosition != 'bottom' ? 'header' : 'footer';        var ow = this[ce].dom.offsetWidth;        var aw = this[ce].dom.clientWidth;        if(!this.resizeTabs || count < 1 || !aw){ // !aw for display:none            return;        }        var each = Math.max(Math.min(Math.floor((aw-4) / count) - this.tabMargin, this.tabWidth), this.minTabWidth); // -4 for float errors in IE        this.lastTabWidth = each;        var lis = this.stripWrap.dom.getElementsByTagName('li');        for(var i = 0, len = lis.length-1; i < len; i++) { // -1 for the "edge" li            var li = lis[i];            var inner = li.childNodes[1].firstChild.firstChild;            var tw = li.offsetWidth;            var iw = inner.offsetWidth;            inner.style.width = (each - (tw-iw)) + 'px';        }    },    // private    adjustBodyWidth : function(w){        if(this.header){            this.header.setWidth(w);        }        if(this.footer){            this.footer.setWidth(w);        }        return w;    },    /**     * Sets the specified tab as the active tab. This method fires the {@link #beforetabchange} event which     * can return false to cancel the tab change.     * @param {String/Panel} tab The id or tab Panel to activate     */    setActiveTab : function(item){        item = this.getComponent(item);

⌨️ 快捷键说明

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