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     badgeWeight : 'default',
46     
47     getAutoCreate : function(){
48         
49         
50         var a = {
51                 tag: 'a',
52                 href : this.href || '#',
53                 cls: '',
54                 html : '',
55                 cn : []
56         };
57         var cfg = {
58             tag: 'li',
59             cls: '',
60             cn: [ a ]
61         }
62         var span = {
63             tag: 'span',
64             html : this.html || ''
65         }
66         
67         
68         if (this.active) {
69             cfg.cls += ' active';
70         }
71         
72         // left icon..
73         if (this.glyphicon || this.icon) {
74             var c = this.glyphicon  ? ('glyphicon glyphicon-'+this.glyphicon)  : this.icon;
75             a.cn.push({ tag : 'i', cls : c }) ;
76         }
77         // html..
78         a.cn.push(span);
79         // then badge..
80         if (this.badge !== '') {
81             
82             a.cn.push({ tag: 'span',  cls : 'badge pull-right badge-' + this.badgeWeight, html: this.badge }); 
83         }
84         // fi
85         if (this.menu) {
86             a.cn.push({ tag : 'i', cls : 'glyphicon glyphicon-chevron-down pull-right'});
87             a.cls += 'dropdown-toggle treeview' ;
88             
89         }
90         
91         
92         
93         return cfg;
94          
95            
96     },
97     
98     initEvents : function()
99     { 
100         
101     }
102    
103      
104  
105 });
106  
107
108