Roo/bootstrap/NavHeaderbar.js
[roojs1] / Roo / bootstrap / NavHeaderbar.js
1 /*
2  * - LGPL
3  *
4  * navbar
5  * 
6  */
7
8 /**
9  * @class Roo.bootstrap.NavHeaderbar
10  * @extends Roo.bootstrap.NavSimplebar
11  * Bootstrap Sidebar class
12  *
13  * @cfg {String} brand what is brand
14  * @cfg {String} position (fixed-top|fixed-bottom|static-top) position
15  * @cfg {String} brand_href href of the brand
16  * @cfg {Boolean} srButton generate the sr-only button (true | false) default true
17  * 
18  * @constructor
19  * Create a new Sidebar
20  * @param {Object} config The config object
21  */
22
23
24 Roo.bootstrap.NavHeaderbar = function(config){
25     Roo.bootstrap.NavHeaderbar.superclass.constructor.call(this, config);
26 };
27
28 Roo.extend(Roo.bootstrap.NavHeaderbar, Roo.bootstrap.NavSimplebar,  {
29     
30     position: '',
31     brand: '',
32     brand_href: false,
33     srButton : true,
34     
35     
36     getAutoCreate : function(){
37         
38         var   cfg = {
39             tag: this.nav || 'nav',
40             cls: 'navbar',
41             role: 'navigation',
42             cn: []
43         };
44         
45         if(this.srButton){
46             cfg.cn.push({
47                 tag: 'div',
48                 cls: 'navbar-header',
49                 cn: [
50                     {
51                         tag: 'button',
52                         type: 'button',
53                         cls: 'navbar-toggle',
54                         'data-toggle': 'collapse',
55                         cn: [
56                             {
57                                 tag: 'span',
58                                 cls: 'sr-only',
59                                 html: 'Toggle navigation'
60                             },
61                             {
62                                 tag: 'span',
63                                 cls: 'icon-bar'
64                             },
65                             {
66                                 tag: 'span',
67                                 cls: 'icon-bar'
68                             },
69                             {
70                                 tag: 'span',
71                                 cls: 'icon-bar'
72                             }
73                         ]
74                     }
75                 ]
76             });
77         }
78         
79         cfg.cn.push({
80             tag: 'div',
81             cls: 'collapse navbar-collapse',
82             cn : []
83         });
84         
85         cfg.cls += this.inverse ? ' navbar-inverse' : ' navbar-default';
86         
87         if (['fixed-top','fixed-bottom','static-top'].indexOf(this.position)>-1) {
88             cfg.cls += ' navbar-' + this.position;
89             
90             // tag can override this..
91             
92             cfg.tag = this.tag || (this.position  == 'fixed-bottom' ? 'footer' : 'header');
93         }
94         
95         if (this.brand !== '') {
96             cfg.cn[0].cn.push({
97                 tag: 'a',
98                 href: this.brand_href ? this.brand_href : '#',
99                 cls: 'navbar-brand',
100                 cn: [
101                 this.brand
102                 ]
103             });
104         }
105         
106         if(this.main){
107             cfg.cls += ' main-nav';
108         }
109         
110         
111         return cfg;
112
113         
114     },
115     initEvents : function()
116     {
117     // parent
118         if (this.autohide) {
119             Roo.get(document.body).on('mousewheel',function(e){
120                 var ft = this.select('.navbar-fixed-top').first();
121                 if(e.wheelDelta < 0 ){
122                     ft.removeClass('slideDown');
123                     ft.addClass('slideUp');
124                     return;
125                 }
126                 ft.removeClass('slideUp').addClass('slideDown');
127                  
128               
129           },this);
130         }
131     }    
132           
133       
134     
135     
136 });
137
138
139
140  
141
142