X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=app%2FResources%2Fstatic%2Fthemes%2Fmaterial%2Findex.js;h=2414c0fcc87e6d7908c96f62344c959c05d7d0e6;hb=HEAD;hp=4b194d00a3ec882eadef1c32d72eb7449013a39d;hpb=cfd77d1c2abca28c346af4697fb92db98a42f40a;p=github%2Fwallabag%2Fwallabag.git diff --git a/app/Resources/static/themes/material/index.js b/app/Resources/static/themes/material/index.js index 4b194d00..2414c0fc 100755 --- a/app/Resources/static/themes/material/index.js +++ b/app/Resources/static/themes/material/index.js @@ -17,6 +17,8 @@ import './js/shortcuts/entry'; /* Theme style */ import './css/index.scss'; +const mobileMaxWidth = 993; + const stickyNav = () => { const nav = $('.js-entry-nav-top'); $('[data-toggle="actions"]').click(() => { @@ -24,6 +26,29 @@ const stickyNav = () => { }); }; +const articleScroll = () => { + const articleEl = $('#article'); + if (articleEl.length > 0) { + $(window).scroll(() => { + const s = $(window).scrollTop(); + const d = $(document).height(); + const c = $(window).height(); + const articleElBottom = articleEl.offset().top + articleEl.height(); + const scrollPercent = (s / (d - c)) * 100; + $('.progress .determinate').css('width', `${scrollPercent}%`); + const fixedActionBtn = $('.js-fixed-action-btn'); + const toggleScrollDataName = 'toggle-auto'; + if ((s + c) > articleElBottom) { + fixedActionBtn.data(toggleScrollDataName, true); + fixedActionBtn.openFAB(); + } else if (fixedActionBtn.data(toggleScrollDataName) === true) { + fixedActionBtn.data(toggleScrollDataName, false); + fixedActionBtn.closeFAB(); + } + }); + } +}; + $(document).ready(() => { // sideNav $('.button-collapse').sideNav(); @@ -34,16 +59,19 @@ $(document).ready(() => { $('.datepicker').pickadate({ selectMonths: true, selectYears: 15, - formatSubmit: 'dd/mm/yyyy', - hiddenName: true, - format: 'dd/mm/yyyy', + formatSubmit: 'yyyy-mm-dd', + hiddenName: false, + format: 'yyyy-mm-dd', container: 'body', }); + $('.dropdown-trigger').dropdown({ hover: false }); + initFilters(); initExport(); initRandom(); stickyNav(); + articleScroll(); const toggleNav = (toShow, toFocus) => { $('.nav-panel-actions').hide(100); @@ -55,6 +83,9 @@ $(document).ready(() => { $('#nav-btn-add-tag').on('click', () => { $('.nav-panel-add-tag').toggle(100); $('.nav-panel-menu').addClass('hidden'); + if (window.innerWidth < mobileMaxWidth) { + $('.side-nav').sideNav('hide'); + } $('#tag_label').focus(); return false; }); @@ -82,11 +113,16 @@ $(document).ready(() => { return false; }); - $(window).scroll(() => { - const s = $(window).scrollTop(); - const d = $(document).height(); - const c = $(window).height(); - const scrollPercent = (s / (d - c)) * 100; - $('.progress .determinate').css('width', `${scrollPercent}%`); - }); + const mainCheckboxes = document.querySelectorAll('[data-js="checkboxes-toggle"]'); + if (mainCheckboxes.length) { + [...mainCheckboxes].forEach((el) => { + el.addEventListener('click', () => { + const checkboxes = document.querySelectorAll(el.dataset.toggle); + [...checkboxes].forEach((checkbox) => { + const checkboxClone = checkbox; + checkboxClone.checked = el.checked; + }); + }); + }); + } });