Skip to content
Snippets Groups Projects
Verified Commit 02a8984f authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

[Global search] Fix minimum_length behaviour and set minimum_length to 2

parent 22b799fe
No related branches found
No related tags found
1 merge request!225Design fixes for global search
Pipeline #1404 failed
......@@ -66,7 +66,7 @@ $(document).ready( function () {
});
// Initialise auto-completion for search bar
window.autocomplete = new Autocomplete({});
window.autocomplete = new Autocomplete({minimum_length: 2});
window.autocomplete.setup();
// Initialize text collapsibles [MAT, own work]
......
......@@ -35,9 +35,20 @@ Autocomplete.prototype.setup = function () {
self.query_box.trigger("keydown");
});
this.query_box.keyup(function () {
var query = self.query_box.val();
if (query.length < self.minimum_length) {
$("#search-results").remove();
return true;
}
self.fetch(query);
return true;
});
// Watch the input box.
this.query_box.keydown(function (e) {
var query = self.query_box.val();
if (e.which === 38) { // Keypress Up
if (!self.selected_element) {
......@@ -69,14 +80,6 @@ Autocomplete.prototype.setup = function () {
e.preventDefault();
window.location.href = self.selected_element.attr("href");
}
if (query.length < self.minimum_length) {
$("#search-results").remove();
return true;
}
self.fetch(query);
return true;
});
// // On selecting a result, remove result box
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment