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
17 * @cfg {String} weight (primary|success|info|warning|danger) default false
21 * @param {Object} config The config object
25 Roo.bootstrap.dash.TabBox = function(config){
26 Roo.bootstrap.dash.TabBox.superclass.constructor.call(this, config);
31 * When a pane is added
32 * @param {Roo.bootstrap.dash.TabPane} pane
37 * When a pane is activated
38 * @param {Roo.bootstrap.dash.TabPane} pane
48 Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component, {
53 tabScrollable : false,
56 getChildContainer : function()
58 return this.el.select('.tab-content', true).first();
61 getAutoCreate : function(){
65 cls: 'pull-left header',
73 cls: 'fa ' + this.icon
79 cls: 'nav nav-tabs pull-right',
85 if(this.tabScrollable){
92 cls: 'nav nav-tabs pull-right',
103 cls: 'nav-tabs-custom',
108 cls: 'tab-content no-padding',
116 initEvents : function()
118 //Roo.log('add add pane handler');
119 this.on('addpane', this.onAddPane, this);
122 * Updates the box title
123 * @param {String} html to set the title to.
125 setTitle : function(value)
127 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
129 onAddPane : function(pane)
131 this.panes.push(pane);
132 //Roo.log('addpane');
134 // tabs are rendere left to right..
139 var ctr = this.el.select('.nav-tabs', true).first();
142 var existing = ctr.select('.nav-tab',true);
143 var qty = existing.getCount();;
146 var tab = ctr.createChild({
148 cls : 'nav-tab' + (qty ? '' : ' active'),
156 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
159 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
161 pane.el.addClass('active');
166 onTabClick : function(ev,un,ob,pane)
168 //Roo.log('tab - prev default');
172 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
173 pane.tab.addClass('active');
174 //Roo.log(pane.title);
175 this.getChildContainer().select('.tab-pane',true).removeClass('active');
176 // technically we should have a deactivate event.. but maybe add later.
177 // and it should not de-activate the selected tab...
178 this.fireEvent('activatepane', pane);
179 pane.el.addClass('active');
180 pane.fireEvent('activate');
185 getActivePane : function()
188 Roo.each(this.panes, function(p) {
189 if(p.el.hasClass('active')){