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         cfg = {
22             tag: 'li'
23         }
24         cfg.cn = [
25             {
26                 tag: 'p',
27                 html: 'Text'
28             }
29         ];
30         
31         if (this.glyphicon) {
32             if(cfg.html){this.html = ' ' + cfg.html};
33             cfg.cn=[
34                 {
35                     tag: 'span',
36                     cls: 'glyphicon glyphicon-' + this.glyphicon
37                 }
38             ];
39         }
40         
41         cfg.cn[0].html = this.html || cfg.cn[0].html ;
42         if (this.menu) {
43             cfg.cn[0].tag='a';
44             cfg.cn[0].href='#';
45             cfg.cn[0].html += " <span class='caret'></span>";
46         //}else if (!this.href) {
47         //    cfg.cn[0].tag='p';
48         //    cfg.cn[0].cls='navbar-text';
49         } else {
50             cfg.cn[0].tag='a';
51             cfg.cn[0].href=this.href||'#';
52             cfg.cn[0].html=this.html;
53         }
54         
55         if (this.badge !== '') {
56             
57             cfg.cn[0].cn=[
58                 cfg.cn[0].html + ' ',
59                 {
60                     tag: 'span',
61                     cls: 'badge',
62                     html: this.badge
63                 }
64             ];
65             cfg.cn[0].html=''
66         }
67          
68         
69         return cfg;
70     },
71     initEvents: function() {
72        // Roo.log('init events?');
73        // Roo.log(this.el.dom);
74         this.el.select('a',true).on('click',
75                 function(e) {
76                     this.fireEvent('click', this);
77                 },
78                 this
79         );
80     }
81    
82 });
83
84  
85
86