diff options
author | Thomas Citharel <tcit@tcit.fr> | 2017-03-31 20:21:41 +0200 |
---|---|---|
committer | Thomas Citharel <tcit@tcit.fr> | 2017-05-04 14:49:44 +0200 |
commit | 64f81bc31699ed239e4becec1cfa7ebc0bef2b5a (patch) | |
tree | 6363a596055683587d11aaffcf30608a682988aa /app/Resources/static/themes/_global/index.js | |
parent | 3b4502e0e663866e7bac00164fd935fdc92309d6 (diff) | |
download | wallabag-64f81bc31699ed239e4becec1cfa7ebc0bef2b5a.tar.gz wallabag-64f81bc31699ed239e4becec1cfa7ebc0bef2b5a.tar.zst wallabag-64f81bc31699ed239e4becec1cfa7ebc0bef2b5a.zip |
Adds Webpack support and removes the use for Grunt
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
use scss
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
fix build, add babel, fix annotations
fixes (and improvements !) for baggy
add live reload & environments & eslint & theme fixes
Diffstat (limited to 'app/Resources/static/themes/_global/index.js')
-rw-r--r-- | app/Resources/static/themes/_global/index.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/app/Resources/static/themes/_global/index.js b/app/Resources/static/themes/_global/index.js new file mode 100644 index 00000000..00410754 --- /dev/null +++ b/app/Resources/static/themes/_global/index.js | |||
@@ -0,0 +1,52 @@ | |||
1 | /* jQuery */ | ||
2 | import $ from 'jquery'; | ||
3 | |||
4 | /* Annotations */ | ||
5 | import annotator from 'annotator'; | ||
6 | |||
7 | /* Fonts */ | ||
8 | import 'material-design-icons-iconfont/dist/material-design-icons.css'; | ||
9 | import 'lato-font/css/lato-font.css'; | ||
10 | import './global.scss'; | ||
11 | |||
12 | /* Shortcuts*/ | ||
13 | import './js/shortcuts/entry'; | ||
14 | import './js/shortcuts/main'; | ||
15 | |||
16 | import { 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 | }); | ||