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