cyp/app/js/nav.js
Ondrej Zara 76802bc630 queue
2019-03-22 15:35:04 +01:00

16 lines
352 B
JavaScript

import * as app from "./app.js";
let tabs = [];
export function init(node) {
tabs = Array.from(node.querySelectorAll("[data-for]"));
tabs.forEach(tab => {
tab.addEventListener("click", e => app.activate(tab.dataset.for));
});
}
export function active(id) {
tabs.forEach(tab => {
tab.classList.toggle("active", tab.dataset.for == id);
});
}