|
1 | | -function toggleCurrent (elem) { |
2 | | - var parent_li = elem.closest('li'); |
3 | | - parent_li.siblings('li.current').removeClass('current'); |
4 | | - parent_li.siblings().find('li.current').removeClass('current'); |
5 | | - parent_li.find('> ul li.current').removeClass('current'); |
6 | | - parent_li.toggleClass('current'); |
| 1 | +function toggleCurrent(elem) |
| 2 | +{ |
| 3 | + var parent_li = elem.closest('li'); |
| 4 | + parent_li.siblings('li.current').removeClass('current'); |
| 5 | + parent_li.siblings().find('li.current').removeClass('current'); |
| 6 | + parent_li.find('> ul li.current').removeClass('current'); |
| 7 | + parent_li.toggleClass('current'); |
7 | 8 | } |
8 | 9 |
|
9 | 10 | $(document).ready(function() { |
10 | | - // Shift nav in mobile when clicking the menu. |
11 | | - $(document).on('click', "[data-toggle='wy-nav-top']", function() { |
12 | | - $("[data-toggle='wy-nav-shift']").toggleClass("shift"); |
13 | | - $("[data-toggle='rst-versions']").toggleClass("shift"); |
14 | | - }); |
15 | | - // Nav menu link click operations |
16 | | - $(document).on('click', ".wy-menu-vertical .current ul li a", function() { |
17 | | - var target = $(this); |
18 | | - // Close menu when you click a link. |
19 | | - $("[data-toggle='wy-nav-shift']").removeClass("shift"); |
20 | | - $("[data-toggle='rst-versions']").toggleClass("shift"); |
21 | | - // Handle dynamic display of l3 and l4 nav lists |
22 | | - toggleCurrent(target); |
23 | | - if (typeof(window.SphinxRtdTheme) != 'undefined') { |
24 | | - window.SphinxRtdTheme.StickyNav.hashChange(); |
25 | | - } |
26 | | - }); |
27 | | - $(document).on('click', "[data-toggle='rst-current-version']", function() { |
28 | | - $("[data-toggle='rst-versions']").toggleClass("shift-up"); |
29 | | - }); |
30 | | - // Make tables responsive |
31 | | - $("table.docutils:not(.field-list)").wrap("<div class='wy-table-responsive'></div>"); |
| 11 | + // Shift nav in mobile when clicking the menu. |
| 12 | + $(document).on('click', '[data-toggle=\'wy-nav-top\']', function() { |
| 13 | + $('[data-toggle=\'wy-nav-shift\']').toggleClass('shift'); |
| 14 | + $('[data-toggle=\'rst-versions\']').toggleClass('shift'); |
| 15 | + }); |
| 16 | + // Nav menu link click operations |
| 17 | + $(document).on('click', '.wy-menu-vertical .current ul li a', function() { |
| 18 | + var target = $(this); |
| 19 | + // Close menu when you click a link. |
| 20 | + $('[data-toggle=\'wy-nav-shift\']').removeClass('shift'); |
| 21 | + $('[data-toggle=\'rst-versions\']').toggleClass('shift'); |
| 22 | + // Handle dynamic display of l3 and l4 nav lists |
| 23 | + toggleCurrent(target); |
| 24 | + if (typeof (window.SphinxRtdTheme) != 'undefined') |
| 25 | + { |
| 26 | + window.SphinxRtdTheme.StickyNav.hashChange(); |
| 27 | + } |
| 28 | + }); |
| 29 | + $(document).on('click', '[data-toggle=\'rst-current-version\']', function() { |
| 30 | + $('[data-toggle=\'rst-versions\']').toggleClass('shift-up'); |
| 31 | + }); |
| 32 | + // Make tables responsive |
| 33 | + $('table.docutils:not(.field-list)').wrap('<div class=\'wy-table-responsive\'></div>'); |
32 | 34 |
|
33 | | - // Add expand links to all parents of nested ul |
34 | | - $('.wy-menu-vertical ul').siblings('a').each(function () { |
35 | | - var link = $(this); |
36 | | - expand = $('<span class="toctree-expand"></span>'); |
37 | | - expand.on('click', function (ev) { |
38 | | - toggleCurrent(link); |
39 | | - ev.stopPropagation(); |
40 | | - return false; |
41 | | - }); |
42 | | - link.prepend(expand); |
| 35 | + // Add expand links to all parents of nested ul |
| 36 | + $('.wy-menu-vertical ul').siblings('a').each(function() { |
| 37 | + var link = $(this); |
| 38 | + expand = $('<span class="toctree-expand"></span>'); |
| 39 | + expand.on('click', function(ev) { |
| 40 | + toggleCurrent(link); |
| 41 | + ev.stopPropagation(); |
| 42 | + return false; |
43 | 43 | }); |
| 44 | + link.prepend(expand); |
| 45 | + }); |
44 | 46 | }); |
45 | 47 |
|
46 | 48 | // Sphinx theme state |
47 | | -window.SphinxRtdTheme = (function (jquery) { |
48 | | - var stickyNav = (function () { |
49 | | - var navBar, |
50 | | - win, |
51 | | - winScroll = false, |
52 | | - linkScroll = false, |
53 | | - winPosition = 0, |
54 | | - enable = function () { |
55 | | - init(); |
56 | | - reset(); |
57 | | - win.on('hashchange', reset); |
| 49 | +window.SphinxRtdTheme = (function(jquery) { |
| 50 | + var stickyNav = (function() { |
| 51 | + var navBar, win, winScroll = false, linkScroll = false, winPosition = 0, enable = function() { |
| 52 | + init(); |
| 53 | + reset(); |
| 54 | + win.on('hashchange', reset); |
58 | 55 |
|
59 | | - // Set scrolling |
60 | | - win.on('scroll', function () { |
61 | | - if (!linkScroll) { |
62 | | - winScroll = true; |
63 | | - } |
64 | | - }); |
65 | | - setInterval(function () { |
66 | | - if (winScroll) { |
67 | | - winScroll = false; |
68 | | - var newWinPosition = win.scrollTop(), |
69 | | - navPosition = navBar.scrollTop(), |
70 | | - newNavPosition = navPosition + (newWinPosition - winPosition); |
71 | | - navBar.scrollTop(newNavPosition); |
72 | | - winPosition = newWinPosition; |
73 | | - } |
74 | | - }, 25); |
75 | | - }, |
76 | | - init = function () { |
77 | | - navBar = jquery('nav.wy-nav-side:first'); |
78 | | - win = jquery(window); |
79 | | - }, |
80 | | - 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 | | - hashChange = function () { |
99 | | - linkScroll = true; |
100 | | - win.one('hashchange', function () { |
101 | | - linkScroll = false; |
102 | | - }); |
103 | | - }; |
104 | | - jquery(init); |
105 | | - return { |
106 | | - enable: enable, |
107 | | - hashChange: hashChange |
108 | | - }; |
109 | | - }()); |
110 | | - return { |
111 | | - StickyNav: stickyNav |
| 56 | + // Set scrolling |
| 57 | + win.on('scroll', function() { |
| 58 | + if (!linkScroll) |
| 59 | + { |
| 60 | + winScroll = true; |
| 61 | + } |
| 62 | + }); |
| 63 | + setInterval(function() { |
| 64 | + if (winScroll) |
| 65 | + { |
| 66 | + winScroll = false; |
| 67 | + var newWinPosition = win.scrollTop(), navPosition = navBar.scrollTop(), |
| 68 | + newNavPosition = navPosition + (newWinPosition - winPosition); |
| 69 | + navBar.scrollTop(newNavPosition); |
| 70 | + winPosition = newWinPosition; |
| 71 | + } |
| 72 | + }, 25); |
| 73 | + }, init = function() { |
| 74 | + navBar = jquery('nav.wy-nav-side:first'); |
| 75 | + win = jquery(window); |
| 76 | + }, reset = function() { |
| 77 | + // Get anchor from URL and open up nested nav |
| 78 | + var anchor = encodeURI(window.location.hash); |
| 79 | + if (anchor) |
| 80 | + { |
| 81 | + try |
| 82 | + { |
| 83 | + var link = $('.wy-menu-vertical').find('[href="' + anchor + '"]'); |
| 84 | + $('.wy-menu-vertical li.toctree-l1 li.current').removeClass('current'); |
| 85 | + link.closest('li.toctree-l2').addClass('current'); |
| 86 | + link.closest('li.toctree-l3').addClass('current'); |
| 87 | + link.closest('li.toctree-l4').addClass('current'); |
| 88 | + } |
| 89 | + catch (err) |
| 90 | + { |
| 91 | + console.log('Error expanding nav for anchor', err); |
| 92 | + } |
| 93 | + } |
| 94 | + }, hashChange = function() { |
| 95 | + linkScroll = true; |
| 96 | + win.one('hashchange', function() { |
| 97 | + linkScroll = false; |
| 98 | + }); |
112 | 99 | }; |
| 100 | + jquery(init); |
| 101 | + return { enable: enable, hashChange: hashChange }; |
| 102 | + }()); |
| 103 | + return { StickyNav: stickyNav }; |
113 | 104 | }($)); |
0 commit comments