aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/Resources/static/themes/baggy/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/Resources/static/themes/baggy/index.js')
-rwxr-xr-xapp/Resources/static/themes/baggy/index.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/app/Resources/static/themes/baggy/index.js b/app/Resources/static/themes/baggy/index.js
index 39ad49aa..27e3e374 100755
--- a/app/Resources/static/themes/baggy/index.js
+++ b/app/Resources/static/themes/baggy/index.js
@@ -9,6 +9,9 @@ import './js/shortcuts/entry';
9 9
10/* Tools */ 10/* Tools */
11import toggleSaveLinkForm from './js/uiTools'; 11import toggleSaveLinkForm from './js/uiTools';
12import {savePercent, retrievePercent, throttle} from '../_global/js/tools';
13
14global.jquery = $;
12 15
13/* Theme style */ 16/* Theme style */
14import './css/index.scss'; 17import './css/index.scss';
@@ -50,6 +53,39 @@ $(document).ready(() => {
50 }); 53 });
51 } 54 }
52 55
56 /* ==========================================================================
57 Annotations & Remember position
58 ========================================================================== */
59
60 if ($('article').length) {
61 const app = new annotator.App();
62
63 app.include(annotator.ui.main, {
64 element: document.querySelector('article'),
65 });
66
67 const x = JSON.parse($('#annotationroutes').html());
68 app.include(annotator.storage.http, x);
69
70 app.start().then(() => {
71 app.annotations.load({ entry: x.entryId });
72 });
73
74 window.addEventListener('unload', () => {
75 const scrollTop = $(window).scrollTop();
76 const docHeight = $(document).height();
77 const scrollPercent = (scrollTop) / (docHeight);
78 const scrollPercentRounded = Math.round(scrollPercent * 100) / 100;
79 savePercent(x.entryId, scrollPercentRounded);
80 });
81
82 retrievePercent(x.entryId);
83
84 $(window).resize(() => {
85 retrievePercent(x.entryId);
86 });
87 }
88
53 /** 89 /**
54 * Close window after adding entry if popup 90 * Close window after adding entry if popup
55 */ 91 */