theme.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. $('.wy-menu-vertical li.toctree-l1 li.current')
  88. .removeClass('current');
  89. link.closest('li.toctree-l2').addClass('current');
  90. link.closest('li.toctree-l3').addClass('current');
  91. link.closest('li.toctree-l4').addClass('current');
  92. }
  93. catch (err) {
  94. console.log("Error expanding nav for anchor", err);
  95. }
  96. }
  97. };
  98. nav.onScroll = function () {
  99. this.winScroll = false;
  100. var newWinPosition = this.win.scrollTop(),
  101. winBottom = newWinPosition + this.winHeight,
  102. navPosition = this.navBar.scrollTop(),
  103. newNavPosition = navPosition + (newWinPosition - this.winPosition);
  104. if (newWinPosition < 0 || winBottom > this.docHeight) {
  105. return;
  106. }
  107. this.navBar.scrollTop(newNavPosition);
  108. this.winPosition = newWinPosition;
  109. };
  110. nav.onResize = function () {
  111. this.winResize = false;
  112. this.winHeight = this.win.height();
  113. this.docHeight = $(document).height();
  114. };
  115. nav.hashChange = function () {
  116. this.linkScroll = true;
  117. this.win.one('hashchange', function () {
  118. this.linkScroll = false;
  119. });
  120. };
  121. nav.toggleCurrent = function (elem) {
  122. var parent_li = elem.closest('li');
  123. parent_li.siblings('li.current').removeClass('current');
  124. parent_li.siblings().find('li.current').removeClass('current');
  125. parent_li.find('> ul li.current').removeClass('current');
  126. parent_li.toggleClass('current');
  127. }
  128. return nav;
  129. };
  130. module.exports.ThemeNav = ThemeNav();
  131. if (typeof(window) != 'undefined') {
  132. window.SphinxRtdTheme = { StickyNav: module.exports.ThemeNav };
  133. }
  134. },{"jquery":"jquery"}]},{},["sphinx-rtd-theme"]);