diff options
author | Nick Espig <nickespig@gmail.com> | 2019-06-04 19:16:19 +0200 |
---|---|---|
committer | Nick Bernd Espig <info@nachtalb.io> | 2019-12-16 19:31:29 +0100 |
commit | 0ae86cd1685d244c83a6080a7816365096ab06f8 (patch) | |
tree | 338f7f4d53434ad1ecefa664b028925f19afb4d6 | |
parent | fb6ff5afcb1ec5771bc149fee25d186198aa7607 (diff) | |
download | searxng-0ae86cd1685d244c83a6080a7816365096ab06f8.tar.gz searxng-0ae86cd1685d244c83a6080a7816365096ab06f8.zip |
Fix not jumping to results loaded by infinite scroll
Infinite scroll adds a `hr` tag to split up the sections loaded by it.
The vim bindings `j` and `k`, which jump to the next and previous result
respectively, search for a **direct** sibling with the class `result`.
With the `hr` between results a direct sibling cannot be found. To fix
this we remove the restriction of it having to be a direct sibling.
-rw-r--r-- | searx/static/plugins/js/vim_hotkeys.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/searx/static/plugins/js/vim_hotkeys.js b/searx/static/plugins/js/vim_hotkeys.js index 13bd070e0..b0f265cb5 100644 --- a/searx/static/plugins/js/vim_hotkeys.js +++ b/searx/static/plugins/js/vim_hotkeys.js @@ -125,6 +125,14 @@ $(document).ready(function() { } }); + function nextResult(current, direction) { + var next = current[direction](); + while (!next.is('.result') && next.length !== 0) { + next = next[direction](); + } + return next + } + function highlightResult(which) { return function() { var current = $('.result[data-vim-selected]'); @@ -157,13 +165,13 @@ $(document).ready(function() { } break; case 'down': - next = current.next('.result'); + next = nextResult(current, 'next'); if (next.length === 0) { next = $('.result:first'); } break; case 'up': - next = current.prev('.result'); + next = nextResult(current, 'prev'); if (next.length === 0) { next = $('.result:last'); } |