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         cfg.cn[0].html = this.html || cfg.cn[0].html ;
32         if (this.menu) {
33             cfg.cn[0].tag='a';
34             cfg.cn[0].href='#';
35             cfg.cn[0].html += " <span class='caret'></span>";
36         //}else if (!this.href) {
37         //    cfg.cn[0].tag='p';
38         //    cfg.cn[0].cls='navbar-text';
39         } else {
40             cfg.cn[0].tag='a';
41             cfg.cn[0].href=this.href||'#';
42             cfg.cn[0].html=this.html;
43         }
44         
45         if (this.glyphicon) {
46             if(cfg.html){cfg.html = ' ' + this.html};
47             cfg.cn=[
48                 {
49                     tag: 'span',
50                     cls: 'glyphicon glyphicon-' + this.glyphicon
51                 }
52             ];
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