mirror of
https://github.com/searxng/searxng
synced 2024-01-01 19:24:07 +01:00
[feat] simple theme: image preview use arrow keys
This commit is contained in:
parent
019bd97f4b
commit
e46a2a3e13
1 changed files with 16 additions and 0 deletions
|
|
@ -32,6 +32,10 @@ searxng.ready(function () {
|
||||||
return resultElement && resultElement.classList.contains('result-images');
|
return resultElement && resultElement.classList.contains('result-images');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hasImageInDetail () {
|
||||||
|
return document.querySelector('#results.image-detail-open') !== null;
|
||||||
|
}
|
||||||
|
|
||||||
searxng.on('.result', 'click', function (e) {
|
searxng.on('.result', 'click', function (e) {
|
||||||
if (!isElementInDetail(e.target)) {
|
if (!isElementInDetail(e.target)) {
|
||||||
highlightResult(this)(true, true);
|
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) {
|
function highlightResult (which) {
|
||||||
return function (noScroll, keepFocus) {
|
return function (noScroll, keepFocus) {
|
||||||
var current = document.querySelector('.result[data-vim-selected]'),
|
var current = document.querySelector('.result[data-vim-selected]'),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue