diff --git a/brutaldon/static/js/brutaldon-enhancements.js b/brutaldon/static/js/brutaldon-enhancements.js index 592a251..f8f8f22 100644 --- a/brutaldon/static/js/brutaldon-enhancements.js +++ b/brutaldon/static/js/brutaldon-enhancements.js @@ -145,3 +145,22 @@ function characterCount() { return $("#id_status").val().length + $("#id_spoiler_text").val().length; } + +function savePlace() +{ + sessionStorage.setItem("lastScrollPos", window.scrollY); + return true; +} + +function restorePlace(ev) +{ + var lastScrollPos = sessionStorage.getItem('lastScrollPos'); + Intercooler.ready(function (elt) + { + if (elt[0].tagName == 'BODY') + { + window.scrollTo(0, lastScrollPos); + } + }); + return false; +} diff --git a/brutaldon/templates/base.html b/brutaldon/templates/base.html index d9173fd..c5818d0 100644 --- a/brutaldon/templates/base.html +++ b/brutaldon/templates/base.html @@ -40,7 +40,8 @@ {% endif %} + ic-global-include='{"csrfmiddlewaretoken": "{{ csrf_token }}"}' + ic-on-beforeSend="savePlace()">
 
{% block navbar %}