]>
git.immae.eu Git - github/wallabag/wallabag.git/blob - index.js
3fdcaa3d078b0525e1df27f5a0c55b534621b968
2 import $ from 'jquery';
5 import annotator
from 'annotator';
8 import 'material-design-icons-iconfont/dist/material-design-icons.css';
9 import 'lato-font/css/lato-font.css';
10 import './global.scss';
13 import './js/shortcuts/entry';
14 import './js/shortcuts/main';
16 import { savePercent
, retrievePercent
} from './js/tools';
19 /* ==========================================================================
20 Annotations & Remember position
21 ========================================================================== */
23 $(document
).ready(() => {
24 if ($('article').length
) {
25 const app
= new annotator
.App();
27 app
.include(annotator
.ui
.main
, {
28 element: document
.querySelector('article'),
31 const authorization
= {
32 permits() { return true; },
34 app
.registry
.registerUtility(authorization
, 'authorizationPolicy');
36 const x
= JSON
.parse($('#annotationroutes').html());
37 app
.include(annotator
.storage
.http
, x
);
39 app
.start().then(() => {
40 app
.annotations
.load({ entry: x
.entryId
});
43 $(window
).scroll(() => {
44 const scrollTop
= $(window
).scrollTop();
45 const docHeight
= $(document
).height();
46 const scrollPercent
= (scrollTop
) / (docHeight
);
47 const scrollPercentRounded
= Math
.round(scrollPercent
* 100) / 100;
48 savePercent(x
.entryId
, scrollPercentRounded
);
51 retrievePercent(x
.entryId
);
53 $(window
).resize(() => {
54 retrievePercent(x
.entryId
);