aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/Resources/static/themes/material/js/init.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/Resources/static/themes/material/js/init.js')
-rwxr-xr-xapp/Resources/static/themes/material/js/init.js110
1 files changed, 0 insertions, 110 deletions
diff --git a/app/Resources/static/themes/material/js/init.js b/app/Resources/static/themes/material/js/init.js
deleted file mode 100755
index 0b2832c0..00000000
--- a/app/Resources/static/themes/material/js/init.js
+++ /dev/null
@@ -1,110 +0,0 @@
1/* jQuery */
2import $ from 'jquery';
3
4/* Annotations */
5import annotator from 'annotator';
6
7/* Tools */
8import { savePercent, retrievePercent, initFilters, initExport } from '../../_global/js/tools';
9
10/* Import shortcuts */
11import './shortcuts/main';
12import './shortcuts/entry';
13import '../../_global/js/shortcuts/main';
14import '../../_global/js/shortcuts/entry';
15
16require('materialize'); // eslint-disable-line
17
18global.jQuery = $;
19
20$(document).ready(() => {
21 // sideNav
22 $('.button-collapse').sideNav();
23 $('select').material_select();
24 $('.collapsible').collapsible({
25 accordion: false,
26 });
27 $('.datepicker').pickadate({
28 selectMonths: true,
29 selectYears: 15,
30 formatSubmit: 'dd/mm/yyyy',
31 hiddenName: true,
32 format: 'dd/mm/yyyy',
33 });
34 initFilters();
35 initExport();
36
37 $('#nav-btn-add-tag').on('click', () => {
38 $('.nav-panel-add-tag').toggle(100);
39 $('.nav-panel-menu').addClass('hidden');
40 $('#tag_label').focus();
41 return false;
42 });
43 $('#nav-btn-add').on('click', () => {
44 $('.nav-panel-buttom').hide(100);
45 $('.nav-panel-add').show(100);
46 $('.nav-panels .action').hide(100);
47 $('.nav-panel-menu').addClass('hidden');
48 $('.nav-panels').css('background', 'white');
49 $('#entry_url').focus();
50 return false;
51 });
52 $('#nav-btn-search').on('click', () => {
53 $('.nav-panel-buttom').hide(100);
54 $('.nav-panel-search').show(100);
55 $('.nav-panels .action').hide(100);
56 $('.nav-panel-menu').addClass('hidden');
57 $('.nav-panels').css('background', 'white');
58 $('#search_entry_term').focus();
59 return false;
60 });
61 $('.close').on('click', () => {
62 $('.nav-panel-add').hide(100);
63 $('.nav-panel-search').hide(100);
64 $('.nav-panel-buttom').show(100);
65 $('.nav-panels .action').show(100);
66 $('.nav-panel-menu').removeClass('hidden');
67 $('.nav-panels').css('background', 'transparent');
68 return false;
69 });
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
78/* ==========================================================================
79 Annotations & Remember position
80 ========================================================================== */
81
82 if ($('article').length) {
83 const app = new annotator.App();
84 const x = JSON.parse($('#annotationroutes').html());
85
86 app.include(annotator.ui.main, {
87 element: document.querySelector('article'),
88 });
89
90 app.include(annotator.storage.http, x);
91
92 app.start().then(() => {
93 app.annotations.load({ entry: x.entryId });
94 });
95
96 $(window).scroll(() => {
97 const scrollTop = $(window).scrollTop();
98 const docHeight = $(document).height();
99 const scrollPercent = (scrollTop) / (docHeight);
100 const scrollPercentRounded = Math.round(scrollPercent * 100) / 100;
101 savePercent(x.entryId, scrollPercentRounded);
102 });
103
104 retrievePercent(x.entryId);
105
106 $(window).resize(() => {
107 retrievePercent(x.entryId);
108 });
109 }
110});