3 * Copyright(c) 2006-2010 Ext JS, Inc.
5 * http://www.extjs.com/license
9 Ext.ux.Tabs = Ext.extend(Ext.util.Observable, {
10 // Configuration options
13 // Our class constructor
14 constructor : function(element, config) {
15 Ext.apply(this, config);
16 Ext.ux.Tabs.superclass.constructor.call(this);
23 this.el = Ext.get(element);
30 this.el.addClass('ux-tabs-container');
32 this.tabStrip = this.el.child('ul');
33 this.tabStrip.addClass('ux-tabs-strip');
35 this.tabStrip.on('click', this.onStripClick, this, {delegate: 'a'});
37 this.tabs = this.tabStrip.select('> li');
38 this.cards = this.el.select('> div');
40 this.cardsContainer = this.el.createChild({
43 this.cardsContainer.setWidth(this.el.getWidth());
45 this.cards.addClass('ux-tabs-card');
46 this.cards.appendTo(this.cardsContainer);
49 cls: 'ux-tabs-clearfix'
52 this.setActiveTab(this.activeTab || 0);
55 onStripClick : function(ev, t) {
56 if(t && t.href && t.href.indexOf('#')) {
58 this.setActiveTab(t.href.split('#')[1]);
62 setActiveTab : function(tab) {
64 if(Ext.isString(tab)) {
66 tab = this.tabStrip.child('a[href=#' + tab + ']').parent();
68 else if (Ext.isNumber(tab)) {
69 tab = this.tabs.item(tab);
70 card = Ext.get(tab.first().dom.href.split('#')[1]);
73 if(tab && card && this.fireEvent('beforetabchange', tab, card) !== false) {
74 card.radioClass('ux-tabs-card-active');
75 tab.radioClass('ux-tabs-tab-active');
76 this.fireEvent('tabchange', tab, card);