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.2.1
11 * Copyright(c) 2006-2010 Ext JS, Inc.
13 * http://www.extjs.com/license
17 Ext.ux.Tabs = Ext.extend(Ext.util.Observable, {
18 // Configuration options
21 // Our class constructor
22 constructor : function(element, config) {
23 Ext.apply(this, config);
24 Ext.ux.Tabs.superclass.constructor.call(this);
31 this.el = Ext.get(element);
38 this.el.addClass('ux-tabs-container');
40 this.tabStrip = this.el.child('ul');
41 this.tabStrip.addClass('ux-tabs-strip');
43 this.tabStrip.on('click', this.onStripClick, this, {delegate: 'a'});
45 this.tabs = this.tabStrip.select('> li');
46 this.cards = this.el.select('> div');
48 this.cardsContainer = this.el.createChild({
51 this.cardsContainer.setWidth(this.el.getWidth());
53 this.cards.addClass('ux-tabs-card');
54 this.cards.appendTo(this.cardsContainer);
57 cls: 'ux-tabs-clearfix'
60 this.setActiveTab(this.activeTab || 0);
63 onStripClick : function(ev, t) {
64 if(t && t.href && t.href.indexOf('#')) {
66 this.setActiveTab(t.href.split('#')[1]);
70 setActiveTab : function(tab) {
72 if(Ext.isString(tab)) {
74 tab = this.tabStrip.child('a[href=#' + tab + ']').parent();
76 else if (Ext.isNumber(tab)) {
77 tab = this.tabs.item(tab);
78 card = Ext.get(tab.first().dom.href.split('#')[1]);
81 if(tab && card && this.fireEvent('beforetabchange', tab, card) !== false) {
82 card.radioClass('ux-tabs-card-active');
83 tab.radioClass('ux-tabs-tab-active');
84 this.fireEvent('tabchange', tab, card);