diff options
Diffstat (limited to 'app/Resources/static/themes/material/js')
-rwxr-xr-x | app/Resources/static/themes/material/js/init.js | 70 |
1 files changed, 25 insertions, 45 deletions
diff --git a/app/Resources/static/themes/material/js/init.js b/app/Resources/static/themes/material/js/init.js index d6a87941..18f7b40a 100755 --- a/app/Resources/static/themes/material/js/init.js +++ b/app/Resources/static/themes/material/js/init.js | |||
@@ -1,29 +1,10 @@ | |||
1 | var $ = require('jquery'); | 1 | const $ = require('jquery'); |
2 | require('materialize'); | 2 | global.jQuery = $; |
3 | var annotator = require('annotator'); | 3 | require('materialize'); // eslint-disable-line |
4 | const annotator = require('annotator'); | ||
5 | import { savePercent, retrievePercent, initFilters, initExport } from '../../_global/js/tools.js'; | ||
4 | 6 | ||
5 | function initFilters() { | 7 | $(document).ready(() => { |
6 | // no display if filters not aviable | ||
7 | if ($('div').is('#filters')) { | ||
8 | $('#button_filters').show(); | ||
9 | $('.button-collapse-right').sideNav({ edge: 'right' }); | ||
10 | $('#clear_form_filters').on('click', function () { | ||
11 | $('#filters input').val(''); | ||
12 | $('#filters :checked').removeAttr('checked'); | ||
13 | return false; | ||
14 | }); | ||
15 | } | ||
16 | } | ||
17 | |||
18 | function initExport() { | ||
19 | // no display if export not aviable | ||
20 | if ($('div').is('#export')) { | ||
21 | $('#button_export').show(); | ||
22 | $('.button-collapse-right').sideNav({ edge: 'right' }); | ||
23 | } | ||
24 | } | ||
25 | |||
26 | $(document).ready(function () { | ||
27 | // sideNav | 8 | // sideNav |
28 | $('.button-collapse').sideNav(); | 9 | $('.button-collapse').sideNav(); |
29 | $('select').material_select(); | 10 | $('select').material_select(); |
@@ -40,13 +21,13 @@ $(document).ready(function () { | |||
40 | initFilters(); | 21 | initFilters(); |
41 | initExport(); | 22 | initExport(); |
42 | 23 | ||
43 | $('#nav-btn-add-tag').on('click', function () { | 24 | $('#nav-btn-add-tag').on('click', () => { |
44 | $('.nav-panel-add-tag').toggle(100); | 25 | $('.nav-panel-add-tag').toggle(100); |
45 | $('.nav-panel-menu').addClass('hidden'); | 26 | $('.nav-panel-menu').addClass('hidden'); |
46 | $('#tag_label').focus(); | 27 | $('#tag_label').focus(); |
47 | return false; | 28 | return false; |
48 | }); | 29 | }); |
49 | $('#nav-btn-add').on('click', function () { | 30 | $('#nav-btn-add').on('click', () => { |
50 | $('.nav-panel-buttom').hide(100); | 31 | $('.nav-panel-buttom').hide(100); |
51 | $('.nav-panel-add').show(100); | 32 | $('.nav-panel-add').show(100); |
52 | $('.nav-panels .action').hide(100); | 33 | $('.nav-panels .action').hide(100); |
@@ -55,7 +36,7 @@ $(document).ready(function () { | |||
55 | $('#entry_url').focus(); | 36 | $('#entry_url').focus(); |
56 | return false; | 37 | return false; |
57 | }); | 38 | }); |
58 | $('#nav-btn-search').on('click', function () { | 39 | $('#nav-btn-search').on('click', () => { |
59 | $('.nav-panel-buttom').hide(100); | 40 | $('.nav-panel-buttom').hide(100); |
60 | $('.nav-panel-search').show(100); | 41 | $('.nav-panel-search').show(100); |
61 | $('.nav-panels .action').hide(100); | 42 | $('.nav-panels .action').hide(100); |
@@ -64,7 +45,7 @@ $(document).ready(function () { | |||
64 | $('#searchfield').focus(); | 45 | $('#searchfield').focus(); |
65 | return false; | 46 | return false; |
66 | }); | 47 | }); |
67 | $('.close').on('click', function () { | 48 | $('.close').on('click', () => { |
68 | $('.nav-panel-add').hide(100); | 49 | $('.nav-panel-add').hide(100); |
69 | $('.nav-panel-search').hide(100); | 50 | $('.nav-panel-search').hide(100); |
70 | $('.nav-panel-buttom').show(100); | 51 | $('.nav-panel-buttom').show(100); |
@@ -73,12 +54,12 @@ $(document).ready(function () { | |||
73 | $('.nav-panels').css('background', 'transparent'); | 54 | $('.nav-panels').css('background', 'transparent'); |
74 | return false; | 55 | return false; |
75 | }); | 56 | }); |
76 | $(window).scroll(function () { | 57 | $(window).scroll(() => { |
77 | var s = $(window).scrollTop(); | 58 | const s = $(window).scrollTop(); |
78 | var d = $(document).height(); | 59 | const d = $(document).height(); |
79 | var c = $(window).height(); | 60 | const c = $(window).height(); |
80 | var scrollPercent = (s / (d - c)) * 100; | 61 | const scrollPercent = (s / (d - c)) * 100; |
81 | $('.progress .determinate').css('width', scrollPercent + '%'); | 62 | $('.progress .determinate').css('width', `${scrollPercent}%`); |
82 | }); | 63 | }); |
83 | 64 | ||
84 | /* ========================================================================== | 65 | /* ========================================================================== |
@@ -86,9 +67,8 @@ $(document).ready(function () { | |||
86 | ========================================================================== */ | 67 | ========================================================================== */ |
87 | 68 | ||
88 | if ($('article').length) { | 69 | if ($('article').length) { |
89 | var app = new annotator.App(); | 70 | const app = new annotator.App(); |
90 | var x = JSON.parse($('#annotationroutes').html()); | 71 | const x = JSON.parse($('#annotationroutes').html()); |
91 | |||
92 | 72 | ||
93 | app.include(annotator.ui.main, { | 73 | app.include(annotator.ui.main, { |
94 | element: document.querySelector('article'), | 74 | element: document.querySelector('article'), |
@@ -96,21 +76,21 @@ $(document).ready(function () { | |||
96 | 76 | ||
97 | app.include(annotator.storage.http, x); | 77 | app.include(annotator.storage.http, x); |
98 | 78 | ||
99 | app.start().then(function () { | 79 | app.start().then(() => { |
100 | app.annotations.load({ entry: x.entryId }); | 80 | app.annotations.load({ entry: x.entryId }); |
101 | }); | 81 | }); |
102 | 82 | ||
103 | $(window).scroll(function (e) { | 83 | $(window).scroll(() => { |
104 | var scrollTop = $(window).scrollTop(); | 84 | const scrollTop = $(window).scrollTop(); |
105 | var docHeight = $(document).height(); | 85 | const docHeight = $(document).height(); |
106 | var scrollPercent = (scrollTop) / (docHeight); | 86 | const scrollPercent = (scrollTop) / (docHeight); |
107 | var scrollPercentRounded = Math.round(scrollPercent * 100) / 100; | 87 | const scrollPercentRounded = Math.round(scrollPercent * 100) / 100; |
108 | savePercent(x.entryId, scrollPercentRounded); | 88 | savePercent(x.entryId, scrollPercentRounded); |
109 | }); | 89 | }); |
110 | 90 | ||
111 | retrievePercent(x.entryId); | 91 | retrievePercent(x.entryId); |
112 | 92 | ||
113 | $(window).resize(function () { | 93 | $(window).resize(() => { |
114 | retrievePercent(x.entryId); | 94 | retrievePercent(x.entryId); |
115 | }); | 95 | }); |
116 | } | 96 | } |