From 6a907269a96130e798815ba1723a2789fc158f3d Mon Sep 17 00:00:00 2001 From: Marcin Aman Date: Wed, 27 May 2020 13:00:08 +0200 Subject: Initially show only the default chosen tab body --- .../resources/dokka/scripts/platformContentHandler.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'plugins/base/src') diff --git a/plugins/base/src/main/resources/dokka/scripts/platformContentHandler.js b/plugins/base/src/main/resources/dokka/scripts/platformContentHandler.js index cd993587..335bb230 100644 --- a/plugins/base/src/main/resources/dokka/scripts/platformContentHandler.js +++ b/plugins/base/src/main/resources/dokka/scripts/platformContentHandler.js @@ -10,10 +10,23 @@ window.addEventListener('load', () => { document.querySelectorAll("div[tabs-section]") .forEach(elem => elem.addEventListener('click', (event) => toggleSections(event))) document.getElementById('filter-section').addEventListener('click', (event) => filterButtonHandler(event)) + initTabs() +}) + +function initTabs(){ + document.querySelectorAll("div[tabs-section]") + .forEach(element => { + showCorrespondingTabBody(element) + element.addEventListener('click', (event) => toggleSections(event)) + }) +} + +function showCorrespondingTabBody(element){ + const key = element.querySelector("button[data-active]").getAttribute("data-togglable") document.querySelector(".tabs-section-body") - .querySelector("div[data-togglable]") + .querySelector("div[data-togglable='" + key + "']") .setAttribute("data-active", "") -}) +} function filterButtonHandler(event) { if(event.target.tagName == "BUTTON" && event.target.hasAttribute("data-filter")) { -- cgit