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