theme.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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: false
  15. };
  16. nav.enable = function () {
  17. var self = this;
  18. if (!self.isRunning) {
  19. self.isRunning = true;
  20. jQuery(function ($) {
  21. self.init($);
  22. self.reset();
  23. self.win.on('hashchange', self.reset);
  24. // Set scroll monitor
  25. self.win.on('scroll', function () {
  26. if (!self.linkScroll) {
  27. self.winScroll = true;
  28. }
  29. });
  30. setInterval(function () { if (self.winScroll) self.onScroll(); }, 25);
  31. // Set resize monitor
  32. self.win.on('resize', function () {
  33. self.winResize = true;
  34. });
  35. setInterval(function () { if (self.winResize) self.onResize(); }, 25);
  36. self.onResize();
  37. });
  38. };
  39. };
  40. nav.init = function ($) {
  41. var doc = $(document),
  42. self = this;
  43. this.navBar = $('div.wy-side-scroll:first');
  44. this.win = $(window);
  45. // Set up javascript UX bits
  46. $(document)
  47. // Shift nav in mobile when clicking the menu.
  48. .on('click', "[data-toggle='wy-nav-top']", function() {
  49. $("[data-toggle='wy-nav-shift']").toggleClass("shift");
  50. $("[data-toggle='rst-versions']").toggleClass("shift");
  51. })
  52. // Nav menu link click operations
  53. .on('click', ".wy-menu-vertical .current ul li a", function() {
  54. var target = $(this);
  55. // Close menu when you click a link.
  56. $("[data-toggle='wy-nav-shift']").removeClass("shift");
  57. $("[data-toggle='rst-versions']").toggleClass("shift");
  58. // Handle dynamic display of l3 and l4 nav lists
  59. self.toggleCurrent(target);
  60. self.hashChange();
  61. })
  62. .on('click', "[data-toggle='rst-current-version']", function() {
  63. $("[data-toggle='rst-versions']").toggleClass("shift-up");
  64. })
  65. // Make tables responsive
  66. $("table.docutils:not(.field-list)")
  67. .wrap("<div class='wy-table-responsive'></div>");
  68. // Add expand links to all parents of nested ul
  69. $('.wy-menu-vertical ul').not('.simple').siblings('a').each(function () {
  70. var link = $(this);
  71. expand = $('<span class="toctree-expand"></span>');
  72. expand.on('click', function (ev) {
  73. self.toggleCurrent(link);
  74. ev.stopPropagation();
  75. return false;
  76. });
  77. link.prepend(expand);
  78. });
  79. };
  80. nav.reset = function () {
  81. // Get anchor from URL and open up nested nav
  82. var anchor = encodeURI(window.location.hash);
  83. if (anchor) {
  84. try {
  85. var link = $('.wy-menu-vertical')
  86. .find('[href="' + anchor + '"]');
  87. // If we didn't find a link, it may be because we clicked on
  88. // something that is not in the sidebar (eg: when using
  89. // sphinxcontrib.httpdomain it generates headerlinks but those
  90. // aren't picked up and placed in the toctree). So let's find
  91. // the closest header in the document and try with that one.
  92. if (link.length === 0) {
  93. var doc_link = $('.document a[href="' + anchor + '"]');
  94. var closest_section = doc_link.closest('div.section');
  95. // Try again with the closest section entry.
  96. link = $('.wy-menu-vertical')
  97. .find('[href="#' + closest_section.attr("id") + '"]');
  98. }
  99. $('.wy-menu-vertical li.toctree-l1 li.current')
  100. .removeClass('current');
  101. link.closest('li.toctree-l2').addClass('current');
  102. link.closest('li.toctree-l3').addClass('current');
  103. link.closest('li.toctree-l4').addClass('current');
  104. }
  105. catch (err) {
  106. console.log("Error expanding nav for anchor", err);
  107. }
  108. }
  109. };
  110. nav.onScroll = function () {
  111. this.winScroll = false;
  112. var newWinPosition = this.win.scrollTop(),
  113. winBottom = newWinPosition + this.winHeight,
  114. navPosition = this.navBar.scrollTop(),
  115. newNavPosition = navPosition + (newWinPosition - this.winPosition);
  116. if (newWinPosition < 0 || winBottom > this.docHeight) {
  117. return;
  118. }
  119. this.navBar.scrollTop(newNavPosition);
  120. this.winPosition = newWinPosition;
  121. };
  122. nav.onResize = function () {
  123. this.winResize = false;
  124. this.winHeight = this.win.height();
  125. this.docHeight = $(document).height();
  126. };
  127. nav.hashChange = function () {
  128. this.linkScroll = true;
  129. this.win.one('hashchange', function () {
  130. this.linkScroll = false;
  131. });
  132. };
  133. nav.toggleCurrent = function (elem) {
  134. var parent_li = elem.closest('li');
  135. parent_li.siblings('li.current').removeClass('current');
  136. parent_li.siblings().find('li.current').removeClass('current');
  137. parent_li.find('> ul li.current').removeClass('current');
  138. parent_li.toggleClass('current');
  139. }
  140. return nav;
  141. };
  142. module.exports.ThemeNav = ThemeNav();
  143. if (typeof(window) != 'undefined') {
  144. window.SphinxRtdTheme = { StickyNav: module.exports.ThemeNav };
  145. }
  146. },{"jquery":"jquery"}]},{},["sphinx-rtd-theme"]);