diff --git a/assets/ts_src/event_listeners.ts b/assets/ts_src/event_listeners.ts index a0ebe799..7f37307f 100644 --- a/assets/ts_src/event_listeners.ts +++ b/assets/ts_src/event_listeners.ts @@ -128,6 +128,28 @@ $(document).on("ajaxUI:start ajaxUI:reload", function () { }); +/** + * Register the button, to jump to the top of the page. + */ +$(document).on("ajaxUI:start", function registerJumpToTop() { + $(window).scroll(function () { + if ($(this).scrollTop() > 50) { + $('#back-to-top').fadeIn(); + } else { + $('#back-to-top').fadeOut(); + } + }); + // scroll body to 0px on click + $('#back-to-top').click(function () { + $('#back-to-top').tooltip('hide'); + $('body,html').animate({ + scrollTop: 0 + }, 800); + return false; + }).tooltip(); +}); + + //Need for proper body padding, with every navbar height $(window).resize(function () { let height : number = $('#navbar').height() + 10; diff --git a/templates/base.html.twig b/templates/base.html.twig index fc847050..ba8375b7 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -262,6 +262,15 @@ + { + + {# Back to top buton #} + + + + + {% endblock %}