Chromium Code Reviews| Index: chrome/browser/resources/md_downloads/item.js |
| diff --git a/chrome/browser/resources/md_downloads/item.js b/chrome/browser/resources/md_downloads/item.js |
| index 2f43efc43bf71648aad800d370f95a55398659e6..032776e06bf9e64c49bda4eabf0e2f267e6ac1b0 100644 |
| --- a/chrome/browser/resources/md_downloads/item.js |
| +++ b/chrome/browser/resources/md_downloads/item.js |
| @@ -65,6 +65,13 @@ cr.define('downloads', function() { |
| }, |
| }, |
| + isActive_: { |
| + computed: 'computeIsActive_(' + |
| + 'data_.state, data_.file_externally_removed)', |
| + type: Boolean, |
| + value: true, |
| + }, |
| + |
| isDangerous_: { |
| computed: 'computeIsDangerous_(data_.state)', |
| type: Boolean, |
| @@ -140,31 +147,18 @@ cr.define('downloads', function() { |
| this.set('data_.' + key, data[key]); |
| } |
| - /** @const */ var isActive = |
| - data.state != downloads.States.CANCELLED && |
| - data.state != downloads.States.INTERRUPTED && |
| - !data.file_externally_removed; |
| - this.$.content.classList.toggle('is-active', isActive); |
| - this.$.content.elevation = isActive ? 1 : 0; |
| - |
| - // Danger-dependent UI and controls. |
| + // TODO(dbeam): Move to a computeClass_() method + data binding. |
| + this.$.content.classList.toggle('is-active', this.isActive_); |
| this.$.content.classList.toggle('dangerous', this.isDangerous_); |
| + this.$.content.classList.toggle('show-progress', this.showProgress_); |
| - var description = this.getDangerText_(data) || this.getStatusText_(data); |
| + var desc = this.getDangerText_(data) || this.getStatusText_(data); |
| // Status goes in the "tag" (next to the file name) if there's no file. |
| - this.ensureTextIs_(this.$.description, isActive ? description : ''); |
| - this.ensureTextIs_(this.$.tag, isActive ? '' : description); |
| - |
| - this.$.content.classList.toggle('show-progress', this.showProgress_); |
| + this.ensureTextIs_(this.$.description, this.isActive_ ? desc : ''); |
| + this.ensureTextIs_(this.$.tag, this.isActive_ ? '' : desc); |
| if (!this.isDangerous_) { |
| - this.$['file-link'].href = data.url; |
| - this.ensureTextIs_(this.$['file-link'], data.file_name); |
| - |
| - this.$['file-link'].hidden = !this.completelyOnDisk_; |
| - this.$.name.hidden = this.completelyOnDisk_; |
| - |
| /** @const */ var controlledByExtension = data.by_ext_id && |
| data.by_ext_name; |
| this.$['controlled-by'].hidden = !controlledByExtension; |
| @@ -192,6 +186,18 @@ cr.define('downloads', function() { |
| }, |
| /** @private */ |
| + computeElevation_: function() { |
|
tommycli
2015/09/09 20:49:16
I still feel uneasy about this.
But I talked to m
Dan Beam
2015/09/09 21:00:15
Acknowledged.
|
| + return this.isActive_ ? 1 : 0; |
| + }, |
| + |
| + /** @private */ |
| + computeIsActive_: function() { |
| + return this.data_.state != downloads.States.CANCELLED && |
| + this.data_.state != downloads.States.INTERRUPTED && |
| + !this.data_.file_externally_removed; |
| + }, |
| + |
| + /** @private */ |
| computeIsInProgress_: function() { |
| return this.data_.state == downloads.States.IN_PROGRESS; |
| }, |