4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-tab-Bar'>/**
19 </span> * @author Ed Spencer
21 * @extends Ext.panel.Header
22 * <p>TabBar is used internally by a {@link Ext.tab.Panel TabPanel} and wouldn't usually need to be created manually.</p>
24 Ext.define('Ext.tab.Bar', {
25 extend: 'Ext.panel.Header',
26 alias: 'widget.tabbar',
27 baseCls: Ext.baseCSSPrefix + 'tab-bar',
37 <span id='Ext-tab-Bar-cfg-Boolean'> /**
38 </span> * @cfg Boolean plain
39 * True to not show the full background on the tabbar
45 '<div class="{baseCls}-body<tpl if="ui"> {baseCls}-body-{ui}<tpl for="uiCls"> {parent.baseCls}-body-{parent.ui}-{.}</tpl></tpl>"<tpl if="bodyStyle"> style="{bodyStyle}"</tpl>></div>',
46 '<div class="{baseCls}-strip<tpl if="ui"> {baseCls}-strip-{ui}<tpl for="uiCls"> {parent.baseCls}-strip-{parent.ui}-{.}</tpl></tpl>"></div>'
49 <span id='Ext-tab-Bar-cfg-minTabWidth'> /**
50 </span> * @cfg {Number} minTabWidth The minimum width for each tab. Defaults to <tt>30</tt>.
54 <span id='Ext-tab-Bar-cfg-maxTabWidth'> /**
55 </span> * @cfg {Number} maxTabWidth The maximum width for each tab. Defaults to <tt>undefined</tt>.
57 maxTabWidth: undefined,
60 initComponent: function() {
65 me.setUI(me.ui + '-plain');
68 me.addClsWithUI(me.dock);
71 <span id='Ext-tab-Bar-event-change'> /**
72 </span> * @event change
73 * Fired when the currently-active tab has changed
74 * @param {Ext.tab.Bar} tabBar The TabBar
75 * @param {Ext.Tab} tab The new Tab
76 * @param {Ext.Component} card The card that was just shown in the TabPanel
81 Ext.applyIf(me.renderSelectors, {
82 body : '.' + me.baseCls + '-body',
83 strip: '.' + me.baseCls + '-strip'
85 me.callParent(arguments);
87 // TabBar must override the Header's align setting.
88 me.layout.align = (me.orientation == 'vertical') ? 'left' : 'top';
89 me.layout.overflowHandler = Ext.create('Ext.layout.container.boxOverflow.Scroller', me.layout);
90 me.items.removeAt(me.items.getCount() - 1);
91 me.items.removeAt(me.items.getCount() - 1);
93 // Subscribe to Ext.FocusManager for key navigation
94 keys = me.orientation == 'vertical' ? ['up', 'down'] : ['left', 'right'];
95 Ext.FocusManager.subscribe(me, {
101 onAdd: function(tab) {
103 tabPanel = me.tabPanel,
104 hasOwner = !!tabPanel;
106 me.callParent(arguments);
107 tab.position = me.dock;
109 tab.minWidth = tabPanel.minTabWidth;
112 tab.minWidth = me.minTabWidth + (tab.iconCls ? 25 : 0);
114 tab.maxWidth = me.maxTabWidth || (hasOwner ? tabPanel.maxTabWidth : undefined);
118 afterRender: function() {
124 delegate: '.' + Ext.baseCSSPrefix + 'tab'
126 me.callParent(arguments);
130 afterComponentLayout : function() {
133 me.callParent(arguments);
134 me.strip.setWidth(me.el.getWidth());
138 onClick: function(e, target) {
139 // The target might not be a valid tab el.
140 var tab = Ext.getCmp(target.id),
141 tabPanel = this.tabPanel,
144 target = e.getTarget();
146 if (tab && tab.isDisabled && !tab.isDisabled()) {
147 if (tab.closable && target === tab.closeEl.dom) {
151 // TabPanel will card setActiveTab of the TabBar
152 tabPanel.setActiveTab(tab.card);
154 this.setActiveTab(tab);
161 <span id='Ext-tab-Bar-method-closeTab'> /**
163 * Closes the given tab by removing it from the TabBar and removing the corresponding card from the TabPanel
164 * @param {Ext.Tab} tab The tab to close
166 closeTab: function(tab) {
169 tabPanel = me.tabPanel,
172 if (card && card.fireEvent('beforeclose', card) === false) {
176 if (tab.active && me.items.getCount() > 1) {
177 nextTab = tab.next('tab') || me.items.items[0];
178 me.setActiveTab(nextTab);
180 tabPanel.setActiveTab(nextTab.card);
184 * force the close event to fire. By the time this function returns,
185 * the tab is already destroyed and all listeners have been purged
186 * so the tab can't fire itself.
191 if (tabPanel && card) {
192 card.fireEvent('close', card);
193 tabPanel.remove(card);
201 <span id='Ext-tab-Bar-method-setActiveTab'> /**
203 * Marks the given tab as active
204 * @param {Ext.Tab} tab The tab to mark active
206 setActiveTab: function(tab) {
212 me.activeTab.deactivate();
218 tab.el.scrollIntoView(me.layout.getRenderTarget());
221 me.fireEvent('change', me, tab, tab.card);