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