| Index: static/js/navbar.js |
| =================================================================== |
| new file mode 100644 |
| --- /dev/null |
| +++ b/static/js/navbar.js |
| @@ -0,0 +1,35 @@ |
| +/******************************************************************************* |
| + * Navbar Component |
|
juliandoucette
2017/10/26 15:55:56
suggest: keyboard and aria functionality from [exa
|
| + ******************************************************************************/ |
| +(function() |
| +{ |
| + document.addEventListener("DOMContentLoaded", function() |
| + { |
| + |
| + function Navbar(navbar) |
| + { |
| + this.navbar = navbar; |
| + |
| + this.navbar |
| + .querySelector(".toggle-navbar-collapse") |
| + .addEventListener("click", this._onClick.bind(this), false); |
|
juliandoucette
2017/10/26 15:55:56
suggest: Allow click away to close?
|
| + } |
| + |
| + Navbar.prototype.toggleCollapse = function() |
| + { |
| + this.navbar.classList.toggle("expanded"); |
| + }; |
| + |
| + Navbar.prototype._onClick = function() |
| + { |
| + this.toggleCollapse(); |
| + }; |
| + |
| + var navbars = document.getElementsByClassName("navbar"); |
|
juliandoucette
2017/10/26 15:55:56
NIT: separate var and for by one line
|
| + for (var i = 0; i < navbars.length; i++) |
| + { |
| + new Navbar(navbars[i]); |
| + } |
| + |
| + }, false); |
| +}()); |