Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1836)

Unified Diff: chrome/browser/resources/file_manager/js/file_manager.js

Issue 13771005: Files.app: Separate the last search query from "lastQuery" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comment Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/file_manager/js/file_manager.js
diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js
index 4d735c5fd8d42ee67e6ccf7ca3d5ab1851c69e17..00a5ffe3ecb4a18310b6ac646bc7cb93b0797aab 100644
--- a/chrome/browser/resources/file_manager/js/file_manager.js
+++ b/chrome/browser/resources/file_manager/js/file_manager.js
@@ -779,6 +779,7 @@ DialogType.isModal = function(type) {
this.searchBox_ = this.dialogDom_.querySelector('#search-box');
this.searchBox_.addEventListener(
'input', this.onSearchBoxUpdate_.bind(this));
+ this.lastSearchQuery_ = '';
var autocompleteList = new cr.ui.AutocompleteList();
autocompleteList.id = 'autocomplete-list';
@@ -3055,8 +3056,8 @@ DialogType.isModal = function(type) {
// the last directory by passing an empty string to
// {@code DirectoryModel.search()}.
if (this.directoryModel_.isSearching() &&
- this.lastQuery_ != searchString) {
- this.directoryModel_.search('', function() {}, function() {});
+ this.lastSearchQuery_ != searchString) {
+ this.doSearch('');
}
// On drive, incremental search is not invoked since we have an auto-
@@ -3093,9 +3094,27 @@ DialogType.isModal = function(type) {
noResultsDiv.removeAttribute('show');
};
- this.directoryModel_.search(searchString,
- reportEmptySearchResults.bind(this),
- hideNoResultsDiv.bind(this));
+ this.doSearch(searchString,
+ reportEmptySearchResults.bind(this),
+ hideNoResultsDiv.bind(this));
+ };
+
+ /**
+ * Performs search and displays results.
+ *
+ * @param {string} query Query that will be searched for.
+ * @param {function()=} opt_onSearchRescan Function that will be called when
+ * the search directory is rescanned (i.e. search results are displayed).
+ * @param {function()=} opt_onClearSearch Function to be called when search
+ * state gets cleared.
+ */
+ FileManager.prototype.doSearch = function(
+ searchString, opt_onSearchRescan, opt_onClearSearch) {
+ var onSearchRescan = opt_onSearchRescan || function() {};
+ var onClearSearch = opt_onClearSearch || function() {};
+
+ this.lastSearchQuery_ = searchString;
+ this.directoryModel_.search(searchString, onSearchRescan, onClearSearch);
};
/**
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698