tocbot.js 817 B

1234567891011121314151617181920212223242526
  1. const initToc = () => {
  2. if (window.tocbot === undefined) {
  3. setTimeout(initToc, 250)
  4. return
  5. }
  6. // Check whether we have any sidebar content. If not, then show the sidebar earlier.
  7. var SIDEBAR_CONTENT_TAGS = ['.tag_full_width', '.tag_popout'];
  8. var sidebar_content_query = SIDEBAR_CONTENT_TAGS.join(', ')
  9. if (document.querySelectorAll(sidebar_content_query).length === 0) {
  10. document.querySelector('nav.onthispage').classList.add('no_sidebar_content')
  11. }
  12. // Initialize the TOC bot
  13. tocbot.init({
  14. tocSelector: 'nav.onthispage',
  15. contentSelector: '.c-textbook__content',
  16. headingSelector: 'h2, h3',
  17. orderedList: false,
  18. collapseDepth: 6,
  19. listClass: 'toc__menu',
  20. activeListItemClass: "", // Not using
  21. activeLinkClass: "", // Not using
  22. });
  23. }
  24. initFunction(initToc);