1 <!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-tab.Bar'>/**
2 </span> * @author Ed Spencer
4 * @extends Ext.panel.Header
5 * <p>TabBar is used internally by a {@link Ext.tab.Panel TabPanel} and wouldn't usually need to be created manually.</p>
9 Ext.define('Ext.tab.Bar', {
10 extend: 'Ext.panel.Header',
11 alias: 'widget.tabbar',
12 baseCls: Ext.baseCSSPrefix + 'tab-bar',
22 <span id='Ext-tab.Bar-cfg-Boolean'> /**
23 </span> * @cfg Boolean plain
24 * True to not show the full background on the tabbar
30 '<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>',
31 '<div class="{baseCls}-strip<tpl if="ui"> {baseCls}-strip-{ui}<tpl for="uiCls"> {parent.baseCls}-strip-{parent.ui}-{.}</tpl></tpl>"></div>'
34 <span id='Ext-tab.Bar-cfg-minTabWidth'> /**
35 </span> * @cfg {Number} minTabWidth The minimum width for each tab. Defaults to <tt>30</tt>.
39 <span id='Ext-tab.Bar-cfg-maxTabWidth'> /**
40 </span> * @cfg {Number} maxTabWidth The maximum width for each tab. Defaults to <tt>undefined</tt>.
42 maxTabWidth: undefined,
45 initComponent: function() {
50 me.setUI(me.ui + '-plain');
53 me.addClsWithUI(me.dock);
56 <span id='Ext-tab.Bar-event-change'> /**
57 </span> * @event change
58 * Fired when the currently-active tab has changed
59 * @param {Ext.tab.Bar} tabBar The TabBar
60 * @param {Ext.Tab} tab The new Tab
61 * @param {Ext.Component} card The card that was just shown in the TabPanel
66 Ext.applyIf(this.renderSelectors, {
67 body : '.' + this.baseCls + '-body',
68 strip: '.' + this.baseCls + '-strip'
70 me.callParent(arguments);
72 // TabBar must override the Header's align setting.
73 me.layout.align = (me.orientation == 'vertical') ? 'left' : 'top';
74 me.layout.overflowHandler = Ext.create('Ext.layout.container.boxOverflow.Scroller', me.layout);
75 me.items.removeAt(me.items.getCount() - 1);
76 me.items.removeAt(me.items.getCount() - 1);
78 // Subscribe to Ext.FocusManager for key navigation
79 keys = me.orientation == 'vertical' ? ['up', 'down'] : ['left', 'right'];
80 Ext.FocusManager.subscribe(me, {
86 onAdd: function(tab) {
88 tabPanel = me.tabPanel,
89 hasOwner = !!tabPanel;
91 me.callParent(arguments);
92 tab.position = me.dock;
94 tab.minWidth = tabPanel.minTabWidth;
97 tab.minWidth = me.minTabWidth + (tab.iconCls ? 25 : 0);
99 tab.maxWidth = me.maxTabWidth || (hasOwner ? tabPanel.maxTabWidth : undefined);
103 afterRender: function() {
109 delegate: '.' + Ext.baseCSSPrefix + 'tab'
111 me.callParent(arguments);
115 afterComponentLayout : function() {
118 me.callParent(arguments);
119 me.strip.setWidth(me.el.getWidth());
123 onClick: function(e, target) {
124 // The target might not be a valid tab el.
125 var tab = Ext.getCmp(target.id),
126 tabPanel = this.tabPanel;
128 target = e.getTarget();
130 if (tab && tab.isDisabled && !tab.isDisabled()) {
131 if (tab.closable && target === tab.closeEl.dom) {
134 this.setActiveTab(tab);
136 tabPanel.setActiveTab(tab.card);
143 <span id='Ext-tab.Bar-method-closeTab'> /**
145 * Closes the given tab by removing it from the TabBar and removing the corresponding card from the TabPanel
146 * @param {Ext.Tab} tab The tab to close
148 closeTab: function(tab) {
150 tabPanel = this.tabPanel,
153 if (tab.active && this.items.getCount() > 1) {
154 nextTab = tab.next('tab') || this.items.items[0];
155 this.setActiveTab(nextTab);
157 tabPanel.setActiveTab(nextTab.card);
162 if (tabPanel && card) {
163 tabPanel.remove(card);
171 <span id='Ext-tab.Bar-method-setActiveTab'> /**
173 * Marks the given tab as active
174 * @param {Ext.Tab} tab The tab to mark active
176 setActiveTab: function(tab) {
182 me.activeTab.deactivate();
188 tab.el.scrollIntoView(me.layout.getRenderTarget());
191 me.fireEvent('change', me, tab, tab.card);
193 });</pre></pre></body></html>