diff --git a/themes/schliesspendel/layouts/partials/footer.html b/themes/schliesspendel/layouts/partials/footer.html index 531c082..7aed40a 100644 --- a/themes/schliesspendel/layouts/partials/footer.html +++ b/themes/schliesspendel/layouts/partials/footer.html @@ -5,5 +5,7 @@

Icons: material.io, CSS-Framework: Skeleton, Generator: Hugo

+ + diff --git a/themes/schliesspendel/static/js/site.js b/themes/schliesspendel/static/js/site.js new file mode 100644 index 0000000..22b8229 --- /dev/null +++ b/themes/schliesspendel/static/js/site.js @@ -0,0 +1,62 @@ +$(document).ready(function() { + + // Variables + var $nav = $('.navbar'), + $body = $('body'), + $window = $(window), + navOffsetTop = $nav.offset().top, + $document = $(document), + entityMap = { + "&": "&", + "<": "<", + ">": ">", + '"': '"', + "'": ''', + "/": '/' + } + + function init() { + $window.on('scroll', onScroll) + $window.on('resize', resize) + $('a[href^="#"]').on('click', smoothScroll) + buildSnippets(); + } + + function smoothScroll(e) { + e.preventDefault(); + $(document).off("scroll"); + var target = this.hash, + menu = target; + $target = $(target); + $('html, body').stop().animate({ + 'scrollTop': $target.offset().top-40 + }, 0, 'swing', function () { + window.location.hash = target; + $(document).on("scroll", onScroll); + }); + } + + function resize() { + $body.removeClass('has-docked-nav') + navOffsetTop = $nav.offset().top + onScroll() + } + + function onScroll() { + if(navOffsetTop < $window.scrollTop() && !$body.hasClass('has-docked-nav')) { + $body.addClass('has-docked-nav') + } + if(navOffsetTop > $window.scrollTop() && $body.hasClass('has-docked-nav')) { + $body.removeClass('has-docked-nav') + } + } + + function escapeHtml(string) { + return String(string).replace(/[&<>"'\/]/g, function (s) { + return entityMap[s]; + }); + } + + init(); + +});