From fd1d257184502e0f8fff10b05f53729498157253 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Sat, 15 Nov 2014 18:49:59 -0500 Subject: [PATCH] Javascript to shift window for in-page anchors. In my research about issues with in-page anchors, I found this code that might be useful. More details once I've adapted it. --- js/tex4ht-footnote-hack.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/js/tex4ht-footnote-hack.js b/js/tex4ht-footnote-hack.js index 78a5605..07b1fd8 100644 --- a/js/tex4ht-footnote-hack.js +++ b/js/tex4ht-footnote-hack.js @@ -25,3 +25,23 @@ $( ".footnote-mark" ).tooltip({ } }}); }); +// The following code was borrowed from: +// https://github.com/pierre-rouanet/sphinxjp.themes.basicstrap/commit/05ac6055be8cbb6097f16ab106df5244c19a067f +// which was licensed under the MIT license. + +$(window).load(function () { + /* + * Scroll the window to avoid the topnav bar + * https://github.com/twitter/bootstrap/issues/1768 + */ + if ($(".navbar.navbar-fixed-top").length > 0) { + // var navHeight = $(".navbar").height(), + var navHeight = 40, + shiftWindow = function() { scrollBy(0, -navHeight - 10); }; + + if (location.hash) { + setTimeout(shiftWindow, 1); + } + window.addEventListener("hashchange", shiftWindow); + } +});