7 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
10 * @class Roo.bootstrap.dash.TabBox
11 * @extends Roo.bootstrap.Component
12 * Bootstrap TabBox class
13 * @cfg {String} title Title of the TabBox
14 * @cfg {String} icon Icon of the TabBox
15 * @cfg {Boolean} showtabs (true|false) show the tabs default true
16 * @cfg {Boolean} tabScrollable (true|false) tab scrollable when mobile view default false
20 * @param {Object} config The config object
24 Roo.bootstrap.dash.TabBox = function(config){
25 Roo.bootstrap.dash.TabBox.superclass.constructor.call(this, config);
30 * When a pane is added
31 * @param {Roo.bootstrap.dash.TabPane} pane
36 * When a pane is activated
37 * @param {Roo.bootstrap.dash.TabPane} pane
47 Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component, {
52 tabScrollable : false,
54 getChildContainer : function()
56 return this.el.select('.tab-content', true).first();
59 getAutoCreate : function(){
63 cls: 'pull-left header',
71 cls: 'fa ' + this.icon
77 cls: 'nav nav-tabs pull-right',
83 if(this.tabScrollable){
95 cls: 'nav-tabs-custom',
100 cls: 'tab-content no-padding',
108 initEvents : function()
110 //Roo.log('add add pane handler');
111 this.on('addpane', this.onAddPane, this);
114 * Updates the box title
115 * @param {String} html to set the title to.
117 setTitle : function(value)
119 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
121 onAddPane : function(pane)
123 this.panes.push(pane);
124 //Roo.log('addpane');
126 // tabs are rendere left to right..
131 var ctr = this.el.select('.nav-tabs', true).first();
134 var existing = ctr.select('.nav-tab',true);
135 var qty = existing.getCount();;
138 var tab = ctr.createChild({
140 cls : 'nav-tab' + (qty ? '' : ' active'),
148 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
151 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
153 pane.el.addClass('active');
158 onTabClick : function(ev,un,ob,pane)
160 //Roo.log('tab - prev default');
164 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
165 pane.tab.addClass('active');
166 //Roo.log(pane.title);
167 this.getChildContainer().select('.tab-pane',true).removeClass('active');
168 // technically we should have a deactivate event.. but maybe add later.
169 // and it should not de-activate the selected tab...
170 this.fireEvent('activatepane', pane);
171 pane.el.addClass('active');
172 pane.fireEvent('activate');
177 getActivePane : function()
180 Roo.each(this.panes, function(p) {
181 if(p.el.hasClass('active')){