diff --git a/resources/assets/js/components/searchform.js b/resources/assets/js/components/searchform.js new file mode 100644 index 000000000..e23843edf --- /dev/null +++ b/resources/assets/js/components/searchform.js @@ -0,0 +1,55 @@ +$(document).ready(function() { + + let queryEngine = new Bloodhound({ + datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'), + queryTokenizer: Bloodhound.tokenizers.whitespace, + remote: { + url: process.env.MIX_API_SEARCH + '/%QUERY', + wildcard: '%QUERY' + } + }); + + $('.search-form .search-form-input').typeahead(null, { + name: 'search', + display: 'value', + source: queryEngine, + limit: 20, + templates: { + empty: [ + '
'+data.value+'
' + + ''+data.count+' posts
' + + ''+data.name+'
' + + ''+data.value+'
' + + '