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){
90 cls: 'nav nav-tabs pull-right',
101 cls: 'nav-tabs-custom',
106 cls: 'tab-content no-padding',
114 initEvents : function()
116 //Roo.log('add add pane handler');
117 this.on('addpane', this.onAddPane, this);
120 * Updates the box title
121 * @param {String} html to set the title to.
123 setTitle : function(value)
125 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
127 onAddPane : function(pane)
129 this.panes.push(pane);
130 //Roo.log('addpane');
132 // tabs are rendere left to right..
137 var ctr = this.el.select('.nav-tabs', true).first();
140 var existing = ctr.select('.nav-tab',true);
141 var qty = existing.getCount();;
144 var tab = ctr.createChild({
146 cls : 'nav-tab' + (qty ? '' : ' active'),
154 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
157 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
159 pane.el.addClass('active');
164 onTabClick : function(ev,un,ob,pane)
166 //Roo.log('tab - prev default');
170 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
171 pane.tab.addClass('active');
172 //Roo.log(pane.title);
173 this.getChildContainer().select('.tab-pane',true).removeClass('active');
174 // technically we should have a deactivate event.. but maybe add later.
175 // and it should not de-activate the selected tab...
176 this.fireEvent('activatepane', pane);
177 pane.el.addClass('active');
178 pane.fireEvent('activate');
183 getActivePane : function()
186 Roo.each(this.panes, function(p) {
187 if(p.el.hasClass('active')){