main.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Client-side interaction for the pages of MyWiki, the simple wiki.
  3. *
  4. * Feel free to modify this file to suit your needs, especially if you edited
  5. * the page template.
  6. *
  7. */
  8. (function () {
  9. "use strict";
  10. var searchBox = document.querySelectorAll("li.search")[0];
  11. searchBox.style.display = "none";
  12. var searchTrigger = document.querySelectorAll("a.search")[0];
  13. searchTrigger.onclick = function () {
  14. if (searchBox.style.display === "none") {
  15. searchBox.style.display = "block";
  16. searchTrigger.classList.add("active")
  17. }
  18. else {
  19. searchBox.style.display = "none";
  20. searchTrigger.classList.remove("active")
  21. }
  22. };
  23. var menuTrigger = document.querySelectorAll("nav div.menutrigger")[0];
  24. var menu = document.querySelectorAll("body > header nav ul")[0];
  25. if (window.innerWidth <= 900) {
  26. menu.style.display = "none";
  27. }
  28. menuTrigger.onclick = function () {
  29. if (menu.style.display === "none") {
  30. menu.style.display = "block";
  31. }
  32. else {
  33. menu.style.display = "none";
  34. }
  35. };
  36. }());