diff options
author | sptaule <lecas83@gmail.com> | 2022-01-31 18:43:17 +0100 |
---|---|---|
committer | sptaule <lecas83@gmail.com> | 2022-01-31 18:43:17 +0100 |
commit | e463223e15ff95ba58726ddf7b652a1a9cd41059 (patch) | |
tree | 2bcfcd8d17a678d760a1248d5329dbe9bc23a313 /templates/partials/doc/global_toc_script.html | |
parent | 608c3f7759f2edf6b8defcf2abe0a9031184c136 (diff) | |
download | garagehq.deuxfleurs.fr-e463223e15ff95ba58726ddf7b652a1a9cd41059.tar.gz garagehq.deuxfleurs.fr-e463223e15ff95ba58726ddf7b652a1a9cd41059.zip |
Fix doc submenus states, doc links hover, split page & global ToC
Diffstat (limited to 'templates/partials/doc/global_toc_script.html')
-rw-r--r-- | templates/partials/doc/global_toc_script.html | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/templates/partials/doc/global_toc_script.html b/templates/partials/doc/global_toc_script.html new file mode 100644 index 0000000..42abcda --- /dev/null +++ b/templates/partials/doc/global_toc_script.html @@ -0,0 +1,35 @@ +<script> +// Global ToC +/* + - Deploy current submenu (if any) and reploy others. + - Fixed ToC when user scrolls. +*/ + +document.addEventListener("DOMContentLoaded", function() { + var menusTriggers = document.getElementsByClassName("deploySubMenu"); + var activeDocPage = document.getElementsByClassName("activePage")[0]; + for (var i = 0; i < menusTriggers.length; i++) { + menusTriggers[i].checked = true; + } + let parentMenu = activeDocPage.parentElement.parentElement; + // Check if current page is the parent submenu page or just a child + if (parentMenu.classList.contains('subMenu')) { // child + parentMenu.previousElementSibling.previousElementSibling.checked = false; + } else { // parent + activeDocPage.nextElementSibling.checked = false; + } +}); + +window.addEventListener('scroll', function() { + if (document.body.clientWidth >= 1280) { + if (window.scrollY >= menuBarHeight) { + document.getElementById('main-toc-menu').classList.add('fixed', 'top-0', 'left-0'); + document.getElementById('main-toc-menu').style.width = mainTocMenuWidth + 'px'; + } else { + document.getElementById('main-toc-menu').classList.remove('fixed', 'top-0', 'left-0'); + } + } else { + + } +}); +</script>
\ No newline at end of file |