[Search] Empty search resets results

When there is no input into the search bar
no results are displayed/displayed results
are removed. This is because the search
providers were changed to return empty
arrays for empty search strings.
This commit is contained in:
shale 2015-07-22 16:09:14 -07:00
parent b16af5fe3e
commit b0e7dca985
5 changed files with 39 additions and 28 deletions

View File

@ -272,9 +272,9 @@ ul.tree {
* at runtime from the About dialog for additional information.
*****************************************************************************/
/* line 27, ../sass/search/_search.scss */
.search .searchbar {
.search .search-input {
width: 100%;
margin-top: 20px; }
margin-top: 10px; }
/* line 32, ../sass/search/_search.scss */
.search .results {
margin-top: 10px; }

View File

@ -24,9 +24,9 @@
$iconWidth: 20px;
$leftMargin: 6px;
.searchbar {
.search-input {
width: 100%;
margin-top: 20px;
margin-top: 10px;
}
.results {

View File

@ -23,7 +23,7 @@
ng-controller="SearchController as controller">
<!-- Search bar input -->
<div>
<input class="searchbar"
<input class="search-input"
id="searchbarinput"
type="text"
value=""

View File

@ -159,6 +159,8 @@ define(
// Get the user input
searchTerm = document.getElementById(inputID).value;
// If the user input is empty, we want to have no search results.
if (searchTerm !== '') {
// Process search term
searchTerm = processSearchTerm(searchTerm);
@ -177,6 +179,11 @@ define(
// ...then process the data
return processResults(rawResults, timestamp);
});
} else {
latestResults = [];
lastSearchTimestamp = timestamp;
return latestResults;
}
}
return {

View File

@ -135,6 +135,9 @@
terms = convertToTerms(input),
timesToLoop = Math.min(indexedItems.length, data.maxNumber);
// If the user input is empty, we want to have no search results.
if (input !== '') {
for (var i = 0; i < timesToLoop; i++) {
var score = scoreItem(indexedItems[i], input, terms);
if (score > 0) {
@ -143,6 +146,7 @@
};
}
}
}
var message = {
request: 'search',