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