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

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

Issue 10388142: Show the message 'No files match "abc"' if the search results are empty. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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
Index: chrome/browser/resources/file_manager/js/file_manager.js
===================================================================
--- chrome/browser/resources/file_manager/js/file_manager.js (revision 137095)
+++ chrome/browser/resources/file_manager/js/file_manager.js (working copy)
@@ -267,6 +267,10 @@
// Instance methods.
+ FileManager.prototype.$ = function(id) {
dgozman 2012/05/15 13:12:39 Don't like this :(
Vladislav Kaznacheev 2012/05/15 13:38:13 Oh no.
Oleg Eterevsky 2012/05/15 13:55:28 Done.
Oleg Eterevsky 2012/05/15 13:55:28 Done.
+ return this.document_.getElementById(id);
+ };
+
/**
* Request local file system, resolve roots and init_ after that.
* @private
@@ -4337,15 +4341,39 @@
};
FileManager.prototype.onSearchBoxUpdate_ = function(event) {
- var searchString = this.dialogDom_.querySelector('#search-box').value;
+ var searchString = this.$('search-box').value;
if (searchString) {
this.directoryModel_.addFilter(
'searchbox',
function(e) {
return e.name.substr(0, searchString.length) == searchString;
});
+
+ var self = this;
+
+ this.reportEmptySearchResults_ = function() {
+ if (self.directoryModel_.getFileList().length === 0) {
+ var template = str('SEARCH_NO_MATCHING_FILES');
+ var index = template.indexOf('$1');
dgozman 2012/05/15 13:12:39 You can just use <b>$1</b> inside the localized st
Oleg Eterevsky 2012/05/15 13:55:28 Done.
+ self.$('no-search-results-prefix').textContent =
+ template.substring(0, index - 1);
+ self.$('no-search-results-suffix').textContent =
+ template.substring(index + 3);
+ var quotedSearchString = template.substring(index - 1, index + 3);
+ self.$('no-search-results-query').textContent =
+ quotedSearchString.replace('$1', searchString);
+
+ self.$('list-container').setAttribute('no-search-results', 'true');
+ }
Vladislav Kaznacheev 2012/05/15 13:38:13 add .bind(this) and you do not need var self
Oleg Eterevsky 2012/05/15 13:55:28 Done.
Oleg Eterevsky 2012/05/15 13:55:28 Done.
+ };
+
+ this.directoryModel_.addEventListener(
+ 'rescan-completed', this.reportEmptySearchResults_);
} else {
this.directoryModel_.removeFilter('searchbox');
+ this.$('list-container').setAttribute('no-search-results', 'false');
+ this.directoryModel_.removeEventListener(
+ 'rescan-completed', this.reportEmptySearchResults_);
}
};

Powered by Google App Engine
This is Rietveld 408576698