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