diff options
Diffstat (limited to 'app/Resources/static/themes/material/index.js')
-rwxr-xr-x | app/Resources/static/themes/material/index.js | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/app/Resources/static/themes/material/index.js b/app/Resources/static/themes/material/index.js index 96310d81..e808d75c 100755 --- a/app/Resources/static/themes/material/index.js +++ b/app/Resources/static/themes/material/index.js | |||
@@ -8,7 +8,7 @@ import 'materialize-css/dist/js/materialize'; | |||
8 | import '../_global/index'; | 8 | import '../_global/index'; |
9 | 9 | ||
10 | /* Tools */ | 10 | /* Tools */ |
11 | import { initExport, initFilters } from './js/tools'; | 11 | import { initExport, initFilters, initRandom } from './js/tools'; |
12 | 12 | ||
13 | /* Import shortcuts */ | 13 | /* Import shortcuts */ |
14 | import './js/shortcuts/main'; | 14 | import './js/shortcuts/main'; |
@@ -17,6 +17,36 @@ import './js/shortcuts/entry'; | |||
17 | /* Theme style */ | 17 | /* Theme style */ |
18 | import './css/index.scss'; | 18 | import './css/index.scss'; |
19 | 19 | ||
20 | const stickyNav = () => { | ||
21 | const nav = $('.js-entry-nav-top'); | ||
22 | $('[data-toggle="actions"]').click(() => { | ||
23 | nav.toggleClass('entry-nav-top--sticky'); | ||
24 | }); | ||
25 | }; | ||
26 | |||
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(); | ||
45 | } | ||
46 | }); | ||
47 | } | ||
48 | }; | ||
49 | |||
20 | $(document).ready(() => { | 50 | $(document).ready(() => { |
21 | // sideNav | 51 | // sideNav |
22 | $('.button-collapse').sideNav(); | 52 | $('.button-collapse').sideNav(); |
@@ -32,8 +62,12 @@ $(document).ready(() => { | |||
32 | format: 'dd/mm/yyyy', | 62 | format: 'dd/mm/yyyy', |
33 | container: 'body', | 63 | container: 'body', |
34 | }); | 64 | }); |
65 | |||
35 | initFilters(); | 66 | initFilters(); |
36 | initExport(); | 67 | initExport(); |
68 | initRandom(); | ||
69 | stickyNav(); | ||
70 | articleScroll(); | ||
37 | 71 | ||
38 | const toggleNav = (toShow, toFocus) => { | 72 | const toggleNav = (toShow, toFocus) => { |
39 | $('.nav-panel-actions').hide(100); | 73 | $('.nav-panel-actions').hide(100); |
@@ -48,30 +82,27 @@ $(document).ready(() => { | |||
48 | $('#tag_label').focus(); | 82 | $('#tag_label').focus(); |
49 | return false; | 83 | return false; |
50 | }); | 84 | }); |
85 | |||
51 | $('#nav-btn-add').on('click', () => { | 86 | $('#nav-btn-add').on('click', () => { |
52 | toggleNav('.nav-panel-add', '#entry_url'); | 87 | toggleNav('.nav-panel-add', '#entry_url'); |
53 | return false; | 88 | return false; |
54 | }); | 89 | }); |
90 | |||
55 | const materialAddForm = $('.nav-panel-add'); | 91 | const materialAddForm = $('.nav-panel-add'); |
56 | materialAddForm.on('submit', () => { | 92 | materialAddForm.on('submit', () => { |
57 | materialAddForm.addClass('disabled'); | 93 | materialAddForm.addClass('disabled'); |
58 | $('input#entry_url', materialAddForm).prop('readonly', true).trigger('blur'); | 94 | $('input#entry_url', materialAddForm).prop('readonly', true).trigger('blur'); |
59 | }); | 95 | }); |
96 | |||
60 | $('#nav-btn-search').on('click', () => { | 97 | $('#nav-btn-search').on('click', () => { |
61 | toggleNav('.nav-panel-search', '#search_entry_term'); | 98 | toggleNav('.nav-panel-search', '#search_entry_term'); |
62 | return false; | 99 | return false; |
63 | }); | 100 | }); |
101 | |||
64 | $('.close').on('click', (e) => { | 102 | $('.close').on('click', (e) => { |
65 | $(e.target).parent('.nav-panel-item').hide(100); | 103 | $(e.target).parent('.nav-panel-item').hide(100); |
66 | $('.nav-panel-actions').show(100); | 104 | $('.nav-panel-actions').show(100); |
67 | $('.nav-panels').css('background', 'transparent'); | 105 | $('.nav-panels').css('background', 'transparent'); |
68 | return false; | 106 | return false; |
69 | }); | 107 | }); |
70 | $(window).scroll(() => { | ||
71 | const s = $(window).scrollTop(); | ||
72 | const d = $(document).height(); | ||
73 | const c = $(window).height(); | ||
74 | const scrollPercent = (s / (d - c)) * 100; | ||
75 | $('.progress .determinate').css('width', `${scrollPercent}%`); | ||
76 | }); | ||
77 | }); | 108 | }); |