Roo/bootstrap/Navbar.Item.js
[roojs1] / Roo / bootstrap / Navbar.Item.js
1 /*
2  * - LGPL
3  *
4  * row
5  * 
6  */ 
7 Roo.bootstrap.Navbar.Item = function(config){
8     Roo.bootstrap.Navbar.Item.superclass.constructor.call(this, config);
9 };
10
11 Roo.extend(Roo.bootstrap.Navbar.Item, Roo.bootstrap.Component,  {
12     
13     href : false,
14     html : '',
15     badge : '',
16     
17     getAutoCreate : function(){
18         
19         var cfg = Roo.apply({}, Roo.bootstrap.Navbar.Item.superclass.getAutoCreate.call(this));
20         
21         console.log(this.closest('.navbar').sidebar)
22         
23         cfg = {
24             tag: 'li'
25         }
26         cfg.cn = [
27             {
28                 tag: 'p',
29                 html: 'Text'
30             }
31         ];
32         
33         if (this.glyphicon) {
34             if(cfg.html){cfg.html = ' ' + this.html};
35             cfg.cn=[
36                 {
37                     tag: 'span',
38                     cls: 'glyphicon glyphicon-' + this.glyphicon
39                 }
40             ];
41         }
42         
43         cfg.cn[0].html = this.html || cfg.cn[0].html ;
44         if (this.menu) {
45             cfg.cn[0].tag='a';
46             cfg.cn[0].href='#';
47             cfg.cn[0].html += " <span class='caret'></span>";
48         //}else if (!this.href) {
49         //    cfg.cn[0].tag='p';
50         //    cfg.cn[0].cls='navbar-text';
51         } else {
52             cfg.cn[0].tag='a';
53             cfg.cn[0].href=this.href||'#';
54             cfg.cn[0].html=this.html;
55         }
56         
57         if (this.badge !== '') {
58             
59             cfg.cn[0].cn=[
60                 cfg.cn[0].html + ' ',
61                 {
62                     tag: 'span',
63                     cls: 'badge',
64                     html: this.badge
65                 }
66             ];
67             cfg.cn[0].html=''
68         }
69          
70         
71         return cfg;
72     },
73     initEvents: function() {
74        // Roo.log('init events?');
75        // Roo.log(this.el.dom);
76         this.el.select('a',true).on('click',
77                 function(e) {
78                     this.fireEvent('click', this);
79                 },
80                 this
81         );
82     }
83    
84 });
85
86  
87
88