]>
git.immae.eu Git - github/wallabag/wallabag.git/blob - app/Resources/static/themes/material/js/shortcuts/main.js
62b7ec6455e8fe71117c65630601e8258c2b948d
1 import Mousetrap
from 'mousetrap';
2 import $ from 'jquery';
4 function toggleFocus(cardToToogleFocus
) {
5 if (cardToToogleFocus
) {
6 $(cardToToogleFocus
).toggleClass('z-depth-4');
14 $(document
).ready(() => {
16 cardNumber
= $('#content ul.data > li').length
;
17 card
= $('#content ul.data > li')[cardIndex
];
18 pagination
= $('.pagination');
20 /* If we come from next page */
21 if (window
.location
.hash
=== '#prev') {
22 cardIndex
= cardNumber
- 1;
23 card
= $('ul.data > li')[cardIndex
];
26 /* Focus current card */
30 Mousetrap
.bind('g n', () => {
31 $('#nav-btn-add').trigger('click');
34 Mousetrap
.bind('esc', () => {
35 $('.close').trigger('click');
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) {
43 card
= $('ul.data > li')[cardIndex
];
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');
53 /* Select previous card. If there's a previous page, go to next page */
54 Mousetrap
.bind('left', () => {
55 if (cardIndex
> 0 && cardIndex
< cardNumber
) {
58 card
= $('ul.data > li')[cardIndex
];
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`;
68 Mousetrap
.bind('enter', () => {
69 window
.location
.href
= window
.location
.origin
+ $(card
).find('span.card-title a').attr('href');