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  * 
17  * {String} labelcls (default|primary|success|info|warning|danger)the extra classes for the badge
18  * @constructor
19  * Create a new Navbar Button
20  * @param {Object} config The config object
21  */
22 Roo.bootstrap.NavSidebarItem = function(config){
23     Roo.bootstrap.NavSidebarItem.superclass.constructor.call(this, config);
24     this.addEvents({
25         // raw events
26         /**
27          * @event click
28          * The raw click event for the entire grid.
29          * @param {Roo.EventObject} e
30          */
31         "click" : true,
32          /**
33             * @event changed
34             * Fires when the active item active state changes
35             * @param {Roo.bootstrap.NavSidebarItem} this
36             * @param {boolean} state the new state
37              
38          */
39         'changed': true
40     });
41    
42 };
43
44 Roo.extend(Roo.bootstrap.NavSidebarItem, Roo.bootstrap.NavItem,  {
45     
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             a.cn.push({ tag: 'span',  cls : 'badge pull-right ' + (this.badgecls || ''), html: this.badge }); 
82         }
83         // fi
84         if (this.menu) {
85             a.cn.push({ tag : 'i', cls : 'glyphicon glyphicon-chevron-down pull-right'});
86             a.cls += 'dropdown-toggle treeview' ;
87             
88         }
89         
90         
91         
92         return cfg;
93          
94            
95     },
96     
97     initEvents : function()
98     { 
99         
100     }
101    
102      
103  
104 });
105  
106
107