9 * @class Roo.bootstrap.NavGroup
10 * @extends Roo.bootstrap.Component
11 * Bootstrap NavGroup class
12 * @cfg {String} align left | right
13 * @cfg {Boolean} inverse false | true
14 * @cfg {String} type (nav|pills|tab) default nav
15 * @cfg {String} navId - reference Id for navbar.
19 * Create a new nav group
20 * @param {Object} config The config object
23 Roo.bootstrap.NavGroup = function(config){
24 Roo.bootstrap.NavGroup.superclass.constructor.call(this, config);
26 Roo.bootstrap.NavGroup.register(this);
30 * Fires when the active item changes
31 * @param {Roo.bootstrap.NavGroup} this
32 * @param {Roo.bootstrap.Navbar.Item} item The item selected
33 * @param {Roo.bootstrap.Navbar.Item} item The previously selected item
40 Roo.extend(Roo.bootstrap.NavGroup, Roo.bootstrap.Component, {
51 getAutoCreate : function()
53 var cfg = Roo.apply({}, Roo.bootstrap.NavGroup.superclass.getAutoCreate.call(this));
60 if (['tabs','pills'].indexOf(this.type)!==-1) {
61 cfg.cls += ' nav-' + this.type
63 if (this.type!=='nav') {
64 Roo.log('nav type must be nav/tabs/pills')
66 cfg.cls += ' navbar-nav'
69 if (this.parent().sidebar) {
72 cls: 'dashboard-menu sidebar-menu'
78 if (this.form === true) {
84 if (this.align === 'right') {
85 cfg.cls += ' navbar-right';
87 cfg.cls += ' navbar-left';
91 if (this.align === 'right') {
92 cfg.cls += ' navbar-right';
96 cfg.cls += ' navbar-inverse';
104 setActiveItem : function(item)
107 Roo.each(this.navItems, function(v){
112 v.setActive(false, true);
119 item.setActive(true, true);
120 this.fireEvent('changed', this, item, prev);
125 getActive : function()
129 Roo.each(this.navItems, function(v){
141 addItem : function(cfg)
143 var cn = new Roo.bootstrap.NavItem(cfg);
145 cn.parentId = this.id;
146 cn.onRender(this.el, null);
150 register : function(item)
152 this.navItems.push( item);
153 item.navId = this.navId;
156 registerTab : function(item)
158 this.tabs.push(item);
162 getNavItem: function(tabId)
165 Roo.each(this.navItems, function(e) {
166 if (e.tabId == tabId) {
182 Roo.apply(Roo.bootstrap.NavGroup, {
186 register : function(navgrp)
188 this.groups[navgrp.navId] = navgrp;
191 get: function(navId) {
192 if (typeof(this.groups[navId]) == 'undefined') {
193 this.register(new Roo.bootstrap.NavGroup({ navId : navId }));
195 return this.groups[navId] ;