]>
git.immae.eu Git - github/shaarli/Shaarli.git/blob - doc/html/js/theme.js
1 $( document
).ready(function() {
2 // Shift nav in mobile when clicking the menu.
3 $(document
).on('click', "[data-toggle='wy-nav-top']", function() {
4 $("[data-toggle='wy-nav-shift']").toggleClass("shift");
5 $("[data-toggle='rst-versions']").toggleClass("shift");
8 // Close menu when you click a link.
9 $(document
).on('click', ".wy-menu-vertical .current ul li a", function() {
10 $("[data-toggle='wy-nav-shift']").removeClass("shift");
11 $("[data-toggle='rst-versions']").toggleClass("shift");
14 $(document
).on('click', "[data-toggle='rst-current-version']", function() {
15 $("[data-toggle='rst-versions']").toggleClass("shift-up");
18 // Make tables responsive
19 $("table.docutils:not(.field-list)").wrap("<div class='wy-table-responsive'></div>");
21 hljs
.initHighlightingOnLoad();
23 $('table').addClass('docutils');
26 window
.SphinxRtdTheme
= (function (jquery
) {
27 var stickyNav
= (function () {
30 stickyNavCssClass
= 'stickynav',
31 applyStickNav = function () {
32 if (navBar
.height() <= win
.height()) {
33 navBar
.addClass(stickyNavCssClass
);
35 navBar
.removeClass(stickyNavCssClass
);
38 enable = function () {
40 win
.on('resize', applyStickNav
);
43 navBar
= jquery('nav.wy-nav-side:first');
56 // The code below is a copy of @seanmadsen code posted Jan 10, 2017 on issue 803.
57 // https://github.com/mkdocs/mkdocs/issues/803
58 // This just incorporates the auto scroll into the theme itself without
59 // the need for additional custom.js file.
62 $.fn
.isFullyWithinViewport = function(){
64 viewport
.top
= $(window
).scrollTop();
65 viewport
.bottom
= viewport
.top
+ $(window
).height();
67 bounds
.top
= this.offset().top
;
68 bounds
.bottom
= bounds
.top
+ this.outerHeight();
70 (bounds
.top
<= viewport
.top
) ||
71 (bounds
.bottom
>= viewport
.bottom
)
74 if( $('li.toctree-l1.current').length
&& !$('li.toctree-l1.current').isFullyWithinViewport() ) {
77 $('li.toctree-l1.current').offset().top
-
78 $('.wy-nav-side').offset().top
-