| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 cr.define('downloads', function() { | 5 cr.define('downloads', function() { |
| 6 var Manager = Polymer({ | 6 var Manager = Polymer({ |
| 7 is: 'downloads-manager', | 7 is: 'downloads-manager', |
| 8 | 8 |
| 9 properties: { | 9 properties: { |
| 10 /** @private */ | 10 /** @private */ |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 /** @private */ | 23 /** @private */ |
| 24 inSearchMode_: { | 24 inSearchMode_: { |
| 25 type: Boolean, | 25 type: Boolean, |
| 26 value: false, | 26 value: false, |
| 27 }, | 27 }, |
| 28 | 28 |
| 29 /** @private {!Array<!downloads.Data>} */ | 29 /** @private {!Array<!downloads.Data>} */ |
| 30 items_: { | 30 items_: { |
| 31 type: Array, | 31 type: Array, |
| 32 value: function() { return []; }, | 32 value: function() { |
| 33 return []; |
| 34 }, |
| 33 }, | 35 }, |
| 34 | 36 |
| 35 /** @private */ | 37 /** @private */ |
| 36 spinnerActive_: { | 38 spinnerActive_: { |
| 37 type: Boolean, | 39 type: Boolean, |
| 38 notify: true, | 40 notify: true, |
| 39 }, | 41 }, |
| 40 }, | 42 }, |
| 41 | 43 |
| 42 hostAttributes: { | 44 hostAttributes: { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 noDownloadsText_: function() { | 115 noDownloadsText_: function() { |
| 114 return loadTimeData.getString( | 116 return loadTimeData.getString( |
| 115 this.inSearchMode_ ? 'noSearchResults' : 'noDownloads'); | 117 this.inSearchMode_ ? 'noSearchResults' : 'noDownloads'); |
| 116 }, | 118 }, |
| 117 | 119 |
| 118 /** | 120 /** |
| 119 * @param {Event} e | 121 * @param {Event} e |
| 120 * @private | 122 * @private |
| 121 */ | 123 */ |
| 122 onCanExecute_: function(e) { | 124 onCanExecute_: function(e) { |
| 123 e = /** @type {cr.ui.CanExecuteEvent} */(e); | 125 e = /** @type {cr.ui.CanExecuteEvent} */ (e); |
| 124 switch (e.command.id) { | 126 switch (e.command.id) { |
| 125 case 'undo-command': | 127 case 'undo-command': |
| 126 e.canExecute = this.$.toolbar.canUndo(); | 128 e.canExecute = this.$.toolbar.canUndo(); |
| 127 break; | 129 break; |
| 128 case 'clear-all-command': | 130 case 'clear-all-command': |
| 129 e.canExecute = this.$.toolbar.canClearAll(); | 131 e.canExecute = this.$.toolbar.canClearAll(); |
| 130 break; | 132 break; |
| 131 case 'find-command': | 133 case 'find-command': |
| 132 e.canExecute = true; | 134 e.canExecute = true; |
| 133 break; | 135 break; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 }, | 204 }, |
| 203 | 205 |
| 204 /** | 206 /** |
| 205 * @param {number} index | 207 * @param {number} index |
| 206 * @param {!downloads.Data} data | 208 * @param {!downloads.Data} data |
| 207 * @private | 209 * @private |
| 208 */ | 210 */ |
| 209 updateItem_: function(index, data) { | 211 updateItem_: function(index, data) { |
| 210 this.set('items_.' + index, data); | 212 this.set('items_.' + index, data); |
| 211 this.updateHideDates_(index, index); | 213 this.updateHideDates_(index, index); |
| 212 var list = /** @type {!IronListElement} */(this.$['downloads-list']); | 214 var list = /** @type {!IronListElement} */ (this.$['downloads-list']); |
| 213 list.updateSizeForItem(index); | 215 list.updateSizeForItem(index); |
| 214 }, | 216 }, |
| 215 }); | 217 }); |
| 216 | 218 |
| 217 Manager.clearAll = function() { | 219 Manager.clearAll = function() { |
| 218 Manager.get().clearAll_(); | 220 Manager.get().clearAll_(); |
| 219 }; | 221 }; |
| 220 | 222 |
| 221 /** @return {!downloads.Manager} */ | 223 /** @return {!downloads.Manager} */ |
| 222 Manager.get = function() { | 224 Manager.get = function() { |
| 223 return /** @type {!downloads.Manager} */( | 225 return /** @type {!downloads.Manager} */ ( |
| 224 queryRequiredElement('downloads-manager')); | 226 queryRequiredElement('downloads-manager')); |
| 225 }; | 227 }; |
| 226 | 228 |
| 227 Manager.insertItems = function(index, list) { | 229 Manager.insertItems = function(index, list) { |
| 228 Manager.get().insertItems_(index, list); | 230 Manager.get().insertItems_(index, list); |
| 229 }; | 231 }; |
| 230 | 232 |
| 231 /** @return {!Promise} */ | 233 /** @return {!Promise} */ |
| 232 Manager.onLoad = function() { | 234 Manager.onLoad = function() { |
| 233 return Manager.get().onLoad_(); | 235 return Manager.get().onLoad_(); |
| 234 }; | 236 }; |
| 235 | 237 |
| 236 Manager.removeItem = function(index) { | 238 Manager.removeItem = function(index) { |
| 237 Manager.get().removeItem_(index); | 239 Manager.get().removeItem_(index); |
| 238 }; | 240 }; |
| 239 | 241 |
| 240 Manager.updateItem = function(index, data) { | 242 Manager.updateItem = function(index, data) { |
| 241 Manager.get().updateItem_(index, data); | 243 Manager.get().updateItem_(index, data); |
| 242 }; | 244 }; |
| 243 | 245 |
| 244 return {Manager: Manager}; | 246 return {Manager: Manager}; |
| 245 }); | 247 }); |
| OLD | NEW |