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