2015-04-23 15:40:08 +08:00
|
|
|
function toggleCurrent (elem) {
|
|
|
|
var parent_li = elem.closest('li');
|
|
|
|
parent_li.siblings('li.current').removeClass('current');
|
|
|
|
parent_li.siblings().find('li.current').removeClass('current');
|
|
|
|
parent_li.find('> ul li.current').removeClass('current');
|
|
|
|
parent_li.toggleClass('current');
|
|
|
|
}
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
2014-01-19 08:50:22 +08:00
|
|
|
// Shift nav in mobile when clicking the menu.
|
|
|
|
$(document).on('click', "[data-toggle='wy-nav-top']", function() {
|
2015-04-23 15:40:08 +08:00
|
|
|
$("[data-toggle='wy-nav-shift']").toggleClass("shift");
|
|
|
|
$("[data-toggle='rst-versions']").toggleClass("shift");
|
2014-01-19 08:50:22 +08:00
|
|
|
});
|
2015-04-23 15:40:08 +08:00
|
|
|
// Nav menu link click operations
|
2014-01-19 08:50:22 +08:00
|
|
|
$(document).on('click', ".wy-menu-vertical .current ul li a", function() {
|
2015-04-23 15:40:08 +08:00
|
|
|
var target = $(this);
|
|
|
|
// Close menu when you click a link.
|
|
|
|
$("[data-toggle='wy-nav-shift']").removeClass("shift");
|
|
|
|
$("[data-toggle='rst-versions']").toggleClass("shift");
|
|
|
|
// Handle dynamic display of l3 and l4 nav lists
|
|
|
|
toggleCurrent(target);
|
|
|
|
if (typeof(window.SphinxRtdTheme) != 'undefined') {
|
|
|
|
window.SphinxRtdTheme.StickyNav.hashChange();
|
|
|
|
}
|
2014-01-19 08:50:22 +08:00
|
|
|
});
|
|
|
|
$(document).on('click', "[data-toggle='rst-current-version']", function() {
|
2015-04-23 15:40:08 +08:00
|
|
|
$("[data-toggle='rst-versions']").toggleClass("shift-up");
|
|
|
|
});
|
2014-01-19 08:50:22 +08:00
|
|
|
// Make tables responsive
|
|
|
|
$("table.docutils:not(.field-list)").wrap("<div class='wy-table-responsive'></div>");
|
2015-04-23 15:40:08 +08:00
|
|
|
|
|
|
|
// Add expand links to all parents of nested ul
|
2015-07-17 15:18:02 +08:00
|
|
|
$('.wy-menu-vertical ul').not('.simple').siblings('a').each(function () {
|
2015-04-23 15:40:08 +08:00
|
|
|
var link = $(this);
|
|
|
|
expand = $('<span class="toctree-expand"></span>');
|
|
|
|
expand.on('click', function (ev) {
|
|
|
|
toggleCurrent(link);
|
|
|
|
ev.stopPropagation();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
link.prepend(expand);
|
|
|
|
});
|
2013-10-22 06:52:35 +08:00
|
|
|
});
|
2014-01-08 06:39:48 +08:00
|
|
|
|
2015-04-23 15:40:08 +08:00
|
|
|
// Sphinx theme state
|
2014-01-08 06:39:48 +08:00
|
|
|
window.SphinxRtdTheme = (function (jquery) {
|
|
|
|
var stickyNav = (function () {
|
|
|
|
var navBar,
|
|
|
|
win,
|
2014-06-12 00:30:56 +08:00
|
|
|
winScroll = false,
|
2015-07-18 06:48:27 +08:00
|
|
|
winResize = false,
|
2015-04-23 15:40:08 +08:00
|
|
|
linkScroll = false,
|
|
|
|
winPosition = 0,
|
2015-07-18 06:48:27 +08:00
|
|
|
winHeight,
|
|
|
|
docHeight,
|
2014-01-08 06:39:48 +08:00
|
|
|
enable = function () {
|
2015-04-23 15:40:08 +08:00
|
|
|
init();
|
|
|
|
reset();
|
|
|
|
win.on('hashchange', reset);
|
|
|
|
|
2015-07-18 06:48:27 +08:00
|
|
|
// Set scroll monitor
|
2015-04-23 15:40:08 +08:00
|
|
|
win.on('scroll', function () {
|
|
|
|
if (!linkScroll) {
|
|
|
|
winScroll = true;
|
|
|
|
}
|
2014-06-12 00:30:56 +08:00
|
|
|
});
|
2015-07-18 06:48:27 +08:00
|
|
|
setInterval(function () { if (winScroll) scroll(); }, 25);
|
|
|
|
|
|
|
|
// Set resize monitor
|
|
|
|
win.on('resize', function () {
|
|
|
|
winResize = true;
|
|
|
|
});
|
|
|
|
setInterval(function () { if (winResize) resize(); }, 25);
|
|
|
|
resize();
|
2014-01-08 06:39:48 +08:00
|
|
|
},
|
|
|
|
init = function () {
|
|
|
|
navBar = jquery('nav.wy-nav-side:first');
|
2015-04-23 15:40:08 +08:00
|
|
|
win = jquery(window);
|
|
|
|
},
|
|
|
|
reset = function () {
|
|
|
|
// Get anchor from URL and open up nested nav
|
|
|
|
var anchor = encodeURI(window.location.hash);
|
|
|
|
if (anchor) {
|
|
|
|
try {
|
|
|
|
var link = $('.wy-menu-vertical')
|
|
|
|
.find('[href="' + anchor + '"]');
|
|
|
|
$('.wy-menu-vertical li.toctree-l1 li.current')
|
|
|
|
.removeClass('current');
|
|
|
|
link.closest('li.toctree-l2').addClass('current');
|
|
|
|
link.closest('li.toctree-l3').addClass('current');
|
|
|
|
link.closest('li.toctree-l4').addClass('current');
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
console.log("Error expanding nav for anchor", err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2015-07-18 06:48:27 +08:00
|
|
|
scroll = function () {
|
|
|
|
winScroll = false;
|
|
|
|
var newWinPosition = win.scrollTop(),
|
|
|
|
winBottom = newWinPosition + winHeight,
|
|
|
|
navPosition = navBar.scrollTop(),
|
|
|
|
newNavPosition = navPosition + (newWinPosition - winPosition);
|
|
|
|
if (newWinPosition < 0 || winBottom > docHeight) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
navBar.scrollTop(newNavPosition);
|
|
|
|
winPosition = newWinPosition;
|
|
|
|
},
|
|
|
|
resize = function () {
|
|
|
|
winResize = false;
|
|
|
|
winHeight = win.height();
|
|
|
|
docHeight = $(document).height();
|
|
|
|
},
|
2015-04-23 15:40:08 +08:00
|
|
|
hashChange = function () {
|
|
|
|
linkScroll = true;
|
|
|
|
win.one('hashchange', function () {
|
|
|
|
linkScroll = false;
|
|
|
|
});
|
2014-01-08 06:39:48 +08:00
|
|
|
};
|
|
|
|
jquery(init);
|
|
|
|
return {
|
2015-04-23 15:40:08 +08:00
|
|
|
enable: enable,
|
|
|
|
hashChange: hashChange
|
2014-01-08 06:39:48 +08:00
|
|
|
};
|
|
|
|
}());
|
|
|
|
return {
|
2015-04-23 15:40:08 +08:00
|
|
|
StickyNav: stickyNav
|
2014-01-08 06:39:48 +08:00
|
|
|
};
|
2014-01-19 08:50:22 +08:00
|
|
|
}($));
|