diff --git a/assets/_global/js/tools.js b/assets/_global/js/tools.js deleted file mode 100644 index 7e5a2b271..000000000 --- a/assets/_global/js/tools.js +++ /dev/null @@ -1,36 +0,0 @@ -import $ from 'jquery'; -import './shortcuts/main'; -import './shortcuts/entry'; - -/* Allows inline call qr-code call */ -import jrQrcode from 'jr-qrcode'; // eslint-disable-line - -function supportsLocalStorage() { - try { - return 'localStorage' in window && window.localStorage !== null; - } catch (e) { - return false; - } -} - -function savePercent(id, percent) { - if (!supportsLocalStorage()) { return false; } - localStorage[`wallabag.article.${id}.percent`] = percent; - return true; -} - -function retrievePercent(id, resized) { - if (!supportsLocalStorage()) { return false; } - - const bheight = $(document).height(); - const percent = localStorage[`wallabag.article.${id}.percent`]; - const scroll = bheight * percent; - - if (!resized) { - $('html,body').animate({ scrollTop: scroll }, 'fast'); - } - - return true; -} - -export { savePercent, retrievePercent }; diff --git a/assets/material/index.js b/assets/material/index.js index b01abbda5..8ff6b334c 100755 --- a/assets/material/index.js +++ b/assets/material/index.js @@ -22,11 +22,9 @@ import '@fontsource/oswald'; /* Highlight */ import './js/highlight'; -import { savePercent, retrievePercent } from '../_global/js/tools'; - /* Tools */ import { - initExport, initFilters, initRandom, initPreviewText, + savePercent, retrievePercent, initExport, initFilters, initRandom, initPreviewText, } from './js/tools'; /* Import shortcuts */ diff --git a/assets/material/js/tools.js b/assets/material/js/tools.js index c497dee38..2fdd1c38d 100644 --- a/assets/material/js/tools.js +++ b/assets/material/js/tools.js @@ -1,5 +1,36 @@ import $ from 'jquery'; +/* Allows inline call qr-code call */ +import jrQrcode from 'jr-qrcode'; // eslint-disable-line + +function supportsLocalStorage() { + try { + return 'localStorage' in window && window.localStorage !== null; + } catch (e) { + return false; + } +} + +function savePercent(id, percent) { + if (!supportsLocalStorage()) { return false; } + localStorage[`wallabag.article.${id}.percent`] = percent; + return true; +} + +function retrievePercent(id, resized) { + if (!supportsLocalStorage()) { return false; } + + const bheight = $(document).height(); + const percent = localStorage[`wallabag.article.${id}.percent`]; + const scroll = bheight * percent; + + if (!resized) { + $('html,body').animate({ scrollTop: scroll }, 'fast'); + } + + return true; +} + function initFilters() { // no display if filters not available if ($('div').is('#filters')) { @@ -46,6 +77,8 @@ function initPreviewText() { } export { + savePercent, + retrievePercent, initExport, initFilters, initRandom,