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