| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 noDownloadsText_: function() { | 100 noDownloadsText_: function() { |
| 99 return loadTimeData.getString( | 101 return loadTimeData.getString( |
| 100 this.inSearchMode_ ? 'noSearchResults' : 'noDownloads'); | 102 this.inSearchMode_ ? 'noSearchResults' : 'noDownloads'); |
| 101 }, | 103 }, |
| 102 | 104 |
| 103 /** | 105 /** |
| 104 * @param {Event} e | 106 * @param {Event} e |
| 105 * @private | 107 * @private |
| 106 */ | 108 */ |
| 107 onCanExecute_: function(e) { | 109 onCanExecute_: function(e) { |
| 108 e = /** @type {cr.ui.CanExecuteEvent} */(e); | 110 e = /** @type {cr.ui.CanExecuteEvent} */ (e); |
| 109 switch (e.command.id) { | 111 switch (e.command.id) { |
| 110 case 'undo-command': | 112 case 'undo-command': |
| 111 e.canExecute = this.$.toolbar.canUndo(); | 113 e.canExecute = this.$.toolbar.canUndo(); |
| 112 break; | 114 break; |
| 113 case 'clear-all-command': | 115 case 'clear-all-command': |
| 114 e.canExecute = this.$.toolbar.canClearAll(); | 116 e.canExecute = this.$.toolbar.canClearAll(); |
| 115 break; | 117 break; |
| 116 case 'find-command': | 118 case 'find-command': |
| 117 e.canExecute = true; | 119 e.canExecute = true; |
| 118 break; | 120 break; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 }, | 189 }, |
| 188 | 190 |
| 189 /** | 191 /** |
| 190 * @param {number} index | 192 * @param {number} index |
| 191 * @param {!downloads.Data} data | 193 * @param {!downloads.Data} data |
| 192 * @private | 194 * @private |
| 193 */ | 195 */ |
| 194 updateItem_: function(index, data) { | 196 updateItem_: function(index, data) { |
| 195 this.set('items_.' + index, data); | 197 this.set('items_.' + index, data); |
| 196 this.updateHideDates_(index, index); | 198 this.updateHideDates_(index, index); |
| 197 var list = /** @type {!IronListElement} */(this.$['downloads-list']); | 199 var list = /** @type {!IronListElement} */ (this.$['downloads-list']); |
| 198 list.updateSizeForItem(index); | 200 list.updateSizeForItem(index); |
| 199 }, | 201 }, |
| 200 }); | 202 }); |
| 201 | 203 |
| 202 Manager.clearAll = function() { | 204 Manager.clearAll = function() { |
| 203 Manager.get().clearAll_(); | 205 Manager.get().clearAll_(); |
| 204 }; | 206 }; |
| 205 | 207 |
| 206 /** @return {!downloads.Manager} */ | 208 /** @return {!downloads.Manager} */ |
| 207 Manager.get = function() { | 209 Manager.get = function() { |
| 208 return /** @type {!downloads.Manager} */( | 210 return /** @type {!downloads.Manager} */ ( |
| 209 queryRequiredElement('downloads-manager')); | 211 queryRequiredElement('downloads-manager')); |
| 210 }; | 212 }; |
| 211 | 213 |
| 212 Manager.insertItems = function(index, list) { | 214 Manager.insertItems = function(index, list) { |
| 213 Manager.get().insertItems_(index, list); | 215 Manager.get().insertItems_(index, list); |
| 214 }; | 216 }; |
| 215 | 217 |
| 216 /** @return {!Promise} */ | 218 /** @return {!Promise} */ |
| 217 Manager.onLoad = function() { | 219 Manager.onLoad = function() { |
| 218 return Manager.get().onLoad_(); | 220 return Manager.get().onLoad_(); |
| 219 }; | 221 }; |
| 220 | 222 |
| 221 Manager.removeItem = function(index) { | 223 Manager.removeItem = function(index) { |
| 222 Manager.get().removeItem_(index); | 224 Manager.get().removeItem_(index); |
| 223 }; | 225 }; |
| 224 | 226 |
| 225 Manager.updateItem = function(index, data) { | 227 Manager.updateItem = function(index, data) { |
| 226 Manager.get().updateItem_(index, data); | 228 Manager.get().updateItem_(index, data); |
| 227 }; | 229 }; |
| 228 | 230 |
| 229 return {Manager: Manager}; | 231 return {Manager: Manager}; |
| 230 }); | 232 }); |
| OLD | NEW |