fix #86 keyboard walk up/dow respects filters
This commit is contained in:
parent
f8c5242a41
commit
50d031fe98
35
index.js
35
index.js
|
@ -232,21 +232,26 @@ function toggleFavorite(alias) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function nextFont() {
|
function walk(direction) {
|
||||||
var activeEntry = document.querySelector('.entry.active');
|
var activeEntry = document.querySelector('.entry.active');
|
||||||
var next = activeEntry.nextSibling;
|
var target = null;
|
||||||
if (next && next.matches('.entry')) {
|
var next = direction === 'up' ? activeEntry.previousSibling : activeEntry.nextSibling;
|
||||||
next.querySelector('a').click();
|
|
||||||
next.scrollIntoView();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function previousFont() {
|
while (target === null) {
|
||||||
var activeEntry = document.querySelector('.entry.active');
|
if (next) {
|
||||||
var next = activeEntry.previousSibling;
|
if (next.matches('.entry:not(.filtered-out)')) {
|
||||||
if (next && next.matches('.entry')) {
|
target = next;
|
||||||
next.querySelector('a').click();
|
} else {
|
||||||
next.scrollIntoView();
|
next = direction === 'up' ? next.previousSibling : next.nextSibling;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
target = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target) {
|
||||||
|
target.querySelector('a').click();
|
||||||
|
target.scrollIntoView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,12 +350,12 @@ $(document).ready(function() {
|
||||||
if (event.key === 'ArrowUp') {
|
if (event.key === 'ArrowUp') {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
previousFont();
|
walk('up');
|
||||||
return;
|
return;
|
||||||
} else if (event.key === 'ArrowDown') {
|
} else if (event.key === 'ArrowDown') {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
nextFont();
|
walk('down');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue