From c146f6940a176142084b4fc3c610d13aca60d90e Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 28 Sep 2016 10:30:18 +0200 Subject: Assets work * ES6 all the things ! * ESLint checks everything * CSS fixes (use stylelint) * Fix #2231 --- .../static/themes/_global/js/bookmarklet.js | 6 ++- .../static/themes/_global/js/restoreScroll.js | 25 ----------- app/Resources/static/themes/_global/js/tools.js | 50 ++++++++++++++++++++++ 3 files changed, 55 insertions(+), 26 deletions(-) delete mode 100644 app/Resources/static/themes/_global/js/restoreScroll.js create mode 100644 app/Resources/static/themes/_global/js/tools.js (limited to 'app/Resources/static/themes/_global/js') 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 @@ -top["bookmarklet-url@wallabag.org"]=""+""+""+""+"bag it!"+''+""+""+"'; 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 @@ -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) { - if (!supportsLocalStorage()) { return false; } - - var bheight = $(document).height(); - var percent = localStorage['wallabag.article.' + id + '.percent']; - var scroll = bheight * percent; - - $('html,body').animate({ scrollTop: scroll }, 'fast'); - - return true; -} 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 @@ +const $ = require('jquery'); + +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) { + if (!supportsLocalStorage()) { return false; } + + const bheight = $(document).height(); + const percent = localStorage[`wallabag.article.${id}.percent`]; + const scroll = bheight * percent; + + $('html,body').animate({ scrollTop: scroll }, 'fast'); + + return true; +} + +function initFilters() { + // no display if filters not available + if ($('div').is('#filters')) { + $('#button_filters').show(); + $('.button-collapse-right').sideNav({ edge: 'right' }); + $('#clear_form_filters').on('click', () => { + $('#filters input').val(''); + $('#filters :checked').removeAttr('checked'); + return false; + }); + } +} + +function initExport() { + // no display if export not available + if ($('div').is('#export')) { + $('#button_export').show(); + $('.button-collapse-right').sideNav({ edge: 'right' }); + } +} + +export { savePercent, retrievePercent, initFilters, initExport }; -- cgit v1.2.3