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

📄 tabpanel.js

📁 当前比较流行的,漂亮的JS框架,这里面用到的API文档
💻 JS
📖 第 1 页 / 共 3 页
字号:
/*
 * Ext JS Library 2.0.2
 * Copyright(c) 2006-2008, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */

/** * @class Ext.TabPanel * <p>A basic tab container. Tab panels can be used exactly like a standard {@link Ext.Panel} for layout * purposes, but also have special support for containing child Panels that get automatically converted into tabs.</p> * <p>There is no actual tab class &mdash; each tab is simply an {@link Ext.Panel}.  However, when rendered in a * TabPanel, each child Panel can fire additional events that only exist for tabs and are not available to other * Panels. These are:</p> * <ul> * <li><b>activate</b>: Fires when this Panel becomes the active tab. * <div class="mdetail-params"> *      <strong style="font-weight: normal;">Listeners will be called with the following arguments:</strong> *      <ul><li><code>tab</code> : Panel<div class="sub-desc">The tab that was activated</div></li></ul> *  </div></li> * <li><b>deactivate</b>: Fires when this Panel that was the active tab becomes deactivated. * <div class="mdetail-params"> *      <strong style="font-weight: normal;">Listeners will be called with the following arguments:</strong> *      <ul><li><code>tab</code> : Panel<div class="sub-desc">The tab that was deactivated</div></li></ul> *  </div></li> * </ul> * <p>There are several methods available for creating TabPanels. The output of the following examples should be * exactly the same. The tabs can be created and rendered completely in code, as in this example:</p> * <pre><code>var tabs = new Ext.TabPanel({    renderTo: Ext.getBody(),    activeTab: 0,    items: [{        title: 'Tab 1',        html: 'A simple tab'    },{        title: 'Tab 2',        html: 'Another one'    }]});</pre></code>  * <p>TabPanels can also be rendered from markup in a couple of ways.  See the {@link #autoTabs} example for  * rendering entirely from markup that is already structured correctly as a TabPanel (a container div with  * one or more nested tab divs with class 'x-tab'). You can also render from markup that is not strictly  * structured by simply specifying by id which elements should be the container and the tabs. Using this method,  * tab content can be pulled from different elements within the page by id regardless of page structure.  Note  * that the tab divs in this example contain the class 'x-hide-display' so that they can be rendered deferred  * without displaying outside the tabs. You could alternately set {@link #deferredRender} to false to render all  * content tabs on page load. For example:  * <pre><code>var tabs = new Ext.TabPanel({    renderTo: 'my-tabs',    activeTab: 0,    items:[        {contentEl:'tab1', title:'Tab 1'},        {contentEl:'tab2', title:'Tab 2'}    ]});// Note that the tabs do not have to be nested within the container (although they can be)&lt;div id="my-tabs">&lt;/div>&lt;div id="tab1" class="x-hide-display">A simple tab&lt;/div>&lt;div id="tab2" class="x-hide-display">Another one&lt;/div></pre></code> * @extends Ext.Panel * @constructor * @param {Object} config The configuration options */Ext.TabPanel = Ext.extend(Ext.Panel,  {    /**     * @cfg {Boolean} layoutOnTabChange Set to true to do a layout of tab items as tabs are changed.     */    /**     * @cfg {Boolean} monitorResize True to automatically monitor window resize events and rerender the layout on     * browser resize (defaults to true).     */    monitorResize : true,    /**     * @cfg {Boolean} deferredRender Internally, the TabPanel uses a {@link Ext.layout.CardLayout} to manage its tabs.     * This property will be passed on to the layout as its {@link Ext.layout.CardLayout#deferredRender} config value,     * determining whether or not each tab is rendered only when first accessed (defaults to true).     */    deferredRender : true,    /**     * @cfg {Number} tabWidth The initial width in pixels of each new tab (defaults to 120).     */    tabWidth: 120,    /**     * @cfg {Number} minTabWidth The minimum width in pixels for each tab when {@link #resizeTabs} = true (defaults to 30).     */    minTabWidth: 30,    /**     * @cfg {Boolean} resizeTabs True to automatically resize each tab so that the tabs will completely fill the     * tab strip (defaults to false).  Setting this to true may cause specific widths that might be set per tab to     * be overridden in order to fit them all into view (although {@link #minTabWidth} will always be honored).     */    resizeTabs:false,    /**     * @cfg {Boolean} enableTabScroll True to enable scrolling to tabs that may be invisible due to overflowing the     * overall TabPanel width. Only available with tabs on top. (defaults to false).     */    enableTabScroll: false,    /**     * @cfg {Number} scrollIncrement The number of pixels to scroll each time a tab scroll button is pressed (defaults     * to 100, or if {@link #resizeTabs} = true, the calculated tab width).  Only applies when {@link #enableTabScroll} = true.     */    scrollIncrement : 0,    /**     * @cfg {Number} scrollRepeatInterval Number of milliseconds between each scroll while a tab scroll button is     * continuously pressed (defaults to 400).     */    scrollRepeatInterval : 400,    /**     * @cfg {Float} scrollDuration The number of milliseconds that each scroll animation should last (defaults to .35).     * Only applies when {@link #animScroll} = true.     */    scrollDuration : .35,    /**     * @cfg {Boolean} animScroll True to animate tab scrolling so that hidden tabs slide smoothly into view (defaults     * to true).  Only applies when {@link #enableTabScroll} = true.     */    animScroll : true,    /**     * @cfg {String} tabPosition The position where the tab strip should be rendered (defaults to 'top').  The only     * other supported value is 'bottom'.  Note that tab scrolling is only supported for position 'top'.     */    tabPosition: 'top',    /**     * @cfg {String} baseCls The base CSS class applied to the panel (defaults to 'x-tab-panel').     */    baseCls: 'x-tab-panel',    /**     * @cfg {Boolean} autoTabs     * <p>True to query the DOM for any divs with a class of 'x-tab' to be automatically converted     * to tabs and added to this panel (defaults to false).  Note that the query will be executed within the scope of     * the container element only (so that multiple tab panels from markup can be supported via this method).</p>     * <p>This method is only possible when the markup is structured correctly as a container with nested     * divs containing the class 'x-tab'. To create TabPanels without these limitations, or to pull tab content from     * other elements on the page, see the example at the top of the class for generating tabs from markup.</p>     * <p>There are a couple of things to note when using this method:<ul>     * <li>When using the autoTabs config (as opposed to passing individual tab configs in the TabPanel's     * {@link #items} collection), you must use {@link #applyTo} to correctly use the specified id as the tab container.     * The autoTabs method <em>replaces</em> existing content with the TabPanel components.</li>     * <li>Make sure that you set {@link #deferredRender} to false so that the content elements for each tab will be     * rendered into the TabPanel immediately upon page load, otherwise they will not be transformed until each tab     * is activated and will be visible outside the TabPanel.</li>     * </ul>Example usage:</p>     * <pre><code>var tabs = new Ext.TabPanel({    applyTo: 'my-tabs',    activeTab: 0,    deferredRender: false,    autoTabs: true});// This markup will be converted to a TabPanel from the code above&lt;div id="my-tabs">    &lt;div class="x-tab" title="Tab 1">A simple tab&lt;/div>    &lt;div class="x-tab" title="Tab 2">Another one&lt;/div>&lt;/div></code></pre>     */    autoTabs : false,    /**     * @cfg {String} autoTabSelector The CSS selector used to search for tabs in existing markup when {@link #autoTabs}     * = true (defaults to 'div.x-tab').  This can be any valid selector supported by {@link Ext.DomQuery#select}.     * Note that the query will be executed within the scope of this tab panel only (so that multiple tab panels from     * markup can be supported on a page).     */    autoTabSelector:'div.x-tab',    /**     * @cfg {String/Number} activeTab A string id or the numeric index of the tab that should be initially     * activated on render (defaults to none).     */    activeTab : null,    /**     * @cfg {Number} tabMargin The number of pixels of space to calculate into the sizing and scrolling of tabs. If you     * change the margin in CSS, you will need to update this value so calculations are correct with either resizeTabs     * or scrolling tabs. (defaults to 2)     */    tabMargin : 2,    /**     * @cfg {Boolean} plain True to render the tab strip without a background container image (defaults to false).     */    plain: false,    /**     * @cfg {Number} wheelIncrement For scrolling tabs, the number of pixels to increment on mouse wheel scrolling (defaults to 20).     */    wheelIncrement : 20,    /*     * This is a protected property used when concatenating tab ids to the TabPanel id for internal uniqueness.     * It does not generally need to be changed, but can be if external code also uses an id scheme that can     * potentially clash with this one.     */    idDelimiter : '__',    // private    itemCls : 'x-tab-item',    // private config overrides    elements: 'body',    headerAsText: false,    frame: false,    hideBorders:true,    // private    initComponent : function(){        this.frame = false;        Ext.TabPanel.superclass.initComponent.call(this);        this.addEvents(            /**             * @event beforetabchange             * Fires before the active tab changes. Handlers can return false to cancel the tab change.             * @param {TabPanel} this             * @param {Panel} newTab The tab being activated             * @param {Panel} currentTab The current active tab             */            'beforetabchange',            /**             * @event tabchange             * Fires after the active tab has changed.             * @param {TabPanel} this             * @param {Panel} tab The new active tab             */            'tabchange',            /**             * @event contextmenu             * Fires when the original browser contextmenu event originated from a tab element.             * @param {TabPanel} this             * @param {Panel} tab The target tab             * @param {EventObject} e             */            'contextmenu'        );        this.setLayout(new Ext.layout.CardLayout({            deferredRender: this.deferredRender        }));        if(this.tabPosition == 'top'){            this.elements += ',header';            this.stripTarget = 'header';        }else {            this.elements += ',footer';            this.stripTarget = 'footer';        }        if(!this.stack){            this.stack = Ext.TabPanel.AccessStack();        }        this.initItems();    },    // private    render : function(){        Ext.TabPanel.superclass.render.apply(this, arguments);        if(this.activeTab !== undefined){            var item = this.activeTab;            delete this.activeTab;            this.setActiveTab(item);        }    },    // private    onRender : function(ct, position){        Ext.TabPanel.superclass.onRender.call(this, ct, position);        if(this.plain){            var pos = this.tabPosition == 'top' ? 'header' : 'footer';            this[pos].addClass('x-tab-panel-'+pos+'-plain');        }        var st = this[this.stripTarget];        this.stripWrap = st.createChild({cls:'x-tab-strip-wrap', cn:{            tag:'ul', cls:'x-tab-strip x-tab-strip-'+this.tabPosition}});        this.stripSpacer = st.createChild({cls:'x-tab-strip-spacer'});        this.strip = new Ext.Element(this.stripWrap.dom.firstChild);        this.edge = this.strip.createChild({tag:'li', cls:'x-tab-edge'});        this.strip.createChild({cls:'x-clear'});        this.body.addClass('x-tab-panel-body-'+this.tabPosition);        if(!this.itemTpl){            var tt = new Ext.Template(                 '<li class="{cls}" id="{id}"><a class="x-tab-strip-close" onclick="return false;"></a>',                 '<a class="x-tab-right" href="#" onclick="return false;"><em class="x-tab-left">',                 '<span class="x-tab-strip-inner"><span class="x-tab-strip-text {iconCls}">{text}</span></span>',                 '</em></a></li>'            );            tt.disableFormats = true;            tt.compile();            Ext.TabPanel.prototype.itemTpl = tt;        }        this.items.each(this.initTab, this);    },    // private    afterRender : function(){        Ext.TabPanel.superclass.afterRender.call(this);        if(this.autoTabs){            this.readTabs(false);        }    },    // private

⌨️ 快捷键说明

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