diff options
author | Thomas Citharel <tcit@tcit.fr> | 2016-11-03 10:02:16 +0100 |
---|---|---|
committer | Thomas Citharel <tcit@tcit.fr> | 2016-11-15 21:55:10 +0100 |
commit | 5637a26e9af98a05c76823c85611315cd1a986e0 (patch) | |
tree | 862469ed65589c18dca9f69914eda94ddf221cde /app/Resources/static | |
parent | 16ef7607f43ebc3e0134360b7657af191e14fe12 (diff) | |
download | wallabag-5637a26e9af98a05c76823c85611315cd1a986e0.tar.gz wallabag-5637a26e9af98a05c76823c85611315cd1a986e0.tar.zst wallabag-5637a26e9af98a05c76823c85611315cd1a986e0.zip |
Bring navigation (with right, left and enter) on material entries page. Supports going to next and previous page !
Also better indentation for js files (changed editorconfig for them).
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Diffstat (limited to 'app/Resources/static')
7 files changed, 105 insertions, 24 deletions
diff --git a/app/Resources/static/themes/_global/js/shortcuts/main.js b/app/Resources/static/themes/_global/js/shortcuts/main.js index 0bb962d0..1f2c1c52 100644 --- a/app/Resources/static/themes/_global/js/shortcuts/main.js +++ b/app/Resources/static/themes/_global/js/shortcuts/main.js | |||
@@ -1,3 +1,6 @@ | |||
1 | import Mousetrap from 'mousetrap'; | ||
2 | |||
3 | |||
1 | /** Shortcuts **/ | 4 | /** Shortcuts **/ |
2 | 5 | ||
3 | /* Go to */ | 6 | /* Go to */ |
diff --git a/app/Resources/static/themes/_global/js/tools.js b/app/Resources/static/themes/_global/js/tools.js index 77879dcd..568b2dce 100644 --- a/app/Resources/static/themes/_global/js/tools.js +++ b/app/Resources/static/themes/_global/js/tools.js | |||
@@ -1,7 +1,6 @@ | |||
1 | import $ from 'jquery'; | 1 | import $ from 'jquery'; |
2 | import Mousetrap from 'mousetrap'; | 2 | import './shortcuts/main'; |
3 | import './shortcuts/main.js'; | 3 | import './shortcuts/entry'; |
4 | import './shortcuts/entry.js'; | ||
5 | 4 | ||
6 | /* Allows inline call qr-code call */ | 5 | /* Allows inline call qr-code call */ |
7 | import jrQrcode from 'jr-qrcode'; // eslint-disable-line | 6 | import jrQrcode from 'jr-qrcode'; // eslint-disable-line |
diff --git a/app/Resources/static/themes/baggy/js/init.js b/app/Resources/static/themes/baggy/js/init.js index 5a8911ad..05360a28 100755 --- a/app/Resources/static/themes/baggy/js/init.js +++ b/app/Resources/static/themes/baggy/js/init.js | |||
@@ -1,7 +1,5 @@ | |||
1 | /* jQuery */ | ||
1 | import $ from 'jquery'; | 2 | import $ from 'jquery'; |
2 | import { initFilters, initExport } from '../../_global/js/tools'; | ||
3 | import './shortcuts/main.js'; | ||
4 | import './shortcuts/entry.js'; | ||
5 | 3 | ||
6 | /* eslint-disable no-unused-vars */ | 4 | /* eslint-disable no-unused-vars */ |
7 | /* jquery has default scope */ | 5 | /* jquery has default scope */ |
@@ -9,8 +7,16 @@ import cookie from 'jquery.cookie'; | |||
9 | import ui from 'jquery-ui-browserify'; | 7 | import ui from 'jquery-ui-browserify'; |
10 | /* eslint-enable no-unused-vars */ | 8 | /* eslint-enable no-unused-vars */ |
11 | 9 | ||
10 | /* Annotations */ | ||
12 | import annotator from 'annotator'; | 11 | import annotator from 'annotator'; |
13 | 12 | ||
13 | /* Shortcuts */ | ||
14 | import './shortcuts/main'; | ||
15 | import './shortcuts/entry'; | ||
16 | import '../../_global/js/shortcuts/main'; | ||
17 | import '../../_global/js/shortcuts/entry'; | ||
18 | |||
19 | /* Tools */ | ||
14 | import { savePercent, retrievePercent } from '../../_global/js/tools'; | 20 | import { savePercent, retrievePercent } from '../../_global/js/tools'; |
15 | import toggleSaveLinkForm from './uiTools'; | 21 | import toggleSaveLinkForm from './uiTools'; |
16 | 22 | ||
diff --git a/app/Resources/static/themes/baggy/js/shortcuts/entry.js b/app/Resources/static/themes/baggy/js/shortcuts/entry.js index d618f28e..77d267a3 100644 --- a/app/Resources/static/themes/baggy/js/shortcuts/entry.js +++ b/app/Resources/static/themes/baggy/js/shortcuts/entry.js | |||
@@ -1,19 +1,22 @@ | |||
1 | import Mousetrap from 'mousetrap'; | ||
2 | import $ from 'jquery'; | ||
3 | |||
1 | /* Article view */ | 4 | /* Article view */ |
2 | Mousetrap.bind('o', () => { | 5 | Mousetrap.bind('o', () => { |
3 | $('div#article_toolbar ul.links li:nth-child(2) a')[0].click(); | 6 | $('div#article_toolbar ul.links li:nth-child(2) a')[0].click(); |
4 | }); | 7 | }); |
5 | 8 | ||
6 | /* mark as favorite */ | 9 | /* mark as favorite */ |
7 | Mousetrap.bind('s', () => { | 10 | Mousetrap.bind('s', () => { |
8 | $('div#article_toolbar ul.links li:nth-child(5) a')[0].click(); | 11 | $('div#article_toolbar ul.links li:nth-child(5) a')[0].click(); |
9 | }); | 12 | }); |
10 | 13 | ||
11 | /* mark as read */ | 14 | /* mark as read */ |
12 | Mousetrap.bind('a', () => { | 15 | Mousetrap.bind('a', () => { |
13 | $('div#article_toolbar ul.links li:nth-child(4) a')[0].click(); | 16 | $('div#article_toolbar ul.links li:nth-child(4) a')[0].click(); |
14 | }); | 17 | }); |
15 | 18 | ||
16 | /* delete */ | 19 | /* delete */ |
17 | Mousetrap.bind('del', () => { | 20 | Mousetrap.bind('del', () => { |
18 | $('div#article_toolbar ul.links li:nth-child(7) a')[0].click(); | 21 | $('div#article_toolbar ul.links li:nth-child(7) a')[0].click(); |
19 | }); | 22 | }); |
diff --git a/app/Resources/static/themes/material/js/init.js b/app/Resources/static/themes/material/js/init.js index 3ff8de0a..9746224b 100755 --- a/app/Resources/static/themes/material/js/init.js +++ b/app/Resources/static/themes/material/js/init.js | |||
@@ -1,8 +1,17 @@ | |||
1 | /* jQuery */ | ||
1 | import $ from 'jquery'; | 2 | import $ from 'jquery'; |
3 | |||
4 | /* Annotations */ | ||
2 | import annotator from 'annotator'; | 5 | import annotator from 'annotator'; |
6 | |||
7 | /* Tools */ | ||
3 | import { savePercent, retrievePercent, initFilters, initExport } from '../../_global/js/tools'; | 8 | import { savePercent, retrievePercent, initFilters, initExport } from '../../_global/js/tools'; |
4 | import './shortcuts/main.js'; | 9 | |
5 | import './shortcuts/entry.js'; | 10 | /* Import shortcuts */ |
11 | import './shortcuts/main'; | ||
12 | import './shortcuts/entry'; | ||
13 | import '../../_global/js/shortcuts/main'; | ||
14 | import '../../_global/js/shortcuts/entry'; | ||
6 | 15 | ||
7 | require('materialize'); // eslint-disable-line | 16 | require('materialize'); // eslint-disable-line |
8 | 17 | ||
diff --git a/app/Resources/static/themes/material/js/shortcuts/entry.js b/app/Resources/static/themes/material/js/shortcuts/entry.js index 900a8214..674253b5 100644 --- a/app/Resources/static/themes/material/js/shortcuts/entry.js +++ b/app/Resources/static/themes/material/js/shortcuts/entry.js | |||
@@ -1,19 +1,22 @@ | |||
1 | import Mousetrap from 'mousetrap'; | ||
2 | import $ from 'jquery'; | ||
3 | |||
1 | /* open original article */ | 4 | /* open original article */ |
2 | Mousetrap.bind('o', () => { | 5 | Mousetrap.bind('o', () => { |
3 | $('ul.side-nav li:nth-child(2) a i')[0].click(); | 6 | $('ul.side-nav li:nth-child(2) a i')[0].click(); |
4 | }); | 7 | }); |
5 | 8 | ||
6 | /* mark as favorite */ | 9 | /* mark as favorite */ |
7 | Mousetrap.bind('s', () => { | 10 | Mousetrap.bind('s', () => { |
8 | $('ul.side-nav li:nth-child(5) a i')[0].click(); | 11 | $('ul.side-nav li:nth-child(5) a i')[0].click(); |
9 | }); | 12 | }); |
10 | 13 | ||
11 | /* mark as read */ | 14 | /* mark as read */ |
12 | Mousetrap.bind('a', () => { | 15 | Mousetrap.bind('a', () => { |
13 | $('ul.side-nav li:nth-child(4) a i')[0].click(); | 16 | $('ul.side-nav li:nth-child(4) a i')[0].click(); |
14 | }); | 17 | }); |
15 | 18 | ||
16 | /* delete */ | 19 | /* delete */ |
17 | Mousetrap.bind('del', () => { | 20 | Mousetrap.bind('del', () => { |
18 | $('ul.side-nav li:nth-child(6) a i')[0].click(); | 21 | $('ul.side-nav li:nth-child(6) a i')[0].click(); |
19 | }); | 22 | }); |
diff --git a/app/Resources/static/themes/material/js/shortcuts/main.js b/app/Resources/static/themes/material/js/shortcuts/main.js index ccd3c92d..62b7ec64 100644 --- a/app/Resources/static/themes/material/js/shortcuts/main.js +++ b/app/Resources/static/themes/material/js/shortcuts/main.js | |||
@@ -1,13 +1,71 @@ | |||
1 | /* Actions */ | 1 | import Mousetrap from 'mousetrap'; |
2 | Mousetrap.bind('g n', () => { | 2 | import $ from 'jquery'; |
3 | |||
4 | function toggleFocus(cardToToogleFocus) { | ||
5 | if (cardToToogleFocus) { | ||
6 | $(cardToToogleFocus).toggleClass('z-depth-4'); | ||
7 | } | ||
8 | } | ||
9 | let card; | ||
10 | let cardIndex; | ||
11 | let cardNumber; | ||
12 | let pagination; | ||
13 | |||
14 | $(document).ready(() => { | ||
15 | cardIndex = 0; | ||
16 | cardNumber = $('#content ul.data > li').length; | ||
17 | card = $('#content ul.data > li')[cardIndex]; | ||
18 | pagination = $('.pagination'); | ||
19 | |||
20 | /* If we come from next page */ | ||
21 | if (window.location.hash === '#prev') { | ||
22 | cardIndex = cardNumber - 1; | ||
23 | card = $('ul.data > li')[cardIndex]; | ||
24 | } | ||
25 | |||
26 | /* Focus current card */ | ||
27 | toggleFocus(card); | ||
28 | |||
29 | /* Actions */ | ||
30 | Mousetrap.bind('g n', () => { | ||
3 | $('#nav-btn-add').trigger('click'); | 31 | $('#nav-btn-add').trigger('click'); |
4 | }); | 32 | }); |
5 | 33 | ||
6 | Mousetrap.bind('esc', () => { | 34 | Mousetrap.bind('esc', () => { |
7 | $('.close').trigger('click'); | 35 | $('.close').trigger('click'); |
8 | }); | 36 | }); |
37 | |||
38 | /* Select right card. If there's a next page, go to next page */ | ||
39 | Mousetrap.bind('right', () => { | ||
40 | if (cardIndex >= 0 && cardIndex < cardNumber - 1) { | ||
41 | toggleFocus(card); | ||
42 | cardIndex += 1; | ||
43 | card = $('ul.data > li')[cardIndex]; | ||
44 | toggleFocus(card); | ||
45 | return; | ||
46 | } | ||
47 | if (pagination != null && pagination.find('li.next') && cardIndex === cardNumber - 1) { | ||
48 | window.location.href = window.location.origin + $(pagination).find('li.next a').attr('href'); | ||
49 | return; | ||
50 | } | ||
51 | }); | ||
52 | |||
53 | /* Select previous card. If there's a previous page, go to next page */ | ||
54 | Mousetrap.bind('left', () => { | ||
55 | if (cardIndex > 0 && cardIndex < cardNumber) { | ||
56 | toggleFocus(card); | ||
57 | cardIndex -= 1; | ||
58 | card = $('ul.data > li')[cardIndex]; | ||
59 | toggleFocus(card); | ||
60 | return; | ||
61 | } | ||
62 | if (pagination !== null && $(pagination).find('li.prev') && cardIndex === 0) { | ||
63 | window.location.href = `${window.location.origin + $(pagination).find('li.prev a').attr('href')}#prev`; | ||
64 | return; | ||
65 | } | ||
66 | }); | ||
9 | 67 | ||
10 | // Display the first element of the current view | 68 | Mousetrap.bind('enter', () => { |
11 | Mousetrap.bind('right', () => { | 69 | window.location.href = window.location.origin + $(card).find('span.card-title a').attr('href'); |
12 | $('ul.data li:first-child span.dot-ellipsis a')[0].click(); | 70 | }); |
13 | }); | 71 | }); |