diff --git a/tpl/js/restoreScroll.js b/tpl/js/restoreScroll.js new file mode 100644 index 0000000..331c9e1 --- /dev/null +++ b/tpl/js/restoreScroll.js @@ -0,0 +1,25 @@ +function supportsLocalStorage() { + try { + return 'localStorage' in window && window['localStorage'] !== null; + } catch (e) { + return false; + } +} + +function savePercent(id, percent) { + if (!supportsLocalStorage()) { return false; } + localStorage["poche.article." + id + ".percent"] = percent; + return true; +} + +function retrievePercent(id) { + if (!supportsLocalStorage()) { return false; } + + var bheight = $(document).height(); + var percent = localStorage["poche.article." + id + ".percent"]; + var scroll = bheight * percent; + + $('html,body').animate({scrollTop: scroll}, 'fast'); + + return true; +} \ No newline at end of file diff --git a/tpl/view.twig b/tpl/view.twig index 2b6d91d..f9405f4 100644 --- a/tpl/view.twig +++ b/tpl/view.twig @@ -37,4 +37,23 @@

{% trans "this article appears wrong?" %} {% trans "create an issue" %} {% trans "or" %} {% trans "contact us by mail" %}

+ + {% endblock %} \ No newline at end of file