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>
26 Ext.define('Ext.tab.Bar', {
27 extend: 'Ext.panel.Header',
28 alias: 'widget.tabbar',
29 baseCls: Ext.baseCSSPrefix + 'tab-bar',
39 <span id='Ext-tab-Bar-cfg-Boolean'> /**
40 </span> * @cfg Boolean plain
41 * True to not show the full background on the tabbar
47 '<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>',
48 '<div class="{baseCls}-strip<tpl if="ui"> {baseCls}-strip-{ui}<tpl for="uiCls"> {parent.baseCls}-strip-{parent.ui}-{.}</tpl></tpl>"></div>'
51 <span id='Ext-tab-Bar-cfg-minTabWidth'> /**
52 </span> * @cfg {Number} minTabWidth The minimum width for each tab. Defaults to <tt>30</tt>.
56 <span id='Ext-tab-Bar-cfg-maxTabWidth'> /**
57 </span> * @cfg {Number} maxTabWidth The maximum width for each tab. Defaults to <tt>undefined</tt>.
59 maxTabWidth: undefined,
62 initComponent: function() {
67 me.setUI(me.ui + '-plain');
70 me.addClsWithUI(me.dock);
73 <span id='Ext-tab-Bar-event-change'> /**
74 </span> * @event change
75 * Fired when the currently-active tab has changed
76 * @param {Ext.tab.Bar} tabBar The TabBar
77 * @param {Ext.Tab} tab The new Tab
78 * @param {Ext.Component} card The card that was just shown in the TabPanel
83 Ext.applyIf(me.renderSelectors, {
84 body : '.' + me.baseCls + '-body',
85 strip: '.' + me.baseCls + '-strip'
87 me.callParent(arguments);
89 // TabBar must override the Header's align setting.
90 me.layout.align = (me.orientation == 'vertical') ? 'left' : 'top';
91 me.layout.overflowHandler = Ext.create('Ext.layout.container.boxOverflow.Scroller', me.layout);
92 me.items.removeAt(me.items.getCount() - 1);
93 me.items.removeAt(me.items.getCount() - 1);
95 // Subscribe to Ext.FocusManager for key navigation
96 keys = me.orientation == 'vertical' ? ['up', 'down'] : ['left', 'right'];
97 Ext.FocusManager.subscribe(me, {
103 onAdd: function(tab) {
105 tabPanel = me.tabPanel,
106 hasOwner = !!tabPanel;
108 me.callParent(arguments);
109 tab.position = me.dock;
111 tab.minWidth = tabPanel.minTabWidth;
114 tab.minWidth = me.minTabWidth + (tab.iconCls ? 25 : 0);
116 tab.maxWidth = me.maxTabWidth || (hasOwner ? tabPanel.maxTabWidth : undefined);
120 afterRender: function() {
126 delegate: '.' + Ext.baseCSSPrefix + 'tab'
128 me.callParent(arguments);
132 afterComponentLayout : function() {
135 me.callParent(arguments);
136 me.strip.setWidth(me.el.getWidth());
140 onClick: function(e, target) {
141 // The target might not be a valid tab el.
142 var tab = Ext.getCmp(target.id),
143 tabPanel = this.tabPanel,
146 target = e.getTarget();
148 if (tab && tab.isDisabled && !tab.isDisabled()) {
149 if (tab.closable && target === tab.closeEl.dom) {
153 // TabPanel will card setActiveTab of the TabBar
154 tabPanel.setActiveTab(tab.card);
156 this.setActiveTab(tab);
163 <span id='Ext-tab-Bar-method-closeTab'> /**
165 * Closes the given tab by removing it from the TabBar and removing the corresponding card from the TabPanel
166 * @param {Ext.Tab} tab The tab to close
168 closeTab: function(tab) {
171 tabPanel = me.tabPanel,
174 if (card && card.fireEvent('beforeclose', card) === false) {
178 if (tab.active && me.items.getCount() > 1) {
179 nextTab = tab.next('tab') || me.items.items[0];
180 me.setActiveTab(nextTab);
182 tabPanel.setActiveTab(nextTab.card);
186 * force the close event to fire. By the time this function returns,
187 * the tab is already destroyed and all listeners have been purged
188 * so the tab can't fire itself.
193 if (tabPanel && card) {
194 card.fireEvent('close', card);
195 tabPanel.remove(card);
203 <span id='Ext-tab-Bar-method-setActiveTab'> /**
205 * Marks the given tab as active
206 * @param {Ext.Tab} tab The tab to mark active
208 setActiveTab: function(tab) {
214 me.activeTab.deactivate();
220 tab.el.scrollIntoView(me.layout.getRenderTarget());
223 me.fireEvent('change', me, tab, tab.card);