diff options
author | Filip Zybała <fzybala@virtuslab.com> | 2020-03-10 17:07:53 +0100 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-03-11 11:40:38 +0100 |
commit | 39759708d2329f81008e66ff57c11898cd739246 (patch) | |
tree | a6ddf1b91586d2089637ceb85b7b9b644ddd8344 /core/src | |
parent | c3d8894722c20411d56194e7529b52644307731e (diff) | |
download | dokka-39759708d2329f81008e66ff57c11898cd739246.tar.gz dokka-39759708d2329f81008e66ff57c11898cd739246.tar.bz2 dokka-39759708d2329f81008e66ff57c11898cd739246.zip |
Add DRIs to navigation elements, tag each ContentPage with DRI, add JS for collapsing navigation
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/main/resources/dokka/scripts/navigationLoader.js | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/core/src/main/resources/dokka/scripts/navigationLoader.js b/core/src/main/resources/dokka/scripts/navigationLoader.js index 99a885a9..5fe52ade 100644 --- a/core/src/main/resources/dokka/scripts/navigationLoader.js +++ b/core/src/main/resources/dokka/scripts/navigationLoader.js @@ -1,12 +1,41 @@ onload = () => { fetch(pathToRoot + "navigation.html") - .then(response => response.text()) - .then(data => { - document.getElementById("sideMenu").innerHTML = data; - }).then(() => { + .then(response => response.text()) + .then(data => { + document.getElementById("sideMenu").innerHTML = data; + }).then(() => { document.querySelectorAll(".overview > a").forEach(link => { - link.setAttribute("href", pathToRoot + link.getAttribute("href")) + link.setAttribute("href", pathToRoot + link.getAttribute("href")); console.log(link.attributes["href"]) }) + }).then(() => { + document.querySelectorAll(".sideMenuPart").forEach(nav => { + if (!nav.classList.contains("hidden")) nav.classList.add("hidden") + }) + }).then(() => { + revealNavigationForCurrentPage() }) -}
\ No newline at end of file +}; + +revealNavigationForCurrentPage = () => { + let pageId = document.getElementById("content").attributes["pageIds"].value.toString(); + let parts = document.querySelectorAll(".sideMenuPart"); + let found = 0; + do { + parts.forEach(part => { + if (part.attributes['pageId'].value.indexOf(pageId) !== -1 && found === 0) { + found = 1; + if (part.classList.contains("hidden")) part.classList.remove("hidden"); + revealParents(part) + } + }); + pageId = pageId.substring(0, pageId.lastIndexOf("/")) + } while (pageId.indexOf("/") !== -1 && found === 0) +}; + +revealParents = (part) => { + if (part.classList.contains("sideMenuPart")) { + if (part.classList.contains("hidden")) part.classList.remove("hidden"); + revealParents(part.parentNode) + } +};
\ No newline at end of file |