Roo/bootstrap/NavSidebarItem.js
[roojs1] / Roo / bootstrap / NavSidebarItem.js
1 /*
2  * - LGPL
3  *
4  * sidebar item
5  *
6  *  li
7  *    <span> icon </span>
8  *    <span> text </span>
9  *    <span>badge </span>
10  */
11
12 /**
13  * @class Roo.bootstrap.NavSidebarItem
14  * @extends Roo.bootstrap.NavItem
15  * Bootstrap Navbar.NavSidebarItem class
16  * {String} badgeWeight (default|primary|success|info|warning|danger)the extra classes for the badge
17  * @constructor
18  * Create a new Navbar Button
19  * @param {Object} config The config object
20  */
21 Roo.bootstrap.NavSidebarItem = function(config){
22     Roo.bootstrap.NavSidebarItem.superclass.constructor.call(this, config);
23     this.addEvents({
24         // raw events
25         /**
26          * @event click
27          * The raw click event for the entire grid.
28          * @param {Roo.EventObject} e
29          */
30         "click" : true,
31          /**
32             * @event changed
33             * Fires when the active item active state changes
34             * @param {Roo.bootstrap.NavSidebarItem} this
35             * @param {boolean} state the new state
36              
37          */
38         'changed': true
39     });
40    
41 };
42
43 Roo.extend(Roo.bootstrap.NavSidebarItem, Roo.bootstrap.NavItem,  {
44     
45     
46     getAutoCreate : function(){
47         
48         
49         var a = {
50                 tag: 'a',
51                 href : this.href || '#',
52                 cls: '',
53                 html : '',
54                 cn : []
55         };
56         var cfg = {
57             tag: 'li',
58             cls: '',
59             cn: [ a ]
60         }
61         var span = {
62             tag: 'span',
63             html : this.html || ''
64         }
65         
66         
67         if (this.active) {
68             cfg.cls += ' active';
69         }
70         
71         // left icon..
72         if (this.glyphicon || this.icon) {
73             var c = this.glyphicon  ? ('glyphicon glyphicon-'+this.glyphicon)  : this.icon;
74             a.cn.push({ tag : 'i', cls : c }) ;
75         }
76         // html..
77         a.cn.push(span);
78         // then badge..
79         if (this.badge !== '') {
80             a.cn.push({ tag: 'span',  cls : 'badge pull-right ' + (this.badgecls || ''), html: this.badge }); 
81         }
82         // fi
83         if (this.menu) {
84             a.cn.push({ tag : 'i', cls : 'glyphicon glyphicon-chevron-down pull-right'});
85             a.cls += 'dropdown-toggle treeview' ;
86             
87         }
88         
89         
90         
91         return cfg;
92          
93            
94     },
95     
96     initEvents : function()
97     { 
98         
99     }
100    
101      
102  
103 });
104  
105
106