summaryrefslogtreecommitdiff
path: root/searx/static/themes/oscar/js/searx.js
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2021-03-10 19:41:05 +0100
committerAlexandre Flament <alex@al-f.net>2021-03-11 09:33:01 +0100
commit86912e22728b8428d25b075be57cd35d6e484692 (patch)
treeaf2c50838fe7d8a08f4a45bf9ee9fb5c835baceb /searx/static/themes/oscar/js/searx.js
parent44407353ef3dbab4e4249e9cca6955a500b8e539 (diff)
[mod] oscar: get bootstrap and typeahead from NPM
Diffstat (limited to 'searx/static/themes/oscar/js/searx.js')
-rw-r--r--searx/static/themes/oscar/js/searx.js37
1 files changed, 24 insertions, 13 deletions
diff --git a/searx/static/themes/oscar/js/searx.js b/searx/static/themes/oscar/js/searx.js
index 4e3904a06..159344b28 100644
--- a/searx/static/themes/oscar/js/searx.js
+++ b/searx/static/themes/oscar/js/searx.js
@@ -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);
}