Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /******************************************************************************* | 1 /******************************************************************************* |
2 * Navbar Component | 2 * Navbar Component |
juliandoucette
2017/10/31 15:18:37
Are you planning to add accessibility features lik
ire
2017/11/02 11:15:25
I haven't done much research either, but I would p
| |
3 ******************************************************************************/ | 3 ******************************************************************************/ |
4 (function() | 4 |
juliandoucette
2017/10/31 15:18:37
TOL: I'm not sure that we have to worry about poll
ire
2017/11/02 11:15:26
You're probably right. I'll remove it.
ire
2017/11/02 11:15:26
Done.
| |
5 document.addEventListener("DOMContentLoaded", function() | |
5 { | 6 { |
6 document.addEventListener("DOMContentLoaded", function() | 7 |
8 function Navbar(navbar) | |
7 { | 9 { |
10 this.navbar = navbar; | |
8 | 11 |
9 function Navbar(navbar) | 12 this.navbar |
10 { | 13 .querySelector(".toggle-navbar-collapse") |
11 this.navbar = navbar; | 14 .addEventListener("click", this._onClick.bind(this), false); |
15 } | |
12 | 16 |
13 this.navbar | 17 Navbar.prototype.toggleCollapse = function() |
14 .querySelector(".toggle-navbar-collapse") | 18 { |
15 .addEventListener("click", this._onClick.bind(this), false); | 19 this.navbar.classList.toggle("expanded"); |
16 } | 20 }; |
17 | 21 |
18 Navbar.prototype.toggleCollapse = function() | 22 Navbar.prototype._onClick = function() |
19 { | 23 { |
20 this.navbar.classList.toggle("expanded"); | 24 this.toggleCollapse(); |
21 }; | 25 }; |
22 | 26 |
23 Navbar.prototype._onClick = function() | 27 var navbars = document.getElementsByClassName("navbar"); |
24 { | 28 for (var i = 0; i < navbars.length; i++) |
25 this.toggleCollapse(); | 29 { |
26 }; | 30 new Navbar(navbars[i]); |
31 } | |
27 | 32 |
28 var navbars = document.getElementsByClassName("navbar"); | 33 }, false); |
29 for (var i = 0; i < navbars.length; i++) | |
30 { | |
31 new Navbar(navbars[i]); | |
32 } | |
33 | |
34 }, false); | |
35 }()); | |
LEFT | RIGHT |