theme.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({"sphinx-rtd-theme":[function(require,module,exports){
  2. var jQuery = (typeof(window) != 'undefined') ? window.jQuery : require('jquery');
  3. // Sphinx theme nav state
  4. function ThemeNav () {
  5. var nav = {
  6. navBar: null,
  7. win: null,
  8. winScroll: false,
  9. winResize: false,
  10. linkScroll: false,
  11. winPosition: 0,
  12. winHeight: null,
  13. docHeight: null,
  14. isRunning: null
  15. };
  16. nav.enable = function () {
  17. var self = this;
  18. jQuery(function ($) {
  19. self.init($);
  20. self.reset();
  21. self.win.on('hashchange', self.reset);
  22. // Set scroll monitor
  23. self.win.on('scroll', function () {
  24. if (!self.linkScroll) {
  25. self.winScroll = true;
  26. }
  27. });
  28. setInterval(function () { if (self.winScroll) self.onScroll(); }, 25);
  29. // Set resize monitor
  30. self.win.on('resize', function () {
  31. self.winResize = true;
  32. });
  33. setInterval(function () { if (self.winResize) self.onResize(); }, 25);
  34. self.onResize();
  35. });
  36. };
  37. nav.init = function ($) {
  38. var doc = $(document),
  39. self = this;
  40. this.navBar = $('div.wy-side-scroll:first');
  41. this.win = $(window);
  42. // Set up javascript UX bits
  43. $(document)
  44. // Shift nav in mobile when clicking the menu.
  45. .on('click', "[data-toggle='wy-nav-top']", function() {
  46. $("[data-toggle='wy-nav-shift']").toggleClass("shift");
  47. $("[data-toggle='rst-versions']").toggleClass("shift");
  48. })
  49. // Nav menu link click operations
  50. .on('click', ".wy-menu-vertical .current ul li a", function() {
  51. var target = $(this);
  52. // Close menu when you click a link.
  53. $("[data-toggle='wy-nav-shift']").removeClass("shift");
  54. $("[data-toggle='rst-versions']").toggleClass("shift");
  55. // Handle dynamic display of l3 and l4 nav lists
  56. self.toggleCurrent(target);
  57. self.hashChange();
  58. })
  59. .on('click', "[data-toggle='rst-current-version']", function() {
  60. $("[data-toggle='rst-versions']").toggleClass("shift-up");
  61. })
  62. // Make tables responsive
  63. $("table.docutils:not(.field-list)")
  64. .wrap("<div class='wy-table-responsive'></div>");
  65. // Add expand links to all parents of nested ul
  66. $('.wy-menu-vertical ul').not('.simple').siblings('a').each(function () {
  67. var link = $(this);
  68. expand = $('<span class="toctree-expand"></span>');
  69. expand.on('click', function (ev) {
  70. self.toggleCurrent(link);
  71. ev.stopPropagation();
  72. return false;
  73. });
  74. link.prepend(expand);
  75. });
  76. };
  77. nav.reset = function () {
  78. // Get anchor from URL and open up nested nav
  79. var anchor = encodeURI(window.location.hash);
  80. if (anchor) {
  81. try {
  82. var link = $('.wy-menu-vertical')
  83. .find('[href="' + anchor + '"]');
  84. $('.wy-menu-vertical li.toctree-l1 li.current')
  85. .removeClass('current');
  86. link.closest('li.toctree-l2').addClass('current');
  87. link.closest('li.toctree-l3').addClass('current');
  88. link.closest('li.toctree-l4').addClass('current');
  89. }
  90. catch (err) {
  91. console.log("Error expanding nav for anchor", err);
  92. }
  93. }
  94. };
  95. nav.onScroll = function () {
  96. this.winScroll = false;
  97. var newWinPosition = this.win.scrollTop(),
  98. winBottom = newWinPosition + this.winHeight,
  99. navPosition = this.navBar.scrollTop(),
  100. newNavPosition = navPosition + (newWinPosition - this.winPosition);
  101. if (newWinPosition < 0 || winBottom > this.docHeight) {
  102. return;
  103. }
  104. this.navBar.scrollTop(newNavPosition);
  105. this.winPosition = newWinPosition;
  106. };
  107. nav.onResize = function () {
  108. this.winResize = false;
  109. this.winHeight = this.win.height();
  110. this.docHeight = $(document).height();
  111. };
  112. nav.hashChange = function () {
  113. this.linkScroll = true;
  114. this.win.one('hashchange', function () {
  115. this.linkScroll = false;
  116. });
  117. };
  118. nav.toggleCurrent = function (elem) {
  119. var parent_li = elem.closest('li');
  120. parent_li.siblings('li.current').removeClass('current');
  121. parent_li.siblings().find('li.current').removeClass('current');
  122. parent_li.find('> ul li.current').removeClass('current');
  123. parent_li.toggleClass('current');
  124. }
  125. return nav;
  126. };
  127. module.exports.ThemeNav = ThemeNav();
  128. if (typeof(window) != 'undefined') {
  129. window.SphinxRtdTheme = { StickyNav: module.exports.ThemeNav };
  130. }
  131. },{"jquery":"jquery"}]},{},["sphinx-rtd-theme"]);