mirror of https://github.com/searxng/searxng.git
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.
This commit is contained in:
parent
fb6ff5afcb
commit
0ae86cd168
|
@ -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');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue