3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.3.1
11 * Copyright(c) 2006-2010 Sencha Inc.
12 * licensing@sencha.com
13 * http://www.sencha.com/license
15 Ext.ux.GroupTab = Ext.extend(Ext.Container, {
32 initComponent: function(config){
33 Ext.apply(this, config);
36 Ext.ux.GroupTab.superclass.initComponent.call(this);
38 this.addEvents('activate', 'deactivate', 'changemainitem', 'beforetabchange', 'tabchange');
40 this.setLayout(new Ext.layout.CardLayout({
41 deferredRender: this.deferredRender
45 this.stack = Ext.TabPanel.AccessStack();
50 this.on('beforerender', function(){
51 this.groupEl = this.ownerCt.getGroupEl(this);
54 this.on('add', this.onAdd, this, {
57 this.on('remove', this.onRemove, this, {
61 if (this.mainItem !== undefined) {
62 var item = (typeof this.mainItem == 'object') ? this.mainItem : this.items.get(this.mainItem);
64 this.setMainItem(item);
68 <div id="method-Ext.ux.tree.ColumnNodeUI-setActiveTab"></div>/**
69 * Sets the specified tab as the active tab. This method fires the {@link #beforetabchange} event which
70 * can return false to cancel the tab change.
71 * @param {String/Panel} tab The id or tab Panel to activate
73 setActiveTab : function(item){
74 item = this.getComponent(item);
79 this.activeTab = item;
82 if(this.activeTab != item && this.fireEvent('beforetabchange', this, item, this.activeTab) !== false){
83 if(this.activeTab && this.activeTab != this.mainItem){
84 var oldEl = this.getTabEl(this.activeTab);
86 Ext.fly(oldEl).removeClass('x-grouptabs-strip-active');
89 var el = this.getTabEl(item);
90 Ext.fly(el).addClass('x-grouptabs-strip-active');
91 this.activeTab = item;
94 this.layout.setActiveItem(item);
95 if(this.layoutOnTabChange && item.doLayout){
99 this.scrollToTab(item, this.animScroll);
102 this.fireEvent('tabchange', this, item);
108 getTabEl: function(item){
109 if (item == this.mainItem) {
112 return Ext.TabPanel.prototype.getTabEl.call(this, item);
115 onRender: function(ct, position){
116 Ext.ux.GroupTab.superclass.onRender.call(this, ct, position);
118 this.strip = Ext.fly(this.groupEl).createChild({
120 cls: 'x-grouptabs-sub'
123 this.tooltip = new Ext.ToolTip({
124 target: this.groupEl,
125 delegate: 'a.x-grouptabs-text',
127 renderTo: document.body,
129 beforeshow: function(tip) {
130 var item = (tip.triggerElement.parentNode === this.mainItem.tabEl)
132 : this.findById(tip.triggerElement.parentNode.id.split(this.idDelimiter)[1]);
137 tip.body.dom.innerHTML = item.tabTip;
144 var tt = new Ext.Template('<li class="{cls}" id="{id}">', '<a onclick="return false;" class="x-grouptabs-text {iconCls}">{text}</a>', '</li>');
145 tt.disableFormats = true;
147 Ext.ux.GroupTab.prototype.itemTpl = tt;
150 this.items.each(this.initTab, this);
153 afterRender: function(){
154 Ext.ux.GroupTab.superclass.afterRender.call(this);
156 if (this.activeTab !== undefined) {
157 var item = (typeof this.activeTab == 'object') ? this.activeTab : this.items.get(this.activeTab);
158 delete this.activeTab;
159 this.setActiveTab(item);
164 initTab: function(item, index){
165 var before = this.strip.dom.childNodes[index];
166 var p = Ext.TabPanel.prototype.getTemplateArgs.call(this, item);
168 if (item === this.mainItem) {
169 item.tabEl = this.groupEl;
170 p.cls += ' x-grouptabs-main-item';
173 var el = before ? this.itemTpl.insertBefore(before, p) : this.itemTpl.append(this.strip, p);
175 item.tabEl = item.tabEl || el;
177 item.on('disable', this.onItemDisabled, this);
178 item.on('enable', this.onItemEnabled, this);
179 item.on('titlechange', this.onItemTitleChanged, this);
180 item.on('iconchange', this.onItemIconChanged, this);
181 item.on('beforeshow', this.onBeforeShowItem, this);
184 setMainItem: function(item){
185 item = this.getComponent(item);
186 if (!item || this.fireEvent('changemainitem', this, item, this.mainItem) === false) {
190 this.mainItem = item;
193 getMainItem: function(){
194 return this.mainItem || null;
198 onBeforeShowItem: function(item){
199 if (item != this.activeTab) {
200 this.setActiveTab(item);
206 onAdd: function(gt, item, index){
208 this.initTab.call(this, item, index);
213 onRemove: function(tp, item){
214 Ext.destroy(Ext.get(this.getTabEl(item)));
215 this.stack.remove(item);
216 item.un('disable', this.onItemDisabled, this);
217 item.un('enable', this.onItemEnabled, this);
218 item.un('titlechange', this.onItemTitleChanged, this);
219 item.un('iconchange', this.onItemIconChanged, this);
220 item.un('beforeshow', this.onBeforeShowItem, this);
221 if (item == this.activeTab) {
222 var next = this.stack.next();
224 this.setActiveTab(next);
226 else if (this.items.getCount() > 0) {
227 this.setActiveTab(0);
230 this.activeTab = null;
236 onBeforeAdd: function(item){
237 var existing = item.events ? (this.items.containsKey(item.getItemId()) ? item : null) : this.items.get(item);
239 this.setActiveTab(item);
242 Ext.TabPanel.superclass.onBeforeAdd.apply(this, arguments);
243 var es = item.elements;
244 item.elements = es ? es.replace(',header', '') : es;
245 item.border = (item.border === true);
249 onItemDisabled: Ext.TabPanel.prototype.onItemDisabled,
250 onItemEnabled: Ext.TabPanel.prototype.onItemEnabled,
253 onItemTitleChanged: function(item){
254 var el = this.getTabEl(item);
256 Ext.fly(el).child('a.x-grouptabs-text', true).innerHTML = item.title;
261 onItemIconChanged: function(item, iconCls, oldCls){
262 var el = this.getTabEl(item);
264 Ext.fly(el).child('a.x-grouptabs-text').replaceClass(oldCls, iconCls);
268 beforeDestroy: function(){
269 Ext.TabPanel.prototype.beforeDestroy.call(this);
270 this.tooltip.destroy();
274 Ext.reg('grouptab', Ext.ux.GroupTab);