diff options
| author | Alexandre Flament <alex@al-f.net> | 2021-03-10 19:41:05 +0100 |
|---|---|---|
| committer | Alexandre Flament <alex@al-f.net> | 2021-03-11 09:33:01 +0100 |
| commit | 86912e22728b8428d25b075be57cd35d6e484692 (patch) | |
| tree | af2c50838fe7d8a08f4a45bf9ee9fb5c835baceb /searx/static/themes/oscar/src/js | |
| parent | 44407353ef3dbab4e4249e9cca6955a500b8e539 (diff) | |
[mod] oscar: get bootstrap and typeahead from NPM
Diffstat (limited to 'searx/static/themes/oscar/src/js')
| -rw-r--r-- | searx/static/themes/oscar/src/js/autocompleter.js | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/searx/static/themes/oscar/src/js/autocompleter.js b/searx/static/themes/oscar/src/js/autocompleter.js index 26d567507..56293f4f3 100644 --- a/searx/static/themes/oscar/src/js/autocompleter.js +++ b/searx/static/themes/oscar/src/js/autocompleter.js @@ -15,31 +15,42 @@ * (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); } |