aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/Resources/static/themes/_global
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2018-07-03 13:55:25 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2018-07-03 13:55:25 +0200
commit44043ebe82a22470e2514d05efac324035ee809a (patch)
tree5ea40b62ce665a8bab6a3e280a47f3be11838e27 /app/Resources/static/themes/_global
parent11f15430ffc67e30f084cffc8e909ace87ce19e1 (diff)
parente586d65b64089fc1cc230a18c470aae3f45f91a6 (diff)
downloadwallabag-44043ebe82a22470e2514d05efac324035ee809a.tar.gz
wallabag-44043ebe82a22470e2514d05efac324035ee809a.tar.zst
wallabag-44043ebe82a22470e2514d05efac324035ee809a.zip
Merge remote-tracking branch 'origin/master' into 2.4
Diffstat (limited to 'app/Resources/static/themes/_global')
-rw-r--r--app/Resources/static/themes/_global/index.js6
-rw-r--r--app/Resources/static/themes/_global/js/highlight.js8
-rw-r--r--app/Resources/static/themes/_global/js/tools.js6
3 files changed, 16 insertions, 4 deletions
diff --git a/app/Resources/static/themes/_global/index.js b/app/Resources/static/themes/_global/index.js
index fddb476d..ae598e56 100644
--- a/app/Resources/static/themes/_global/index.js
+++ b/app/Resources/static/themes/_global/index.js
@@ -13,8 +13,10 @@ import './global.scss';
13import './js/shortcuts/entry'; 13import './js/shortcuts/entry';
14import './js/shortcuts/main'; 14import './js/shortcuts/main';
15 15
16import { savePercent, retrievePercent } from './js/tools'; 16/* Hightlight */
17import './js/highlight';
17 18
19import { savePercent, retrievePercent } from './js/tools';
18 20
19/* ========================================================================== 21/* ==========================================================================
20 Annotations & Remember position 22 Annotations & Remember position
@@ -65,7 +67,7 @@ $(document).ready(() => {
65 retrievePercent(x.entryId); 67 retrievePercent(x.entryId);
66 68
67 $(window).resize(() => { 69 $(window).resize(() => {
68 retrievePercent(x.entryId); 70 retrievePercent(x.entryId, true);
69 }); 71 });
70 } 72 }
71}); 73});
diff --git a/app/Resources/static/themes/_global/js/highlight.js b/app/Resources/static/themes/_global/js/highlight.js
new file mode 100644
index 00000000..4025fc14
--- /dev/null
+++ b/app/Resources/static/themes/_global/js/highlight.js
@@ -0,0 +1,8 @@
1import 'highlight.js/styles/atom-one-light.css';
2import * as hljs from 'highlight.js';
3
4window.addEventListener('load', () => {
5 document.querySelectorAll('pre').forEach((node) => {
6 hljs.highlightBlock(node);
7 });
8});
diff --git a/app/Resources/static/themes/_global/js/tools.js b/app/Resources/static/themes/_global/js/tools.js
index 774f4539..7e5a2b27 100644
--- a/app/Resources/static/themes/_global/js/tools.js
+++ b/app/Resources/static/themes/_global/js/tools.js
@@ -19,14 +19,16 @@ function savePercent(id, percent) {
19 return true; 19 return true;
20} 20}
21 21
22function retrievePercent(id) { 22function retrievePercent(id, resized) {
23 if (!supportsLocalStorage()) { return false; } 23 if (!supportsLocalStorage()) { return false; }
24 24
25 const bheight = $(document).height(); 25 const bheight = $(document).height();
26 const percent = localStorage[`wallabag.article.${id}.percent`]; 26 const percent = localStorage[`wallabag.article.${id}.percent`];
27 const scroll = bheight * percent; 27 const scroll = bheight * percent;
28 28
29 $('html,body').animate({ scrollTop: scroll }, 'fast'); 29 if (!resized) {
30 $('html,body').animate({ scrollTop: scroll }, 'fast');
31 }
30 32
31 return true; 33 return true;
32} 34}