24 lines
651 B
JavaScript
24 lines
651 B
JavaScript
|
let remoteValue;
|
||
|
if (typeof os_return_all !== 'function') {
|
||
|
function os_return_all() { return []; }
|
||
|
remoteValue = { url: '?q=%QUERY&json', wildcard: '%QUERY' }
|
||
|
}
|
||
|
|
||
|
let os_bloodhound = new Bloodhound({
|
||
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('title'),
|
||
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||
|
limit: 5,
|
||
|
remote: remoteValue,
|
||
|
local: os_return_all
|
||
|
});
|
||
|
|
||
|
$('input[type="text"].os_typeahead').attr('autocomplete', 'off').typeahead({
|
||
|
hint: true,
|
||
|
highlight: true,
|
||
|
minLength: 3
|
||
|
}, {
|
||
|
source: os_bloodhound,
|
||
|
display: 'title'
|
||
|
}).bind('typeahead:selected', function (obj, datum) {
|
||
|
window.location.href = datum.url;
|
||
|
});
|