Chromium Code Reviews| 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..dc734fcab61ebf246e353978bc3fafdc7726874f 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,15 @@ Downloads.prototype.updateDateDisplay_ = function() { |
| container.style.display = 'block'; |
| } |
| } |
| + |
| + var hasDownloads = this.size() > 0; |
| + this.node_.hidden = !hasDownloads; |
| + this.noDownloadsOrResults_.hidden = hasDownloads; |
| + |
| + if (!this.noDownloadsOrResults_.hidden) { |
|
benjhayden
2014/11/06 16:59:54
if (!hasDownloads) ?
Dan Beam
2014/11/06 19:57:52
eh, just changed the code to set the text content
|
| + this.noDownloadsOrResults_.textContent = loadTimeData.getString( |
| + this.searchText_ ? 'no_search_results' : 'no_downloads'); |
| + } |
| }; |
| /** |
| @@ -199,7 +206,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_(); |
| }; |
| /** |