]>
git.immae.eu Git - github/wallabag/wallabag.git/blob - app/Resources/static/themes/material/index.js
1 import $ from 'jquery';
3 /* Materialize imports */
4 import 'materialize-css/dist/css/materialize.css';
5 import 'materialize-css/dist/js/materialize';
8 import '../_global/index';
11 import { initExport
, initFilters
, initRandom
, initSort
} from './js/tools';
13 /* Import shortcuts */
14 import './js/shortcuts/main';
15 import './js/shortcuts/entry';
18 import './css/index.scss';
20 const stickyNav
= () => {
21 const nav
= $('.js-entry-nav-top');
22 $('[data-toggle="actions"]').click(() => {
23 nav
.toggleClass('entry-nav-top--sticky');
27 const articleScroll
= () => {
28 const articleEl
= $('#article');
29 if (articleEl
.length
> 0) {
30 $(window
).scroll(() => {
31 const s
= $(window
).scrollTop();
32 const d
= $(document
).height();
33 const c
= $(window
).height();
34 const articleElBottom
= articleEl
.offset().top
+ articleEl
.height();
35 const scrollPercent
= (s
/ (d
- c
)) * 100;
36 $('.progress .determinate').css('width', `${scrollPercent}%`);
37 const fixedActionBtn
= $('.js-fixed-action-btn');
38 const toggleScrollDataName
= 'toggle-auto';
39 if ((s
+ c
) > articleElBottom
) {
40 fixedActionBtn
.data(toggleScrollDataName
, true);
41 fixedActionBtn
.openFAB();
42 } else if (fixedActionBtn
.data(toggleScrollDataName
) === true) {
43 fixedActionBtn
.data(toggleScrollDataName
, false);
44 fixedActionBtn
.closeFAB();
50 $(document
).ready(() => {
52 $('.button-collapse').sideNav();
53 $('select').material_select();
54 $('.collapsible').collapsible({
57 $('.datepicker').pickadate({
60 formatSubmit: 'yyyy-mm-dd',
66 $('.dropdown-trigger').dropdown({ hover: false });
75 const toggleNav
= (toShow
, toFocus
) => {
76 $('.nav-panel-actions').hide(100);
78 $('.nav-panels').css('background', 'white');
82 $('#nav-btn-add-tag').on('click', () => {
83 $('.nav-panel-add-tag').toggle(100);
84 $('.nav-panel-menu').addClass('hidden');
85 $('#tag_label').focus();
89 $('#nav-btn-add').on('click', () => {
90 toggleNav('.nav-panel-add', '#entry_url');
94 const materialAddForm
= $('.nav-panel-add');
95 materialAddForm
.on('submit', () => {
96 materialAddForm
.addClass('disabled');
97 $('input#entry_url', materialAddForm
).prop('readonly', true).trigger('blur');
100 $('#nav-btn-search').on('click', () => {
101 toggleNav('.nav-panel-search', '#search_entry_term');
105 $('.close').on('click', (e
) => {
106 $(e
.target
).parent('.nav-panel-item').hide(100);
107 $('.nav-panel-actions').show(100);
108 $('.nav-panels').css('background', 'transparent');
112 const mainCheckboxes
= document
.querySelectorAll('[data-js="checkboxes-toggle"]');
113 if (mainCheckboxes
.length
) {
114 [...mainCheckboxes
].forEach((el
) => {
115 el
.addEventListener('click', () => {
116 const checkboxes
= document
.querySelectorAll(el
.dataset
.toggle
);
117 [...checkboxes
].forEach((checkbox
) => {
118 const checkboxClone
= checkbox
;
119 checkboxClone
.checked
= el
.checked
;