2019-01-03 23:30:27 +01:00
|
|
|
var menu = (function() {
|
|
|
|
|
2019-01-04 17:24:05 +01:00
|
|
|
var _bind = function() {
|
|
|
|
var allMenuNavButton = helper.eA(".menu-nav-button");
|
|
|
|
allMenuNavButton.forEach(function(arrayItem, index) {
|
|
|
|
arrayItem.addEventListener("click", function() {
|
|
|
|
_tab(this);
|
|
|
|
}, false);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
var _tab = function(button) {
|
|
|
|
var allMenuNavButton = helper.eA(".menu-nav-button");
|
2019-01-04 20:40:49 +01:00
|
|
|
var allMenuContentArea = helper.eA(".menu-content-area");
|
2019-01-04 17:24:05 +01:00
|
|
|
var target = helper.e(button.dataset.target);
|
|
|
|
allMenuNavButton.forEach(function(arrayItem, index) {
|
|
|
|
helper.removeClass(arrayItem, "active");
|
|
|
|
});
|
2019-01-04 20:40:49 +01:00
|
|
|
allMenuContentArea.forEach(function(arrayItem, index) {
|
|
|
|
helper.addClass(arrayItem, "is-hidden");
|
2019-01-04 17:24:05 +01:00
|
|
|
});
|
|
|
|
helper.addClass(button, "active");
|
2019-01-04 20:40:49 +01:00
|
|
|
helper.removeClass(target, "is-hidden");
|
2019-01-04 17:24:05 +01:00
|
|
|
};
|
|
|
|
|
2019-01-03 23:30:27 +01:00
|
|
|
var close = function() {
|
|
|
|
state.get().menu.active = false;
|
|
|
|
render();
|
|
|
|
};
|
|
|
|
|
|
|
|
var open = function() {
|
|
|
|
state.get().menu.active = true;
|
|
|
|
render();
|
|
|
|
};
|
|
|
|
|
|
|
|
var toggle = function() {
|
|
|
|
if (state.get().menu.active) {
|
|
|
|
state.get().menu.active = false;
|
|
|
|
} else {
|
|
|
|
state.get().menu.active = true;
|
|
|
|
};
|
|
|
|
render();
|
|
|
|
};
|
|
|
|
|
|
|
|
var render = function() {
|
|
|
|
var html = helper.e("html");
|
|
|
|
if (state.get().menu.active) {
|
|
|
|
helper.addClass(html, "is-menu-open");
|
|
|
|
shade.render({
|
|
|
|
action: function() {
|
|
|
|
close();
|
|
|
|
render();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
helper.removeClass(html, "is-menu-open");
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
var init = function() {
|
2019-01-04 17:24:05 +01:00
|
|
|
_bind();
|
2019-01-03 23:30:27 +01:00
|
|
|
close();
|
|
|
|
};
|
|
|
|
|
|
|
|
return {
|
|
|
|
init: init,
|
|
|
|
close: close,
|
|
|
|
open: open,
|
|
|
|
toggle: toggle,
|
|
|
|
render: render
|
|
|
|
};
|
|
|
|
|
|
|
|
})();
|