]>
git.immae.eu Git - github/wallabag/wallabag.git/blob - app/Resources/static/themes/_global/js/tools.js
d6a2d803423675c237c3b825001fa69210c59118
1 const $ = require('jquery');
4 /* Allows inline call qr-code call */
5 import jrQrcode
from 'jr-qrcode'; // eslint-disable-line
7 function supportsLocalStorage() {
9 return 'localStorage' in window
&& window
.localStorage
!== null;
15 function savePercent(id
, percent
) {
16 if (!supportsLocalStorage()) { return false; }
17 localStorage
[`wallabag.article.${id}.percent`] = percent
;
21 function retrievePercent(id
) {
22 if (!supportsLocalStorage()) { return false; }
24 const bheight
= $(document
).height();
25 const percent
= localStorage
[`wallabag.article.${id}.percent`];
26 const scroll
= bheight
* percent
;
28 $('html,body').animate({ scrollTop: scroll
}, 'fast');
33 function initFilters() {
34 // no display if filters not available
35 if ($('div').is('#filters')) {
36 $('#button_filters').show();
37 $('.button-collapse-right').sideNav({ edge: 'right' });
38 $('#clear_form_filters').on('click', () => {
39 $('#filters input').val('');
40 $('#filters :checked').removeAttr('checked');
46 function initExport() {
47 // no display if export not available
48 if ($('div').is('#export')) {
49 $('#button_export').show();
50 $('.button-collapse-right').sideNav({ edge: 'right' });
54 export { savePercent
, retrievePercent
, initFilters
, initExport
};
59 Mousetrap
.bind('g u', function() { window
.location
.href
= Routing
.generate('homepage') });
60 Mousetrap
.bind('g s', function() { window
.location
.href
= Routing
.generate('starred') });
61 Mousetrap
.bind('g r', function() { window
.location
.href
= Routing
.generate('archive') });
62 Mousetrap
.bind('g a', function() { window
.location
.href
= Routing
.generate('all') });
63 Mousetrap
.bind('g t', function() { window
.location
.href
= Routing
.generate('tag') });
64 Mousetrap
.bind('g c', function() { window
.location
.href
= Routing
.generate('config') });
65 Mousetrap
.bind('g i', function() { window
.location
.href
= Routing
.generate('import') });
66 Mousetrap
.bind('g d', function() { window
.location
.href
= Routing
.generate('developer') });
67 Mousetrap
.bind('g h', function() { window
.location
.href
= Routing
.generate('howto') });
68 Mousetrap
.bind('g l', function() { window
.location
.href
= Routing
.generate('logout') });
72 Mousetrap
.bind('g n', function() {
73 $("#nav-btn-add").trigger("click");
76 Mousetrap
.bind('esc', function() {
77 $(".close").trigger("click");
80 // Display the first element of the current view
81 Mousetrap
.bind('right', function() {
82 $("ul.data li:first-child span.dot-ellipsis a")[0].click();
86 Mousetrap
.bind('o', function() {
87 $("ul.side-nav li:nth-child(2) a i")[0].click();
90 Mousetrap
.bind('s', function() {
91 $("ul.side-nav li:nth-child(5) a i")[0].click();
94 Mousetrap
.bind('a', function() {
95 $("ul.side-nav li:nth-child(4) a i")[0].click();
98 Mousetrap
.bind('del', function() {
99 $("ul.side-nav li:nth-child(6) a i")[0].click();