diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2016-06-23 09:25:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-23 09:25:01 +0200 |
commit | 49e2854d5c15bbce3f24f91da34450e8f209295b (patch) | |
tree | f5aa95445549cc151e86f144b40464eecee28cf7 /app/Resources/static/themes/_global/js/restoreScroll.js | |
parent | 4eaaa27bb5b9a5725b26471a39548d764fc9cd0a (diff) | |
parent | 496cfdc0172fd55cb555f74b64704c8f50c71b77 (diff) | |
download | wallabag-49e2854d5c15bbce3f24f91da34450e8f209295b.tar.gz wallabag-49e2854d5c15bbce3f24f91da34450e8f209295b.tar.zst wallabag-49e2854d5c15bbce3f24f91da34450e8f209295b.zip |
Merge pull request #2142 from wallabag/v2-use-npm
Manage assets through npm
Diffstat (limited to 'app/Resources/static/themes/_global/js/restoreScroll.js')
-rw-r--r-- | app/Resources/static/themes/_global/js/restoreScroll.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/app/Resources/static/themes/_global/js/restoreScroll.js b/app/Resources/static/themes/_global/js/restoreScroll.js new file mode 100644 index 00000000..9c4d7e20 --- /dev/null +++ b/app/Resources/static/themes/_global/js/restoreScroll.js | |||
@@ -0,0 +1,25 @@ | |||
1 | function supportsLocalStorage() { | ||
2 | try { | ||
3 | return 'localStorage' in window && window.localStorage !== null; | ||
4 | } catch (e) { | ||
5 | return false; | ||
6 | } | ||
7 | } | ||
8 | |||
9 | function savePercent(id, percent) { | ||
10 | if (!supportsLocalStorage()) { return false; } | ||
11 | localStorage['wallabag.article.' + id + '.percent'] = percent; | ||
12 | return true; | ||
13 | } | ||
14 | |||
15 | function retrievePercent(id) { | ||
16 | if (!supportsLocalStorage()) { return false; } | ||
17 | |||
18 | var bheight = $(document).height(); | ||
19 | var percent = localStorage['wallabag.article.' + id + '.percent']; | ||
20 | var scroll = bheight * percent; | ||
21 | |||
22 | $('html,body').animate({ scrollTop: scroll }, 'fast'); | ||
23 | |||
24 | return true; | ||
25 | } | ||