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

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

Issue 702353002: downloads: add "No downloads" and "No search results" messages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: benjhayden@ review Created 6 years, 1 month 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 | « chrome/browser/resources/downloads/downloads.html ('k') | chrome/browser/ui/webui/downloads_ui.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/downloads/downloads.js
diff --git a/chrome/browser/resources/downloads/downloads.js b/chrome/browser/resources/downloads/downloads.js
index ac72b3e4fadbbd99cef83a62051f98161a0ffcde..98a3c6ee0a817423e7fd60d143ca4b30941e7e2a 100644
--- a/chrome/browser/resources/downloads/downloads.js
+++ b/chrome/browser/resources/downloads/downloads.js
@@ -89,6 +89,7 @@ function Downloads() {
*/
this.downloads_ = {};
this.node_ = $('downloads-display');
+ this.noDownloadsOrResults_ = $('no-downloads-or-results');
this.summary_ = $('downloads-summary-text');
this.searchText_ = '';
@@ -108,6 +109,8 @@ function Downloads() {
'chrome://theme/IDR_DOWNLOAD_PROGRESS_FOREGROUND_32@2x';
window.addEventListener('keydown', this.onKeyDown_.bind(this));
+
+ this.onDownloadListChanged_();
}
/**
@@ -136,7 +139,7 @@ Downloads.prototype.updated = function(download) {
// TODO(benjhayden) Only do this if its nodeSince_ or nodeDate_ actually did
// change since this may touch 150 elements and Downloads.prototype.updated
// may be called 150 times.
- this.updateDateDisplay_();
+ this.onDownloadListChanged_();
};
/**
@@ -157,12 +160,6 @@ Downloads.prototype.updateSummary = function() {
} else {
this.summary_.textContent = '';
}
-
- var hasDownloads = false;
- for (var i in this.downloads_) {
- hasDownloads = true;
- break;
- }
};
/**
@@ -174,11 +171,12 @@ Downloads.prototype.size = function() {
};
/**
- * Update the date visibility in our nodes so that no date is
- * repeated.
+ * Called whenever the downloads lists items have changed (either by being
+ * updated, added, or removed).
* @private
*/
-Downloads.prototype.updateDateDisplay_ = function() {
+Downloads.prototype.onDownloadListChanged_ = function() {
+ // Update the date visibility in our nodes so that no date is repeated.
var dateContainers = document.getElementsByClassName('date-container');
var displayed = {};
for (var i = 0, container; container = dateContainers[i]; i++) {
@@ -190,6 +188,13 @@ Downloads.prototype.updateDateDisplay_ = function() {
container.style.display = 'block';
}
}
+
+ this.noDownloadsOrResults_.textContent = loadTimeData.getString(
+ this.searchText_ ? 'no_search_results' : 'no_downloads');
+
+ var hasDownloads = this.size() > 0;
+ this.node_.hidden = !hasDownloads;
+ this.noDownloadsOrResults_.hidden = hasDownloads;
};
/**
@@ -199,7 +204,7 @@ Downloads.prototype.updateDateDisplay_ = function() {
Downloads.prototype.remove = function(id) {
this.node_.removeChild(this.downloads_[id].node);
delete this.downloads_[id];
- this.updateDateDisplay_();
+ this.onDownloadListChanged_();
};
/**
« no previous file with comments | « chrome/browser/resources/downloads/downloads.html ('k') | chrome/browser/ui/webui/downloads_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698