4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../resources/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
20 * TabBar is used internally by a {@link Ext.tab.Panel TabPanel} and typically should not need to be created manually.
21 * The tab bar automatically removes the default title provided by {@link Ext.panel.Header}
23 Ext.define('Ext.tab.Bar', {
24 extend: 'Ext.panel.Header',
25 alias: 'widget.tabbar',
26 baseCls: Ext.baseCSSPrefix + 'tab-bar',
35 <span id='Ext-tab-Bar-cfg-title'> /**
36 </span> * @cfg {String} title @hide
39 <span id='Ext-tab-Bar-cfg-iconCls'> /**
40 </span> * @cfg {String} iconCls @hide
46 <span id='Ext-tab-Bar-cfg-plain'> /**
47 </span> * @cfg {Boolean} plain
48 * True to not show the full background on the tabbar
54 '<div id="{id}-body" class="{baseCls}-body <tpl if="bodyCls"> {bodyCls}</tpl> <tpl if="ui"> {baseCls}-body-{ui}<tpl for="uiCls"> {parent.baseCls}-body-{parent.ui}-{.}</tpl></tpl>"<tpl if="bodyStyle"> style="{bodyStyle}"</tpl>></div>',
55 '<div id="{id}-strip" class="{baseCls}-strip<tpl if="ui"> {baseCls}-strip-{ui}<tpl for="uiCls"> {parent.baseCls}-strip-{parent.ui}-{.}</tpl></tpl>"></div>'
58 <span id='Ext-tab-Bar-cfg-minTabWidth'> /**
59 </span> * @cfg {Number} minTabWidth
60 * The minimum width for a tab in this tab Bar. Defaults to the tab Panel's {@link Ext.tab.Panel#minTabWidth minTabWidth} value.
61 * @deprecated This config is deprecated. It is much easier to use the {@link Ext.tab.Panel#minTabWidth minTabWidth} config on the TabPanel.
64 <span id='Ext-tab-Bar-cfg-maxTabWidth'> /**
65 </span> * @cfg {Number} maxTabWidth
66 * The maximum width for a tab in this tab Bar. Defaults to the tab Panel's {@link Ext.tab.Panel#maxTabWidth maxTabWidth} value.
67 * @deprecated This config is deprecated. It is much easier to use the {@link Ext.tab.Panel#maxTabWidth maxTabWidth} config on the TabPanel.
71 initComponent: function() {
76 me.setUI(me.ui + '-plain');
79 me.addClsWithUI(me.dock);
82 <span id='Ext-tab-Bar-event-change'> /**
83 </span> * @event change
84 * Fired when the currently-active tab has changed
85 * @param {Ext.tab.Bar} tabBar The TabBar
86 * @param {Ext.tab.Tab} tab The new Tab
87 * @param {Ext.Component} card The card that was just shown in the TabPanel
92 me.addChildEls('body', 'strip');
93 me.callParent(arguments);
95 // TabBar must override the Header's align setting.
96 me.layout.align = (me.orientation == 'vertical') ? 'left' : 'top';
97 me.layout.overflowHandler = Ext.create('Ext.layout.container.boxOverflow.Scroller', me.layout);
99 me.remove(me.titleCmp);
102 // Subscribe to Ext.FocusManager for key navigation
103 keys = me.orientation == 'vertical' ? ['up', 'down'] : ['left', 'right'];
104 Ext.FocusManager.subscribe(me, {
108 Ext.apply(me.renderData, {
114 onAdd: function(tab) {
115 tab.position = this.dock;
116 this.callParent(arguments);
119 onRemove: function(tab) {
122 if (tab === me.previousTab) {
123 me.previousTab = null;
125 if (me.items.getCount() === 0) {
128 me.callParent(arguments);
132 afterRender: function() {
138 delegate: '.' + Ext.baseCSSPrefix + 'tab'
140 me.callParent(arguments);
144 afterComponentLayout : function() {
147 me.callParent(arguments);
148 me.strip.setWidth(me.el.getWidth());
152 onClick: function(e, target) {
153 // The target might not be a valid tab el.
154 var tab = Ext.getCmp(target.id),
155 tabPanel = this.tabPanel;
157 target = e.getTarget();
159 if (tab && tab.isDisabled && !tab.isDisabled()) {
160 if (tab.closable && target === tab.closeEl.dom) {
164 // TabPanel will card setActiveTab of the TabBar
165 tabPanel.setActiveTab(tab.card);
167 this.setActiveTab(tab);
174 <span id='Ext-tab-Bar-method-closeTab'> /**
176 * Closes the given tab by removing it from the TabBar and removing the corresponding card from the TabPanel
177 * @param {Ext.tab.Tab} tab The tab to close
179 closeTab: function(tab) {
182 tabPanel = me.tabPanel,
185 if (card && card.fireEvent('beforeclose', card) === false) {
189 if (tab.active && me.items.getCount() > 1) {
190 nextTab = me.previousTab || tab.next('tab') || me.items.first();
191 me.setActiveTab(nextTab);
193 tabPanel.setActiveTab(nextTab.card);
197 * force the close event to fire. By the time this function returns,
198 * the tab is already destroyed and all listeners have been purged
199 * so the tab can't fire itself.
204 if (tabPanel && card) {
205 card.fireEvent('close', card);
206 tabPanel.remove(card);
214 <span id='Ext-tab-Bar-method-setActiveTab'> /**
216 * Marks the given tab as active
217 * @param {Ext.tab.Tab} tab The tab to mark active
219 setActiveTab: function(tab) {
225 me.previousTab = me.activeTab;
226 me.activeTab.deactivate();
232 tab.el && tab.el.scrollIntoView(me.layout.getRenderTarget());
235 me.fireEvent('change', me, tab, tab.card);