This commit is contained in:
parent
692a065f82
commit
31ff5555d8
|
@ -132,9 +132,21 @@ function showSearchResultsExtended(element, template, searchTool, query, input,
|
||||||
|
|
||||||
let $ul = el('ul',
|
let $ul = el('ul',
|
||||||
_.map(results, (hit, i) => {
|
_.map(results, (hit, i) => {
|
||||||
const li = el('li', [document.createTextNode(hit.item.label || hit.item.title)])
|
let div = el('div', []);
|
||||||
|
div.innerHTML = hit.text
|
||||||
|
const fragment = hit.text ? [div] : []
|
||||||
|
|
||||||
|
let children = [
|
||||||
|
document.createTextNode(hit.title || hit.item.label || hit.item.title),
|
||||||
|
...(fragment)
|
||||||
|
];
|
||||||
|
if (hit.ref) {
|
||||||
|
children = hit.ref ? [el('a', children)] : children;
|
||||||
|
children[0].setAttribute('href', '/edit/' + hit.ref)
|
||||||
|
}
|
||||||
|
const li = el('li', children)
|
||||||
if (selectedPos === i) li.classList.add('selected')
|
if (selectedPos === i) li.classList.add('selected')
|
||||||
li.dataset['new_page'] = hit.item.title
|
li.dataset['new_page'] = hit.title || hit.item.title
|
||||||
return li
|
return li
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
|
@ -43,7 +43,7 @@ $(document).on('keydown', '#search-input', function (event) {
|
||||||
if (event.key === 'Enter') {
|
if (event.key === 'Enter') {
|
||||||
_.defer(() => {
|
_.defer(() => {
|
||||||
let $a = $('#autocomplete li.selected > a');
|
let $a = $('#autocomplete li.selected > a');
|
||||||
$a[0].click()
|
if ($a.length) $a[0].click()
|
||||||
})
|
})
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -54,12 +54,16 @@ $(document).on('keydown', '#search-input', function (event) {
|
||||||
|
|
||||||
if (event.key === 'ArrowDown') {
|
if (event.key === 'ArrowDown') {
|
||||||
let x = $ac.find('li.selected').removeClass('selected').next('li').addClass('selected')
|
let x = $ac.find('li.selected').removeClass('selected').next('li').addClass('selected')
|
||||||
|
if (x.length) {
|
||||||
x[0].scrollIntoView({behavior: "smooth", block: "nearest"})
|
x[0].scrollIntoView({behavior: "smooth", block: "nearest"})
|
||||||
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if (event.key === 'ArrowUp') {
|
if (event.key === 'ArrowUp') {
|
||||||
let x = $ac.find('li.selected').removeClass('selected').prev('li').addClass('selected')
|
let x = $ac.find('li.selected').removeClass('selected').prev('li').addClass('selected')
|
||||||
|
if (x.length) {
|
||||||
x[0].scrollIntoView({behavior: "smooth", block: "nearest"})
|
x[0].scrollIntoView({behavior: "smooth", block: "nearest"})
|
||||||
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user