mirror of
https://github.com/searxng/searxng.git
synced 2026-06-04 17:07:17 +02:00
[mod] oscar: get bootstrap and typeahead from NPM
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -45,31 +45,42 @@ window.searx = (function(d) {
|
||||
* (C) 2014 by Thomas Pointhuber, <thomas.pointhuber@gmx.at>
|
||||
*/
|
||||
|
||||
if(searx.autocompleter) {
|
||||
searx.searchResults = new Bloodhound({
|
||||
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
|
||||
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||
remote: './autocompleter?q=%QUERY'
|
||||
});
|
||||
searx.searchResults.initialize();
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
var original_search_value = '';
|
||||
if(searx.autocompleter) {
|
||||
$("#q").on('keydown', function(e) {
|
||||
var searchResults = new Bloodhound({
|
||||
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
|
||||
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||
remote: {
|
||||
url: './autocompleter?q=%QUERY',
|
||||
wildcard: '%QUERY'
|
||||
}
|
||||
});
|
||||
searchResults.initialize();
|
||||
|
||||
$("#q").on('keydown', function(e) {
|
||||
if(e.which == 13) {
|
||||
original_search_value = $('#q').val();
|
||||
}
|
||||
});
|
||||
$('#q').typeahead(null, {
|
||||
$('#q').typeahead({
|
||||
name: 'search-results',
|
||||
highlight: false,
|
||||
hint: true,
|
||||
displayKey: function(result) {
|
||||
return result;
|
||||
},
|
||||
source: searx.searchResults.ttAdapter()
|
||||
classNames: {
|
||||
input: 'tt-input',
|
||||
hint: 'tt-hint',
|
||||
menu: 'tt-dropdown-menu',
|
||||
dataset: 'tt-dataset-search-results',
|
||||
},
|
||||
}, {
|
||||
name: 'autocomplete',
|
||||
source: searchResults,
|
||||
});
|
||||
$('#q').bind('typeahead:selected', function(ev, suggestion) {
|
||||
$('#q').bind('typeahead:select', function(ev, suggestion) {
|
||||
if(original_search_value) {
|
||||
$('#q').val(original_search_value);
|
||||
}
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user