]> git.immae.eu Git - github/wallabag/wallabag.git/blame - app/Resources/static/themes/_global/js/tools.js
Merge pull request #2180 from wallabag/download-pictures
[github/wallabag/wallabag.git] / app / Resources / static / themes / _global / js / tools.js
CommitLineData
c146f694
TC
1const $ = require('jquery');
2
32508ef0
TC
3/* Allows inline call qr-code call */
4import jrQrcode from 'jr-qrcode'; // eslint-disable-line
e61ee560 5
c146f694
TC
6function supportsLocalStorage() {
7 try {
8 return 'localStorage' in window && window.localStorage !== null;
9 } catch (e) {
10 return false;
11 }
12}
13
14function savePercent(id, percent) {
15 if (!supportsLocalStorage()) { return false; }
16 localStorage[`wallabag.article.${id}.percent`] = percent;
17 return true;
18}
19
20function retrievePercent(id) {
21 if (!supportsLocalStorage()) { return false; }
22
23 const bheight = $(document).height();
24 const percent = localStorage[`wallabag.article.${id}.percent`];
25 const scroll = bheight * percent;
26
27 $('html,body').animate({ scrollTop: scroll }, 'fast');
28
29 return true;
30}
31
32function initFilters() {
33 // no display if filters not available
34 if ($('div').is('#filters')) {
35 $('#button_filters').show();
36 $('.button-collapse-right').sideNav({ edge: 'right' });
37 $('#clear_form_filters').on('click', () => {
38 $('#filters input').val('');
39 $('#filters :checked').removeAttr('checked');
40 return false;
41 });
42 }
43}
44
45function initExport() {
46 // no display if export not available
47 if ($('div').is('#export')) {
48 $('#button_export').show();
49 $('.button-collapse-right').sideNav({ edge: 'right' });
50 }
51}
52
53export { savePercent, retrievePercent, initFilters, initExport };