From 5ed8050791ef562ff4351ede3a077ab1e8b0d916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Wed, 8 Jan 2014 11:28:46 +0100 Subject: [add] courgette theme --- themes/courgette/js/init.js | 6 ++++++ themes/courgette/js/restoreScroll.js | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100755 themes/courgette/js/init.js create mode 100755 themes/courgette/js/restoreScroll.js (limited to 'themes/courgette/js') diff --git a/themes/courgette/js/init.js b/themes/courgette/js/init.js new file mode 100755 index 00000000..dca83906 --- /dev/null +++ b/themes/courgette/js/init.js @@ -0,0 +1,6 @@ +$.fn.ready(function () { + $('#menu').on('click', function(){ + $('body').toggleClass('menuOpen'); + $('#menuContainer, #article_toolbar').toggleClass('open'); + }); +}) \ No newline at end of file diff --git a/themes/courgette/js/restoreScroll.js b/themes/courgette/js/restoreScroll.js new file mode 100755 index 00000000..331c9e19 --- /dev/null +++ b/themes/courgette/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