[feat] simple theme: image preview use arrow keys

This commit is contained in:
bonswouar 2023-09-07 16:13:44 +02:00
parent 019bd97f4b
commit e46a2a3e13

View File

@ -32,6 +32,10 @@ searxng.ready(function () {
return resultElement && resultElement.classList.contains('result-images');
}
function hasImageInDetail () {
return document.querySelector('#results.image-detail-open') !== null;
}
searxng.on('.result', 'click', function (e) {
if (!isElementInDetail(e.target)) {
highlightResult(this)(true, true);
@ -171,6 +175,18 @@ searxng.ready(function () {
});
}
searxng.on(document, 'keydown', function (e) {
if (hasImageInDetail()) {
if (e.key === 'ArrowLeft') {
e.preventDefault();
searxng.selectPrevious(false);
} else if (e.key === 'ArrowRight') {
e.preventDefault();
searxng.selectNext(false);
}
}
});
function highlightResult (which) {
return function (noScroll, keepFocus) {
var current = document.querySelector('.result[data-vim-selected]'),