From fbdd2459014999b89f65678b3e0c348f91e27167 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Fri, 7 Feb 2020 07:50:11 +0100 Subject: Update static documentation --- docs/pkgdown.js | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'docs/pkgdown.js') diff --git a/docs/pkgdown.js b/docs/pkgdown.js index de9bd72..087a762 100644 --- a/docs/pkgdown.js +++ b/docs/pkgdown.js @@ -2,14 +2,12 @@ (function($) { $(function() { - $("#sidebar") - .stick_in_parent({offset_top: 40}) - .on('sticky_kit:bottom', function(e) { - $(this).parent().css('position', 'static'); - }) - .on('sticky_kit:unbottom', function(e) { - $(this).parent().css('position', 'relative'); - }); + $('.navbar-fixed-top').headroom(); + + $('body').css('padding-top', $('.navbar').height() + 10); + $(window).resize(function(){ + $('body').css('padding-top', $('.navbar').height() + 10); + }); $('body').scrollspy({ target: '#sidebar', @@ -25,9 +23,13 @@ for (var i = 0; i < links.length; i++) { if (links[i].getAttribute("href") === "#") continue; - var path = paths(links[i].pathname); + // Ignore external links + if (links[i].host !== location.host) + continue; + + var nav_path = paths(links[i].pathname); - var length = prefix_length(cur_path, path); + var length = prefix_length(nav_path, cur_path); if (length > max_length) { max_length = length; pos = i; @@ -52,13 +54,14 @@ return(pieces); } + // Returns -1 if not found function prefix_length(needle, haystack) { if (needle.length > haystack.length) - return(0); + return(-1); // Special case for length-0 haystack, since for loop won't run if (haystack.length === 0) { - return(needle.length === 0 ? 1 : 0); + return(needle.length === 0 ? 0 : -1); } for (var i = 0; i < haystack.length; i++) { @@ -78,9 +81,9 @@ element.setAttribute('data-original-title', tooltipOriginalTitle); } - if(Clipboard.isSupported()) { + if(ClipboardJS.isSupported()) { $(document).ready(function() { - var copyButton = ""; + var copyButton = ""; $(".examples, div.sourceCode").addClass("hasCopyButton"); @@ -91,7 +94,7 @@ $('.btn-copy-ex').tooltip({container: 'body'}); // Initialize clipboard: - var clipboardBtnCopies = new Clipboard('[data-clipboard-copy]', { + var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', { text: function(trigger) { return trigger.parentNode.textContent; } -- cgit v1.2.1