23 lines
605 B
JavaScript
23 lines
605 B
JavaScript
|
(function () {
|
||
|
|
||
|
var ACTIVE_CLASS = 'is-active';
|
||
|
var navigation = document.querySelector('nav');
|
||
|
var toggles = document.querySelectorAll('.js-toggle-navigation');
|
||
|
|
||
|
function toggleNavigation() {
|
||
|
navigation.classList.contains(ACTIVE_CLASS) ?
|
||
|
navigation.classList.remove(ACTIVE_CLASS) :
|
||
|
navigation.classList.add(ACTIVE_CLASS);
|
||
|
}
|
||
|
|
||
|
Array.prototype.forEach.call(
|
||
|
toggles,
|
||
|
/**
|
||
|
* @param {HTMLElement} toggle
|
||
|
*/
|
||
|
function (toggle) {
|
||
|
toggle.addEventListener('click', toggleNavigation);
|
||
|
}
|
||
|
)
|
||
|
|
||
|
})()
|