Show hint when more search results are available

This commit is contained in:
Brian Clozel
2016-11-24 16:16:38 +01:00
parent c4bfbe755e
commit 009c9a1572
2 changed files with 22 additions and 3 deletions

View File

@@ -121,9 +121,9 @@ input[type=text] {
}
.tt-suggestion {
padding: 3px 20px;
font-size: 18px;
line-height: 24px;
padding: 4px 20px;
font-size: 16px;
line-height: 22px;
}
.tt-suggestion:hover {
@@ -137,6 +137,15 @@ input[type=text] {
background-color: #0097cf;
}
.tt-footer {
padding: 6px 20px 0px 20px;
font-size: 13px;
line-height: 15px;
text-align: center;
font-style: italic;
border-top: 1px solid #ccc;
}
footer {
position: absolute;
bottom: 0;

View File

@@ -182,6 +182,7 @@ $(function () {
$("body").scrollTop(0);
return false;
});
var maxSuggestions = 5;
var starters = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.nonword('name', 'description', 'keywords', 'group'),
queryTokenizer: Bloodhound.tokenizers.nonword,
@@ -191,6 +192,7 @@ $(function () {
sorter: function(a,b) {
return b.weight - a.weight;
},
limit: maxSuggestions,
cache: false
});
initializeSearchEngine(starters, $("#bootVersion").val());
@@ -205,6 +207,14 @@ $(function () {
templates: {
suggestion: function (data) {
return "<div><strong>" + data.name + "</strong><br/><small>" + data.description + "</small></div>";
},
footer: function(search) {
if (search.suggestions && search.suggestions.length == maxSuggestions) {
return "<div class=\"tt-footer\">More matches, please refine your search</div>";
}
else {
return "";
}
}
}
});