aboutsummaryrefslogtreecommitdiffstats
path: root/_static/js/theme.js
diff options
context:
space:
mode:
Diffstat (limited to '_static/js/theme.js')
-rwxr-xr-x_static/js/theme.js58
1 files changed, 37 insertions, 21 deletions
diff --git a/_static/js/theme.js b/_static/js/theme.js
index 48a9f06..af661a9 100755
--- a/_static/js/theme.js
+++ b/_static/js/theme.js
@@ -13,33 +13,36 @@ function ThemeNav () {
13 winPosition: 0, 13 winPosition: 0,
14 winHeight: null, 14 winHeight: null,
15 docHeight: null, 15 docHeight: null,
16 isRunning: null 16 isRunning: false
17 }; 17 };
18 18
19 nav.enable = function () { 19 nav.enable = function () {
20 var self = this; 20 var self = this;
21 21
22 jQuery(function ($) { 22 if (!self.isRunning) {
23 self.init($); 23 self.isRunning = true;
24 24 jQuery(function ($) {
25 self.reset(); 25 self.init($);
26 self.win.on('hashchange', self.reset); 26
27 27 self.reset();
28 // Set scroll monitor 28 self.win.on('hashchange', self.reset);
29 self.win.on('scroll', function () { 29
30 if (!self.linkScroll) { 30 // Set scroll monitor
31 self.winScroll = true; 31 self.win.on('scroll', function () {
32 } 32 if (!self.linkScroll) {
33 }); 33 self.winScroll = true;
34 setInterval(function () { if (self.winScroll) self.onScroll(); }, 25); 34 }
35 35 });
36 // Set resize monitor 36 setInterval(function () { if (self.winScroll) self.onScroll(); }, 25);
37 self.win.on('resize', function () { 37
38 self.winResize = true; 38 // Set resize monitor
39 self.win.on('resize', function () {
40 self.winResize = true;
41 });
42 setInterval(function () { if (self.winResize) self.onResize(); }, 25);
43 self.onResize();
39 }); 44 });
40 setInterval(function () { if (self.winResize) self.onResize(); }, 25); 45 };
41 self.onResize();
42 });
43 }; 46 };
44 47
45 nav.init = function ($) { 48 nav.init = function ($) {
@@ -95,6 +98,19 @@ function ThemeNav () {
95 try { 98 try {
96 var link = $('.wy-menu-vertical') 99 var link = $('.wy-menu-vertical')
97 .find('[href="' + anchor + '"]'); 100 .find('[href="' + anchor + '"]');
101 // If we didn't find a link, it may be because we clicked on
102 // something that is not in the sidebar (eg: when using
103 // sphinxcontrib.httpdomain it generates headerlinks but those
104 // aren't picked up and placed in the toctree). So let's find
105 // the closest header in the document and try with that one.
106 if (link.length === 0) {
107 var doc_link = $('.document a[href="' + anchor + '"]');
108 var closest_section = doc_link.closest('div.section');
109 // Try again with the closest section entry.
110 link = $('.wy-menu-vertical')
111 .find('[href="#' + closest_section.attr("id") + '"]');
112
113 }
98 $('.wy-menu-vertical li.toctree-l1 li.current') 114 $('.wy-menu-vertical li.toctree-l1 li.current')
99 .removeClass('current'); 115 .removeClass('current');
100 link.closest('li.toctree-l2').addClass('current'); 116 link.closest('li.toctree-l2').addClass('current');