]> git.immae.eu Git - github/wallabag/wallabag.git/blame - app/Resources/static/themes/_global/index.js
Adds Webpack support and removes the use for Grunt
[github/wallabag/wallabag.git] / app / Resources / static / themes / _global / index.js
CommitLineData
64f81bc3
TC
1/* jQuery */
2import $ from 'jquery';
3
4/* Annotations */
5import annotator from 'annotator';
6
7/* Fonts */
8import 'material-design-icons-iconfont/dist/material-design-icons.css';
9import 'lato-font/css/lato-font.css';
10import './global.scss';
11
12/* Shortcuts*/
13import './js/shortcuts/entry';
14import './js/shortcuts/main';
15
16import { savePercent, retrievePercent } from './js/tools';
17
18
19/* ==========================================================================
20 Annotations & Remember position
21 ========================================================================== */
22
23$(document).ready(() => {
24 if ($('article').length) {
25 const app = new annotator.App();
26
27 app.include(annotator.ui.main, {
28 element: document.querySelector('article'),
29 });
30
31 const x = JSON.parse($('#annotationroutes').html());
32 app.include(annotator.storage.http, x);
33
34 app.start().then(() => {
35 app.annotations.load({ entry: x.entryId });
36 });
37
38 $(window).scroll(() => {
39 const scrollTop = $(window).scrollTop();
40 const docHeight = $(document).height();
41 const scrollPercent = (scrollTop) / (docHeight);
42 const scrollPercentRounded = Math.round(scrollPercent * 100) / 100;
43 savePercent(x.entryId, scrollPercentRounded);
44 });
45
46 retrievePercent(x.entryId);
47
48 $(window).resize(() => {
49 retrievePercent(x.entryId);
50 });
51 }
52});