theme.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. hljs.initHighlightingOnLoad();
  18. $('table').addClass('docutils');
  19. });
  20. window.SphinxRtdTheme = (function (jquery) {
  21. var stickyNav = (function () {
  22. var navBar,
  23. win,
  24. stickyNavCssClass = 'stickynav',
  25. applyStickNav = function () {
  26. if (navBar.height() <= win.height()) {
  27. navBar.addClass(stickyNavCssClass);
  28. } else {
  29. navBar.removeClass(stickyNavCssClass);
  30. }
  31. },
  32. enable = function () {
  33. applyStickNav();
  34. win.on('resize', applyStickNav);
  35. },
  36. init = function () {
  37. navBar = jquery('nav.wy-nav-side:first');
  38. win = jquery(window);
  39. };
  40. jquery(init);
  41. return {
  42. enable : enable
  43. };
  44. }());
  45. return {
  46. StickyNav : stickyNav
  47. };
  48. }($));