]>
git.immae.eu Git - github/wallabag/wallabag.git/blob - app/Resources/static/themes/material/js/shortcuts/main.js
1 import Mousetrap
from 'mousetrap';
2 import $ from 'jquery';
4 function toggleFocus(cardToToogleFocus
) {
5 if (cardToToogleFocus
) {
6 $(cardToToogleFocus
).toggleClass('z-depth-4');
10 $(document
).ready(() => {
12 const cardNumber
= $('#content ul.data > li').length
;
13 let card
= $('#content ul.data > li')[cardIndex
];
14 const pagination
= $('.pagination');
16 /* Show nothing on quickstart */
17 if ($('#content > div.quickstart').length
> 0) {
21 /* If we come from next page */
22 if (window
.location
.hash
=== '#prev') {
23 cardIndex
= cardNumber
- 1;
24 card
= $('ul.data > li')[cardIndex
];
27 /* Focus current card */
31 Mousetrap
.bind('g n', () => {
32 $('#nav-btn-add').trigger('click');
36 Mousetrap
.bind('s', () => {
37 $('#nav-btn-search').trigger('click');
41 Mousetrap
.bind('esc', () => {
42 $('.close').trigger('click');
45 /* Select right card. If there's a next page, go to next page */
46 Mousetrap
.bind('right', () => {
47 if (cardIndex
>= 0 && cardIndex
< cardNumber
- 1) {
50 card
= $('ul.data > li')[cardIndex
];
54 if (pagination
.length
> 0 && pagination
.find('li.next:not(.disabled)').length
> 0 && cardIndex
=== cardNumber
- 1) {
55 window
.location
.href
= window
.location
.origin
+ $(pagination
).find('li.next a').attr('href');
59 /* Select previous card. If there's a previous page, go to next page */
60 Mousetrap
.bind('left', () => {
61 if (cardIndex
> 0 && cardIndex
< cardNumber
) {
64 card
= $('ul.data > li')[cardIndex
];
68 if (pagination
.length
> 0 && $(pagination
).find('li.prev:not(.disabled)').length
> 0 && cardIndex
=== 0) {
69 window
.location
.href
= `${window.location.origin + $(pagination).find('li.prev a').attr('href')}#prev`;
73 Mousetrap
.bind('enter', () => {
74 window
.location
.href
= window
.location
.origin
+ $(card
).find('span.card-title a').attr('href');