| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 /** | 5 /** |
| 6 * Controller of metadata box. | 6 * Controller of metadata box. |
| 7 * This should be initialized with |init| method. |
| 7 * | 8 * |
| 8 * @param{!MetadataModel} metadataModel | 9 * @param{!MetadataModel} metadataModel |
| 9 * @param{!FilesMetadataBox} metadataBox | |
| 10 * @param{!FilesQuickView} quickView | |
| 11 * @param{!QuickViewModel} quickViewModel | 10 * @param{!QuickViewModel} quickViewModel |
| 12 * @param{!FileMetadataFormatter} fileMetadataFormatter | 11 * @param{!FileMetadataFormatter} fileMetadataFormatter |
| 13 * | 12 * |
| 14 * @constructor | 13 * @constructor |
| 15 */ | 14 */ |
| 16 function MetadataBoxController( | 15 function MetadataBoxController( |
| 17 metadataModel, metadataBox, quickView, quickViewModel, | 16 metadataModel, quickViewModel, fileMetadataFormatter) { |
| 18 fileMetadataFormatter) { | |
| 19 /** | 17 /** |
| 20 * @type {!MetadataModel} | 18 * @type {!MetadataModel} |
| 21 * @private | 19 * @private |
| 22 */ | 20 */ |
| 23 this.metadataModel_ = metadataModel; | 21 this.metadataModel_ = metadataModel; |
| 24 | 22 |
| 25 /** | 23 /** |
| 26 * @type {!FilesMetadataBox} | 24 * @type {!QuickViewModel} |
| 27 * @private | 25 * @private |
| 28 */ | 26 */ |
| 29 this.metadataBox_ = metadataBox; | 27 this.quickViewModel_ = quickViewModel; |
| 28 |
| 29 /** |
| 30 * @type {FilesMetadataBox} metadataBox |
| 31 * @private |
| 32 */ |
| 33 this.metadataBox_ = null; |
| 30 | 34 |
| 31 /** | 35 /** |
| 32 * @type {!FilesQuickView} | 36 * @type {FilesQuickView} quickView |
| 33 * @private | 37 * @private |
| 34 */ | 38 */ |
| 35 this.quickView_ = quickView; | 39 this.quickView_ = null; |
| 36 | 40 |
| 37 /** | 41 /** |
| 38 * @type {!FileMetadataFormatter} | 42 * @type {!FileMetadataFormatter} |
| 39 * @private | 43 * @private |
| 40 */ | 44 */ |
| 41 this.fileMetadataFormatter_ = fileMetadataFormatter; | 45 this.fileMetadataFormatter_ = fileMetadataFormatter; |
| 46 } |
| 42 | 47 |
| 48 /** |
| 49 * Initialize the controller with quick view which will be lazily loaded. |
| 50 * @param{!FilesQuickView} quickView |
| 51 */ |
| 52 MetadataBoxController.prototype.init = function(quickView) { |
| 43 // TODO(oka): Add storage to persist the value of | 53 // TODO(oka): Add storage to persist the value of |
| 44 // quickViewModel_.metadataBoxActive. | 54 // quickViewModel_.metadataBoxActive. |
| 45 /** | 55 this.fileMetadataFormatter_.addEventListener( |
| 46 * @type {!QuickViewModel} | |
| 47 * @private | |
| 48 */ | |
| 49 this.quickViewModel_ = quickViewModel; | |
| 50 | |
| 51 fileMetadataFormatter.addEventListener( | |
| 52 'date-time-format-changed', this.updateView_.bind(this)); | 56 'date-time-format-changed', this.updateView_.bind(this)); |
| 53 | 57 |
| 54 quickView.addEventListener( | 58 quickView.addEventListener( |
| 55 'metadata-box-active-changed', this.updateView_.bind(this)); | 59 'metadata-box-active-changed', this.updateView_.bind(this)); |
| 56 | 60 |
| 57 quickViewModel.addEventListener( | 61 this.quickViewModel_.addEventListener( |
| 58 'selected-entry-changed', this.updateView_.bind(this)); | 62 'selected-entry-changed', this.updateView_.bind(this)); |
| 59 } | 63 |
| 64 this.metadataBox_ = quickView.getFilesMetadataBox(); |
| 65 this.quickView_ = quickView; |
| 66 }; |
| 60 | 67 |
| 61 /** | 68 /** |
| 62 * @const {!Array<string>} | 69 * @const {!Array<string>} |
| 63 */ | 70 */ |
| 64 MetadataBoxController.GENERAL_METADATA_NAME = [ | 71 MetadataBoxController.GENERAL_METADATA_NAME = [ |
| 65 'size', | 72 'size', |
| 66 'modificationTime', | 73 'modificationTime', |
| 67 ]; | 74 ]; |
| 68 | 75 |
| 69 /** | 76 /** |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 if(chrome.runtime.lastError) { | 193 if(chrome.runtime.lastError) { |
| 187 this.metadataBox_.isSizeLoading = false; | 194 this.metadataBox_.isSizeLoading = false; |
| 188 return; | 195 return; |
| 189 } | 196 } |
| 190 | 197 |
| 191 this.metadataBox_.isSizeLoading = false; | 198 this.metadataBox_.isSizeLoading = false; |
| 192 this.metadataBox_.size = | 199 this.metadataBox_.size = |
| 193 this.fileMetadataFormatter_.formatSize(size, true); | 200 this.fileMetadataFormatter_.formatSize(size, true); |
| 194 }.bind(this)); | 201 }.bind(this)); |
| 195 }; | 202 }; |
| OLD | NEW |