9 * @class Roo.bootstrap.NavSidebarItem
10 * @extends Roo.bootstrap.Component
11 * Bootstrap Navbar.NavSidebarItem class
12 * @cfg {String} href link to
13 * @cfg {String} html content of button
14 * @cfg {String} badge text inside badge
15 * @cfg {String} glyphicon name of glyphicon
16 * @cfg {String} icon name of font awesome icon
17 * @cfg {Boolean} active Is item active
18 * @cfg {Boolean} preventDefault (true | false) default false
19 * @cfg {String} tabId the tab that this item activates.
22 * Create a new Navbar Button
23 * @param {Object} config The config object
25 Roo.bootstrap.NavItem = function(config){
26 Roo.bootstrap.NavItem.superclass.constructor.call(this, config);
31 * The raw click event for the entire grid.
32 * @param {Roo.EventObject} e
37 * Fires when the active item active state changes
38 * @param {Roo.bootstrap.Navbar.Item} this
39 * @param {boolean} state the new state
47 Roo.extend(Roo.bootstrap.NavSidebarItem, Roo.bootstrap.NavItem, {
55 preventDefault : false,
58 getAutoCreate : function(){
60 var cfg = Roo.apply({}, Roo.bootstrap.Navbar.Item.superclass.getAutoCreate.call(this));
76 cfg.cn[0].html = this.html;
80 this.cls += ' active';
87 cfg.cn[0].href = this.href;
90 if (this.badge !== '') {
91 cfg.cn[0].html += ' <span class="badge">' + this.badge + '</span>';
95 cfg.cn[0].cls += ' dropdown-toggle';
96 cfg.cn[0].html += '<span class="glyphicon glyphicon-chevron-down"></span>';
99 // fixme - this should handle glyphicon or ico
100 if (this.glyphicon || this.icon) {
101 var c = this.glyphicon ? ('glyphicon glyphicon-'+this.glyphicon) : this.icon;
103 cfg.cn[0].html = '<i class="' +c+'"></i><span>' + cfg.cn[0].html || this.html + '</span>'
111 initEvents: function() {
112 // Roo.log('init events?');
113 // Roo.log(this.el.dom);
114 this.el.select('a',true).on('click', this.onClick, this);
115 // at this point parent should be available..
116 this.parent().register(this);
119 onClick : function(e)
121 if(this.preventDefault){
125 if(this.fireEvent('click', this, e) === false){
129 if (['tabs','pills'].indexOf(this.parent().type)!==-1) {
130 if (typeof(this.parent().setActiveItem) !== 'undefined') {
131 this.parent().setActiveItem(this);
139 isActive: function () {
142 setActive : function(state, fire)
146 this.el.removeClass('active');
147 } else if (!this.el.hasClass('active')) {
148 this.el.addClass('active');
151 this.fireEvent('changed', this, state);
156 // this should not be here...