theme-default.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. function hashChange() {
  2. const currentItems = document.querySelectorAll('.tocify-subheader');
  3. Array.from(currentItems).forEach((elem) => {
  4. elem.classList.remove('visible');
  5. });
  6. const currentTag = document.querySelector(`a[href="${window.location.hash}"]`);
  7. if (currentTag) {
  8. if (currentTag.parentElement.matches('.level-2')) {
  9. const parent = currentTag.closest('.tocify-subheader');
  10. if (parent) {
  11. parent.classList.add('visible');
  12. }
  13. }
  14. }
  15. }
  16. window.addEventListener('hashchange', hashChange, false);
  17. document.addEventListener('DOMContentLoaded', function() {
  18. window.hljs.highlightAll();
  19. // https://jets.js.org/
  20. const wrapper = document.getElementById('toc');
  21. window.jets = new window.Jets({
  22. // *OR - Selects elements whose values contains at least one part of search substring
  23. searchSelector: '*OR',
  24. searchTag: '#input-search',
  25. contentTag: '#toc li',
  26. didSearch: function(term) {
  27. wrapper.classList.toggle('jets-searching', String(term).length > 0)
  28. },
  29. // map these accent keys to plain values
  30. diacriticsMap: {
  31. a: 'ÀÁÂÃÄÅàáâãäåĀāąĄ',
  32. c: 'ÇçćĆčČ',
  33. d: 'đĐďĎ',
  34. e: 'ÈÉÊËèéêëěĚĒēęĘ',
  35. i: 'ÌÍÎÏìíîïĪī',
  36. l: 'łŁ',
  37. n: 'ÑñňŇńŃ',
  38. o: 'ÒÓÔÕÕÖØòóôõöøŌō',
  39. r: 'řŘ',
  40. s: 'ŠšśŚ',
  41. t: 'ťŤ',
  42. u: 'ÙÚÛÜùúûüůŮŪū',
  43. y: 'ŸÿýÝ',
  44. z: 'ŽžżŻźŹ'
  45. }
  46. });
  47. hashChange();
  48. });