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);
27 Roo.bootstrap.NavGroup.register(this);
31 * Fires when the active item changes
32 * @param {Roo.bootstrap.NavGroup} this
33 * @param {Roo.bootstrap.Navbar.Item} selected The item selected
34 * @param {Roo.bootstrap.Navbar.Item} prev The previously selected item
41 Roo.extend(Roo.bootstrap.NavGroup, Roo.bootstrap.Component, {
52 getAutoCreate : function()
54 var cfg = Roo.apply({}, Roo.bootstrap.NavGroup.superclass.getAutoCreate.call(this));
61 if (['tabs','pills'].indexOf(this.type)!==-1) {
62 cfg.cls += ' nav-' + this.type
64 if (this.type!=='nav') {
65 Roo.log('nav type must be nav/tabs/pills')
67 cfg.cls += ' navbar-nav'
70 if (this.parent().sidebar) {
73 cls: 'dashboard-menu sidebar-menu'
79 if (this.form === true) {
85 if (this.align === 'right') {
86 cfg.cls += ' navbar-right';
88 cfg.cls += ' navbar-left';
92 if (this.align === 'right') {
93 cfg.cls += ' navbar-right';
97 cfg.cls += ' navbar-inverse';
105 * sets the active Navigation item
106 * @param {Roo.bootstrap.NavItem} the new current navitem
108 setActiveItem : function(item)
111 Roo.each(this.navItems, function(v){
116 v.setActive(false, true);
123 item.setActive(true, true);
124 this.fireEvent('changed', this, item, prev);
129 * gets the active Navigation item
130 * @return {Roo.bootstrap.NavItem} the current navitem
132 getActive : function()
136 Roo.each(this.navItems, function(v){
147 indexOfNav : function()
151 Roo.each(this.navItems, function(v,i){
162 * adds a Navigation item
163 * @param {Roo.bootstrap.NavItem} the navitem to add
165 addItem : function(cfg)
167 var cn = new Roo.bootstrap.NavItem(cfg);
169 cn.parentId = this.id;
170 cn.onRender(this.el, null);
174 * register a Navigation item
175 * @param {Roo.bootstrap.NavItem} the navitem to add
177 register : function(item)
179 this.navItems.push( item);
180 item.navId = this.navId;
185 * clear all the Navigation item
188 clearAll : function()
193 getNavItem: function(tabId)
196 Roo.each(this.navItems, function(e) {
197 if (e.tabId == tabId) {
207 setActiveNext : function()
209 var i = this.indexOfNav(this.getActive());
210 if (i > this.navItems.length) {
213 this.setActiveItem(this.navItems[i+1]);
215 setActivePrev : function()
217 var i = this.indexOfNav(this.getActive());
221 this.setActiveItem(this.navItems[i-1]);
223 clearWasActive : function(except) {
224 Roo.each(this.navItems, function(e) {
225 if (e.tabId != except.tabId && e.was_active) {
226 e.was_active = false;
233 getWasActive : function ()
236 Roo.each(this.navItems, function(e) {
251 Roo.apply(Roo.bootstrap.NavGroup, {
255 * register a Navigation Group
256 * @param {Roo.bootstrap.NavGroup} the navgroup to add
258 register : function(navgrp)
260 this.groups[navgrp.navId] = navgrp;
264 * fetch a Navigation Group based on the navigation ID
265 * @param {string} the navgroup to add
266 * @returns {Roo.bootstrap.NavGroup} the navgroup
268 get: function(navId) {
269 if (typeof(this.groups[navId]) == 'undefined') {
271 //this.register(new Roo.bootstrap.NavGroup({ navId : navId }));
273 return this.groups[navId] ;