Commit 61b85a58 authored by Eugen Rochko's avatar Eugen Rochko

Improve script

parent feca9ba8
(function () { (function () {
document.addEventListener('DOMContentLoaded', function () { 'use strict';
var menuLinks = document.getElementsByClassName('menu-item');
for (var i = 0; i < menuLinks.length; i++) {
menuLinks[i].addEventListener('click', toggleSubMenu, false);
}
function onLoaded () {
function toggleSubMenu () { function toggleSubMenu () {
var subMenus = document.getElementsByClassName('sub-menu'); var subMenus = document.getElementsByClassName('sub-menu');
...@@ -15,5 +11,17 @@ ...@@ -15,5 +11,17 @@
this.parentNode.querySelector('.sub-menu').classList.remove('collapsed'); this.parentNode.querySelector('.sub-menu').classList.remove('collapsed');
} }
});
var menuLinks = document.getElementsByClassName('menu-item');
for (var i = 0; i < menuLinks.length; i++) {
menuLinks[i].addEventListener('click', toggleSubMenu, false);
}
}
if (document.readyState === 'interactive' || document.readyState === 'complete') {
onLoaded();
} else {
document.addEventListener('DOMContentLoaded', onLoaded);
}
})(); })();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment