diff options
Diffstat (limited to 'app/Resources/static/themes/material/index.js')
-rwxr-xr-x | app/Resources/static/themes/material/index.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/app/Resources/static/themes/material/index.js b/app/Resources/static/themes/material/index.js index d6afbb8a..408528ea 100755 --- a/app/Resources/static/themes/material/index.js +++ b/app/Resources/static/themes/material/index.js | |||
@@ -75,4 +75,37 @@ $(document).ready(() => { | |||
75 | const scrollPercent = (s / (d - c)) * 100; | 75 | const scrollPercent = (s / (d - c)) * 100; |
76 | $('.progress .determinate').css('width', `${scrollPercent}%`); | 76 | $('.progress .determinate').css('width', `${scrollPercent}%`); |
77 | }); | 77 | }); |
78 | |||
79 | /* ========================================================================== | ||
80 | Annotations & Remember position | ||
81 | ========================================================================== */ | ||
82 | |||
83 | if ($('article').length) { | ||
84 | const app = new annotator.App(); | ||
85 | const x = JSON.parse($('#annotationroutes').html()); | ||
86 | |||
87 | app.include(annotator.ui.main, { | ||
88 | element: document.querySelector('article'), | ||
89 | }); | ||
90 | |||
91 | app.include(annotator.storage.http, x); | ||
92 | |||
93 | app.start().then(() => { | ||
94 | app.annotations.load({ entry: x.entryId }); | ||
95 | }); | ||
96 | |||
97 | window.addEventListener('unload', () => { | ||
98 | const scrollTop = $(window).scrollTop(); | ||
99 | const docHeight = $(document).height(); | ||
100 | const scrollPercent = (scrollTop) / (docHeight); | ||
101 | const scrollPercentRounded = Math.round(scrollPercent * 100) / 100; | ||
102 | savePercent(x.entryId, scrollPercentRounded); | ||
103 | }); | ||
104 | |||
105 | retrievePercent(x.entryId); | ||
106 | |||
107 | $(window).resize(() => { | ||
108 | retrievePercent(x.entryId); | ||
109 | }); | ||
110 | } | ||
78 | }); | 111 | }); |