keycloak-scim/aggregation/navbar.html

37 lines
1.3 KiB
HTML
Raw Normal View History

2019-10-23 13:17:38 +00:00
<script src="https://cdnjs.cloudflare.com/ajax/libs/tocbot/4.4.2/tocbot.js"></script>
<script>
const oldtoc = document.getElementById('toctitle').nextElementSibling;
const newtoc = document.createElement('div');
2019-10-23 13:17:38 +00:00
newtoc.setAttribute('id', 'tocbot');
newtoc.setAttribute('class', 'js-toc');
oldtoc.parentNode.replaceChild(newtoc, oldtoc);
tocbot.init({ contentSelector: '#content',
headingSelector: 'h2, h3, h4',
smoothScroll: false
});
const handleTocOnResize = function() {
const width = window.innerWidth
2019-10-23 13:17:38 +00:00
|| document.documentElement.clientWidth
|| document.body.clientWidth;
if (width < 768) {
tocbot.refresh({
contentSelector: '#content',
headingSelector: 'h2, h3, h4',
collapseDepth: 6,
activeLinkClass: 'ignoreactive',
throttleTimeout: 1000,
smoothScroll: false
});
}
else {
tocbot.refresh({
contentSelector: '#content',
headingSelector: 'h2, h3, h4',
smoothScroll: false
});
}
};
window.addEventListener('resize', handleTocOnResize);
handleTocOnResize();
</script>