aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/Resources/static/themes/_global
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2016-09-28 10:30:18 +0200
committerThomas Citharel <tcit@tcit.fr>2016-09-28 10:30:18 +0200
commitc146f6940a176142084b4fc3c610d13aca60d90e (patch)
tree7bc4683febcf15a4fd6053bddd49e36c202adeda /app/Resources/static/themes/_global
parent55345331c47ca6f389e38a842584c3062476601d (diff)
downloadwallabag-c146f6940a176142084b4fc3c610d13aca60d90e.tar.gz
wallabag-c146f6940a176142084b4fc3c610d13aca60d90e.tar.zst
wallabag-c146f6940a176142084b4fc3c610d13aca60d90e.zip
Assets work
* ES6 all the things ! * ESLint checks everything * CSS fixes (use stylelint) * Fix #2231
Diffstat (limited to 'app/Resources/static/themes/_global')
-rw-r--r--app/Resources/static/themes/_global/js/bookmarklet.js6
-rw-r--r--app/Resources/static/themes/_global/js/restoreScroll.js25
-rw-r--r--app/Resources/static/themes/_global/js/tools.js50
3 files changed, 55 insertions, 26 deletions
diff --git a/app/Resources/static/themes/_global/js/bookmarklet.js b/app/Resources/static/themes/_global/js/bookmarklet.js
index 2afdfc3c..5174ff47 100644
--- a/app/Resources/static/themes/_global/js/bookmarklet.js
+++ b/app/Resources/static/themes/_global/js/bookmarklet.js
@@ -1,2 +1,6 @@
1 1
2top["bookmarklet-url@wallabag.org"]=""+"<!DOCTYPE html>"+"<html>"+"<head>"+"<title>bag it!</title>"+'<link rel="icon" href="tpl/img/favicon.ico" />'+"</head>"+"<body>"+"<script>"+"window.onload=function(){"+"window.setTimeout(function(){"+"history.back();"+"},250);"+"};"+"</scr"+"ipt>"+"</body>"+"</html>" 2top['bookmarklet-url@wallabag.org'] =
3 '<!DOCTYPE html><html><head><title>bag it!</title>' +
4 '<link rel="icon" href="tpl/img/favicon.ico" />' +
5 '</head><body><script>window.onload=function(){window.setTimeout' +
6 '(function(){history.back();},250);};</script></body></html>';
diff --git a/app/Resources/static/themes/_global/js/restoreScroll.js b/app/Resources/static/themes/_global/js/restoreScroll.js
deleted file mode 100644
index 9c4d7e20..00000000
--- a/app/Resources/static/themes/_global/js/restoreScroll.js
+++ /dev/null
@@ -1,25 +0,0 @@
1function supportsLocalStorage() {
2 try {
3 return 'localStorage' in window && window.localStorage !== null;
4 } catch (e) {
5 return false;
6 }
7}
8
9function savePercent(id, percent) {
10 if (!supportsLocalStorage()) { return false; }
11 localStorage['wallabag.article.' + id + '.percent'] = percent;
12 return true;
13}
14
15function 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}
diff --git a/app/Resources/static/themes/_global/js/tools.js b/app/Resources/static/themes/_global/js/tools.js
new file mode 100644
index 00000000..ab30deb1
--- /dev/null
+++ b/app/Resources/static/themes/_global/js/tools.js
@@ -0,0 +1,50 @@
1const $ = require('jquery');
2
3function supportsLocalStorage() {
4 try {
5 return 'localStorage' in window && window.localStorage !== null;
6 } catch (e) {
7 return false;
8 }
9}
10
11function savePercent(id, percent) {
12 if (!supportsLocalStorage()) { return false; }
13 localStorage[`wallabag.article.${id}.percent`] = percent;
14 return true;
15}
16
17function retrievePercent(id) {
18 if (!supportsLocalStorage()) { return false; }
19
20 const bheight = $(document).height();
21 const percent = localStorage[`wallabag.article.${id}.percent`];
22 const scroll = bheight * percent;
23
24 $('html,body').animate({ scrollTop: scroll }, 'fast');
25
26 return true;
27}
28
29function initFilters() {
30 // no display if filters not available
31 if ($('div').is('#filters')) {
32 $('#button_filters').show();
33 $('.button-collapse-right').sideNav({ edge: 'right' });
34 $('#clear_form_filters').on('click', () => {
35 $('#filters input').val('');
36 $('#filters :checked').removeAttr('checked');
37 return false;
38 });
39 }
40}
41
42function initExport() {
43 // no display if export not available
44 if ($('div').is('#export')) {
45 $('#button_export').show();
46 $('.button-collapse-right').sideNav({ edge: 'right' });
47 }
48}
49
50export { savePercent, retrievePercent, initFilters, initExport };