From 4cc3c2ac1735196e4e6a18d1a1124cd0d9a0ed5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Thu, 3 Oct 2013 14:10:44 +0200 Subject: embed themes --- themes/default/js/restoreScroll.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 themes/default/js/restoreScroll.js (limited to 'themes/default/js/restoreScroll.js') diff --git a/themes/default/js/restoreScroll.js b/themes/default/js/restoreScroll.js new file mode 100644 index 00000000..331c9e19 --- /dev/null +++ b/themes/default/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 -- cgit v1.2.3