‘use strict’;
function initMiniSearch() {
return {
minSearchLength: 1,
suggestionsAllowed: false,
suggestions: [],
inputValue: ”,
checkInputValue() {
this.inputValue = this.$refs.searchInput.value;
},
clearInput() {
this.$refs.searchInput.value = ”;
this.checkInputValue();
},
loadInput(){
const urlParams = new URLSearchParams(window.location.search);
const paramValue = urlParams.get(‘q’);
if(paramValue){
this.inputValue = paramValue;
}
},
suggest() {
const search = this.$refs.searchInput;
if (search.value.length >= this.minSearchLength) {
search.setCustomValidity(”);
search.reportValidity();
// Start Klevu customisation of default Hyvä template
if (this.suggestionsAllowed) {
this.fetchSuggestions(search.value);
} else {
this.suggestions = [];
}
// End Klevu customisation of default Hyvä template
} else {
this.suggestions = [];
}
},
fetchSuggestions(term) {
fetch(
window.BASE_URL + ‘search/ajax/suggest?’ + new URLSearchParams({q: term}),
{
headers: {
‘X-Requested-With’: ‘XMLHttpRequest’
}
}
)
.then(response => response.json())
.then(result => this.suggestions = result);
},
search(term) {
const search = this.$refs.searchInput;
term = term || search.value;
if (term.length < this.minSearchLength) {
search.setCustomValidity('Minimumu0020Searchu0020queryu0020lengthu0020isu00201');
search.reportValidity();
} else {
search.setCustomValidity('');
search.value = term;
this.$refs.form.submit();
}
},
focusElement(element) {
if (element && element.nodeName === "DIV") {
element.focus();
return true;
} else {
return false;
}
}
}
}
0″>
Search
Reviews
Clear filtersThere are no reviews yet.