diff options
Diffstat (limited to 'src/pages.js')
| -rw-r--r-- | src/pages.js | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/pages.js b/src/pages.js index 0576684..f6a8b9b 100644 --- a/src/pages.js +++ b/src/pages.js @@ -1,3 +1,5 @@ +const menu = document.querySelector("#menu") + export default class Page { static pages = {} static currentPage = null @@ -33,9 +35,20 @@ export default class Page { } setVisible(visible) { - this.pageContainer.style.display = visible ? null : "none" + this.pageContainer.classList.toggle("hidden!", !visible) this.visible = visible - if (visible && !this.initialized && this.initialize) - this.initialized = this.initialize(this.pageContainer) + if (this.visible) { + /* initialize page */ + if (!this.initialized && this.initialize) + this.initialized = this.initialize(this.pageContainer) + + /* set selected attribute on the link */ + for (const a of menu.querySelectorAll("a")) { + if (this.endpoints.includes(a.getAttribute("href"))) + a.dataset.selected = "1" + else + delete a.dataset.selected + } + } } } |
