aboutsummaryrefslogtreecommitdiffhomepage
path: root/doc/html/js/theme.js
diff options
context:
space:
mode:
authornodiscc <nodiscc@gmail.com>2017-07-04 21:37:30 +0200
committerGitHub <noreply@github.com>2017-07-04 21:37:30 +0200
commit5b25a9635fe808bc1c4f3eee8cdf8485115da75d (patch)
treed5c46525f3c739d9c63de860427e0b3cadd688e5 /doc/html/js/theme.js
parentd5d22a6d07917865c44148ad76f43c65a929a890 (diff)
parent8bf94136e10c64496711c8f66a4f58f89c515360 (diff)
downloadShaarli-5b25a9635fe808bc1c4f3eee8cdf8485115da75d.tar.gz
Shaarli-5b25a9635fe808bc1c4f3eee8cdf8485115da75d.tar.zst
Shaarli-5b25a9635fe808bc1c4f3eee8cdf8485115da75d.zip
Merge pull request #772 from nodiscc/rtfd
Generate HTML documentation using MkDocs
Diffstat (limited to 'doc/html/js/theme.js')
-rw-r--r--doc/html/js/theme.js82
1 files changed, 82 insertions, 0 deletions
diff --git a/doc/html/js/theme.js b/doc/html/js/theme.js
new file mode 100644
index 00000000..99b146ec
--- /dev/null
+++ b/doc/html/js/theme.js
@@ -0,0 +1,82 @@
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");
6 });
7
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");
12 });
13
14 $(document).on('click', "[data-toggle='rst-current-version']", function() {
15 $("[data-toggle='rst-versions']").toggleClass("shift-up");
16 });
17
18 // Make tables responsive
19 $("table.docutils:not(.field-list)").wrap("<div class='wy-table-responsive'></div>");
20
21 hljs.initHighlightingOnLoad();
22
23 $('table').addClass('docutils');
24});
25
26window.SphinxRtdTheme = (function (jquery) {
27 var stickyNav = (function () {
28 var navBar,
29 win,
30 stickyNavCssClass = 'stickynav',
31 applyStickNav = function () {
32 if (navBar.height() <= win.height()) {
33 navBar.addClass(stickyNavCssClass);
34 } else {
35 navBar.removeClass(stickyNavCssClass);
36 }
37 },
38 enable = function () {
39 applyStickNav();
40 win.on('resize', applyStickNav);
41 },
42 init = function () {
43 navBar = jquery('nav.wy-nav-side:first');
44 win = jquery(window);
45 };
46 jquery(init);
47 return {
48 enable : enable
49 };
50 }());
51 return {
52 StickyNav : stickyNav
53 };
54}($));
55
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.
60//
61$(function() {
62 $.fn.isFullyWithinViewport = function(){
63 var viewport = {};
64 viewport.top = $(window).scrollTop();
65 viewport.bottom = viewport.top + $(window).height();
66 var bounds = {};
67 bounds.top = this.offset().top;
68 bounds.bottom = bounds.top + this.outerHeight();
69 return ( ! (
70 (bounds.top <= viewport.top) ||
71 (bounds.bottom >= viewport.bottom)
72 ) );
73 };
74 if( $('li.toctree-l1.current').length && !$('li.toctree-l1.current').isFullyWithinViewport() ) {
75 $('.wy-nav-side')
76 .scrollTop(
77 $('li.toctree-l1.current').offset().top -
78 $('.wy-nav-side').offset().top -
79 60
80 );
81 }
82});