theme.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. $( document ).ready(function() {
  2. // Shift nav in mobile when clicking the menu.
  3. $(document).on('click', "[data-toggle='wy-nav-top']", function() {
  4. $("[data-toggle='wy-nav-shift']").toggleClass("shift");
  5. $("[data-toggle='rst-versions']").toggleClass("shift");
  6. });
  7. // Close menu when you click a link.
  8. $(document).on('click', ".wy-menu-vertical .current ul li a", function() {
  9. $("[data-toggle='wy-nav-shift']").removeClass("shift");
  10. $("[data-toggle='rst-versions']").toggleClass("shift");
  11. });
  12. $(document).on('click', "[data-toggle='rst-current-version']", function() {
  13. $("[data-toggle='rst-versions']").toggleClass("shift-up");
  14. });
  15. // Make tables responsive
  16. $("table.docutils:not(.field-list)").wrap("<div class='wy-table-responsive'></div>");
  17. });
  18. window.ElggRtdTheme = (function (jquery) {
  19. var stickyNav = (function () {
  20. var navBar,
  21. win,
  22. stickyNavCssClass = 'stickynav',
  23. applyStickNav = function () {
  24. if (navBar.height() <= win.height()) {
  25. navBar.addClass(stickyNavCssClass);
  26. } else {
  27. navBar.removeClass(stickyNavCssClass);
  28. }
  29. },
  30. enable = function () {
  31. applyStickNav();
  32. win.on('resize', applyStickNav);
  33. },
  34. init = function () {
  35. navBar = jquery('nav.wy-nav-side:first');
  36. win = jquery(window);
  37. };
  38. jquery(init);
  39. return {
  40. enable : enable
  41. };
  42. }());
  43. return {
  44. StickyNav : stickyNav
  45. };
  46. }($));