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