aboutsummaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorFilip Zybała <fzybala@virtuslab.com>2020-03-10 17:07:53 +0100
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-03-11 11:40:38 +0100
commit39759708d2329f81008e66ff57c11898cd739246 (patch)
treea6ddf1b91586d2089637ceb85b7b9b644ddd8344 /core/src
parentc3d8894722c20411d56194e7529b52644307731e (diff)
downloaddokka-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.js41
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