Left: | ||
Right: |
OLD | NEW |
---|---|
(Empty) | |
1 /******************************************************************************* | |
2 * Navbar Component | |
juliandoucette
2017/10/26 15:55:56
suggest: keyboard and aria functionality from [exa
| |
3 ******************************************************************************/ | |
4 (function() | |
5 { | |
6 document.addEventListener("DOMContentLoaded", function() | |
7 { | |
8 | |
9 function Navbar(navbar) | |
10 { | |
11 this.navbar = navbar; | |
12 | |
13 this.navbar | |
14 .querySelector(".toggle-navbar-collapse") | |
15 .addEventListener("click", this._onClick.bind(this), false); | |
juliandoucette
2017/10/26 15:55:56
suggest: Allow click away to close?
| |
16 } | |
17 | |
18 Navbar.prototype.toggleCollapse = function() | |
19 { | |
20 this.navbar.classList.toggle("expanded"); | |
21 }; | |
22 | |
23 Navbar.prototype._onClick = function() | |
24 { | |
25 this.toggleCollapse(); | |
26 }; | |
27 | |
28 var navbars = document.getElementsByClassName("navbar"); | |
juliandoucette
2017/10/26 15:55:56
NIT: separate var and for by one line
| |
29 for (var i = 0; i < navbars.length; i++) | |
30 { | |
31 new Navbar(navbars[i]); | |
32 } | |
33 | |
34 }, false); | |
35 }()); | |
OLD | NEW |