-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve toc element alignment, boxes landing page search bar appearan…
…ce, fix toc error on landing page
- Loading branch information
1 parent
0d43af2
commit 673a53c
Showing
3 changed files
with
75 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,36 @@ | ||
/* Trigger Tocbot dynamic TOC, works with tocbot 3.0.2 */ | ||
function makeToc() { | ||
var oldtoc = document.getElementById('toc').nextElementSibling; | ||
var newtoc = document.getElementById('tocbot'); | ||
newtoc.setAttribute('id', 'tocbot'); | ||
newtoc.setAttribute('class', 'js-toc'); | ||
oldtoc.parentNode.replaceChild(newtoc, oldtoc); | ||
tocbot.init({ contentSelector: '#content', | ||
headingSelector: 'h1, h2, h3, h4', | ||
smoothScroll: true, | ||
includeHtml: true | ||
}); | ||
var handleTocOnResize = function() { | ||
var width = window.innerWidth | ||
|| document.documentElement.clientWidth | ||
|| document.body.clientWidth; | ||
if (width < 768) { | ||
tocbot.refresh({ contentSelector: '#content', | ||
var tocElement = document.getElementById('toc'); | ||
if (tocElement) { /* only run on pages that have a toc -- exclude boxes landing pages, for instance */ | ||
var oldtoc = tocElement.nextElementSibling; | ||
var newtoc = document.getElementById('tocbot'); | ||
newtoc.setAttribute('id', 'tocbot'); | ||
newtoc.setAttribute('class', 'js-toc'); | ||
oldtoc.parentNode.replaceChild(newtoc, oldtoc); | ||
tocbot.init({ contentSelector: '#content', | ||
headingSelector: 'h1, h2, h3, h4', | ||
collapseDepth: 6, | ||
activeLinkClass: 'ignoreactive', | ||
throttleTimeout: 1000, | ||
smoothScroll: true }); | ||
smoothScroll: true, | ||
includeHtml: true | ||
}); | ||
var handleTocOnResize = function() { | ||
var width = window.innerWidth | ||
|| document.documentElement.clientWidth | ||
|| document.body.clientWidth; | ||
if (width < 768) { | ||
tocbot.refresh({ contentSelector: '#content', | ||
headingSelector: 'h1, h2, h3, h4', | ||
collapseDepth: 6, | ||
activeLinkClass: 'ignoreactive', | ||
throttleTimeout: 1000, | ||
smoothScroll: true }); | ||
} | ||
else { | ||
tocbot.refresh({ contentSelector: '#content', | ||
headingSelector: 'h1, h2, h3, h4', | ||
smoothScroll: true }); | ||
} | ||
}; | ||
window.addEventListener('resize', handleTocOnResize); | ||
handleTocOnResize(); | ||
} | ||
else { | ||
tocbot.refresh({ contentSelector: '#content', | ||
headingSelector: 'h1, h2, h3, h4', | ||
smoothScroll: true }); | ||
} | ||
}; | ||
window.addEventListener('resize', handleTocOnResize); | ||
handleTocOnResize(); | ||
} |