]>
git.immae.eu Git - github/wallabag/wallabag.git/blob - app/Resources/static/themes/_global/js/tools.js
1 import $ from 'jquery';
2 import './shortcuts/main';
3 import './shortcuts/entry';
5 /* Allows inline call qr-code call */
6 import jrQrcode
from 'jr-qrcode'; // eslint-disable-line
8 function savePercent(id
, percent
) {
9 fetch(`/progress/${id}/${percent * 100}`, { credentials: 'include' });
12 function retrievePercent() {
13 const percent
= $('#article').attr('data-progress');
15 const scroll
= $(document
).height() * percent
;
17 $('html,body').animate({ scrollTop: scroll
}, 'fast');
20 function initFilters() {
21 // no display if filters not available
22 if ($('div').is('#filters')) {
23 $('#button_filters').show();
24 $('.js-filters-action').sideNav({ edge: 'right' });
25 $('#clear_form_filters').on('click', () => {
26 $('#filters input').val('');
27 $('#filters :checked').removeAttr('checked');
33 function initExport() {
34 // no display if export not available
35 if ($('div').is('#export')) {
36 $('#button_export').show();
37 $('.js-export-action').sideNav({ edge: 'right' });
41 function throttle(callback
, delay
) {
46 const now
= new Date();
47 const args
= arguments
;
48 if (last
&& now
< last
+ delay
) {
49 // le délai n'est pas écoulé on reset le timer
51 timer
= setTimeout(function () {
53 callback
.apply(context
, args
);
57 callback
.apply(context
, args
);
62 export { savePercent
, retrievePercent
, initFilters
, initExport
, throttle
};