aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main
diff options
context:
space:
mode:
authorMarcin Aman <maman@virtuslab.com>2020-08-04 19:01:30 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-08-10 09:47:23 +0200
commit49c9bcc586abb7c78f569526a05fea97da86993d (patch)
tree6ec9de732dbc8dcb50885963ff1bfde6d23023e0 /plugins/base/src/main
parent632a497ac47150cab9c00bff6b81060af089a908 (diff)
downloaddokka-49c9bcc586abb7c78f569526a05fea97da86993d.tar.gz
dokka-49c9bcc586abb7c78f569526a05fea97da86993d.tar.bz2
dokka-49c9bcc586abb7c78f569526a05fea97da86993d.zip
Highlight anchor
Diffstat (limited to 'plugins/base/src/main')
-rw-r--r--plugins/base/src/main/resources/dokka/scripts/platformContentHandler.js12
-rw-r--r--plugins/base/src/main/resources/dokka/styles/style.css7
2 files changed, 19 insertions, 0 deletions
diff --git a/plugins/base/src/main/resources/dokka/scripts/platformContentHandler.js b/plugins/base/src/main/resources/dokka/scripts/platformContentHandler.js
index f0e08f48..78d65333 100644
--- a/plugins/base/src/main/resources/dokka/scripts/platformContentHandler.js
+++ b/plugins/base/src/main/resources/dokka/scripts/platformContentHandler.js
@@ -3,6 +3,8 @@ filteringContext = {
restrictedDependencies: [],
activeFilters: []
}
+let highlightedAnchor;
+
window.addEventListener('load', () => {
document.querySelectorAll("div[data-platform-hinted]")
.forEach(elem => elem.addEventListener('click', (event) => togglePlatformDependent(event,elem)))
@@ -22,6 +24,11 @@ window.addEventListener('load', () => {
window.onhashchange = handleAnchor
function handleAnchor() {
+ if(highlightedAnchor){
+ highlightedAnchor.classList.remove('anchor-highlight')
+ highlightedAnchor = null;
+ }
+
let searchForTab = function(element) {
if(element && element.hasAttribute) {
if(element.hasAttribute("data-togglable")) return element;
@@ -37,6 +44,11 @@ function handleAnchor() {
if (tab) {
let found = document.querySelector('.tabs-section > .section-tab[data-togglable="' + tab.getAttribute("data-togglable") + '"]')
toggleSections(tab)
+ const content = element.nextElementSibling
+ if(content){
+ content.classList.add('anchor-highlight')
+ highlightedAnchor = content
+ }
element.scrollIntoView({behavior: "smooth"})
}
}
diff --git a/plugins/base/src/main/resources/dokka/styles/style.css b/plugins/base/src/main/resources/dokka/styles/style.css
index b0bf8141..f40aa33d 100644
--- a/plugins/base/src/main/resources/dokka/styles/style.css
+++ b/plugins/base/src/main/resources/dokka/styles/style.css
@@ -1053,4 +1053,11 @@ td.content {
div.runnablesample {
height: fit-content;
+}
+
+.anchor-highlight {
+ border: 1px solid var(--hover-link-color) !important;
+ box-shadow: 0 0 0 0.2em #c8e1ff;
+ margin-top: 0.2em;
+ margin-bottom: 0.2em;
} \ No newline at end of file