Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // Namespace | 5 // Namespace |
| 6 var importer = importer || {}; | 6 var importer = importer || {}; |
| 7 | 7 |
| 8 /** @enum {string} */ | 8 /** @enum {string} */ |
| 9 importer.ResponseId = { | 9 importer.ResponseId = { |
| 10 EXECUTABLE: 'executable', | 10 READY: 'ready', |
| 11 HIDDEN: 'hidden', | 11 HIDDEN: 'hidden', |
| 12 ACTIVE_IMPORT: 'active_import', | 12 IMPORTING: 'importing', |
| 13 INSUFFICIENT_SPACE: 'insufficient_space', | 13 INSUFFICIENT_SPACE: 'insufficient-space', |
| 14 NO_MEDIA: 'no_media', | 14 NO_MEDIA: 'no-media', |
| 15 SCANNING: 'scanning' | 15 SCANNING: 'scanning' |
| 16 }; | 16 }; |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * @typedef {{ | |
| 20 * id: !importer.ResponseId, | |
| 21 * label: string, | |
| 22 * visible: boolean, | |
| 23 * executable: boolean, | |
| 24 * coreIcon: string | |
| 25 * }} | |
| 26 */ | |
| 27 importer.CommandUpdate; | |
| 28 | |
| 29 /** | |
| 30 * Class that orchestrates background activity and UI changes on | 19 * Class that orchestrates background activity and UI changes on |
| 31 * behalf of Cloud Import. | 20 * behalf of Cloud Import. |
| 32 * | 21 * |
| 33 * @constructor | 22 * @constructor |
| 34 * @struct | 23 * @struct |
| 35 * | 24 * |
| 36 * @param {!importer.ControllerEnvironment} environment The class providing | 25 * @param {!importer.ControllerEnvironment} environment The class providing |
| 37 * access to runtime environmental information, like the current directory, | 26 * access to runtime environmental information, like the current directory, |
| 38 * volume lookup and so-on. | 27 * volume lookup and so-on. |
| 39 * @param {!importer.MediaScanner} scanner | 28 * @param {!importer.MediaScanner} scanner |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 this.onVolumeUnmounted_.bind(this)); | 66 this.onVolumeUnmounted_.bind(this)); |
| 78 | 67 |
| 79 this.environment_.addDirectoryChangedListener( | 68 this.environment_.addDirectoryChangedListener( |
| 80 this.onDirectoryChanged_.bind(this)); | 69 this.onDirectoryChanged_.bind(this)); |
| 81 | 70 |
| 82 this.environment_.addSelectionChangedListener( | 71 this.environment_.addSelectionChangedListener( |
| 83 this.onSelectionChanged_.bind(this)); | 72 this.onSelectionChanged_.bind(this)); |
| 84 | 73 |
| 85 this.commandWidget_.addImportClickedListener( | 74 this.commandWidget_.addImportClickedListener( |
| 86 this.execute.bind(this)); | 75 this.execute.bind(this)); |
| 76 | |
| 77 this.commandWidget_.addDestinationClickedListener( | |
| 78 this.showDestination.bind(this)); | |
| 87 }; | 79 }; |
| 88 | 80 |
| 89 /** | 81 /** |
| 90 * @param {!importer.ScanEvent} event Command event. | 82 * @param {!importer.ScanEvent} event Command event. |
| 91 * @param {importer.ScanResult} scan | 83 * @param {importer.ScanResult} scan |
| 92 * | 84 * |
| 93 * @private | 85 * @private |
| 94 */ | 86 */ |
| 95 importer.ImportController.prototype.onScanEvent_ = function(event, scan) { | 87 importer.ImportController.prototype.onScanEvent_ = function(event, scan) { |
| 96 if (!this.scanManager_.isActiveScan(scan)) { | 88 if (!this.scanManager_.isActiveScan(scan)) { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 scan, | 164 scan, |
| 173 importer.Destination.GOOGLE_DRIVE); | 165 importer.Destination.GOOGLE_DRIVE); |
| 174 | 166 |
| 175 this.activeImportTask_ = importTask; | 167 this.activeImportTask_ = importTask; |
| 176 var taskFinished = this.onImportFinished_.bind(this, importTask); | 168 var taskFinished = this.onImportFinished_.bind(this, importTask); |
| 177 importTask.whenFinished.then(taskFinished).catch(taskFinished); | 169 importTask.whenFinished.then(taskFinished).catch(taskFinished); |
| 178 this.checkState_(); | 170 this.checkState_(); |
| 179 }; | 171 }; |
| 180 | 172 |
| 181 /** | 173 /** |
| 174 * Shows the import destination folder. | |
| 175 */ | |
| 176 importer.ImportController.prototype.showDestination = function() { | |
| 177 console.log('SET THE CURRENT DIRECTORY TO THE DESTINATION'); | |
| 178 // this.environment_.setCurrentDirectory(); | |
| 179 }; | |
| 180 | |
| 181 /** | |
| 182 * Checks the environment and updates UI as needed. | 182 * Checks the environment and updates UI as needed. |
| 183 * @param {importer.ScanResult=} opt_scan If supplied, | 183 * @param {importer.ScanResult=} opt_scan If supplied, |
| 184 * @private | 184 * @private |
| 185 */ | 185 */ |
| 186 importer.ImportController.prototype.checkState_ = function(opt_scan) { | 186 importer.ImportController.prototype.checkState_ = function(opt_scan) { |
| 187 // If there is no Google Drive mount, Drive may be disabled | 187 // If there is no Google Drive mount, Drive may be disabled |
| 188 // or the machine may be running in guest mode. | 188 // or the machine may be running in guest mode. |
| 189 if (!this.environment_.isGoogleDriveMounted()) { | 189 if (!this.environment_.isGoogleDriveMounted()) { |
| 190 this.updateUi_(importer.ResponseId.HIDDEN); | 190 this.updateUi_(importer.ResponseId.HIDDEN); |
| 191 return; | 191 return; |
| 192 } | 192 } |
| 193 | 193 |
| 194 if (!!this.activeImportTask_) { | 194 if (!!this.activeImportTask_) { |
| 195 this.updateUi_(importer.ResponseId.ACTIVE_IMPORT); | 195 this.updateUi_(importer.ResponseId.IMPORTING); |
| 196 return; | 196 return; |
| 197 } | 197 } |
| 198 | 198 |
| 199 // If we don't have an existing scan, we'll try to create | 199 // If we don't have an existing scan, we'll try to create |
| 200 // one. When we do end up creating one (not getting | 200 // one. When we do end up creating one (not getting |
| 201 // one from the cache) it'll be empty...even if there is | 201 // one from the cache) it'll be empty...even if there is |
| 202 // a current selection. This is because scans are | 202 // a current selection. This is because scans are |
| 203 // resolved asynchronously. And we like it that way. | 203 // resolved asynchronously. And we like it that way. |
| 204 // We'll get notification when the scan is updated. When | 204 // We'll get notification when the scan is updated. When |
| 205 // that happens, we'll be called back with opt_scan | 205 // that happens, we'll be called back with opt_scan |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 236 /** @param {boolean} fits */ | 236 /** @param {boolean} fits */ |
| 237 function(fits) { | 237 function(fits) { |
| 238 if (!fits) { | 238 if (!fits) { |
| 239 this.updateUi_( | 239 this.updateUi_( |
| 240 importer.ResponseId.INSUFFICIENT_SPACE, | 240 importer.ResponseId.INSUFFICIENT_SPACE, |
| 241 opt_scan); | 241 opt_scan); |
| 242 return; | 242 return; |
| 243 } | 243 } |
| 244 | 244 |
| 245 this.updateUi_( | 245 this.updateUi_( |
| 246 importer.ResponseId.EXECUTABLE, | 246 importer.ResponseId.READY, // to import... |
| 247 opt_scan); | 247 opt_scan); |
| 248 }.bind(this)); | 248 }.bind(this)); |
| 249 }; | 249 }; |
| 250 | 250 |
| 251 /** | 251 /** |
| 252 * @param {importer.ResponseId} responseId | 252 * @param {importer.ResponseId} responseId |
| 253 * @param {importer.ScanResult=} opt_scan | 253 * @param {importer.ScanResult=} opt_scan |
| 254 * | |
| 255 * @return {!importer.CommandUpdate} | |
| 256 * @private | 254 * @private |
| 257 */ | 255 */ |
| 258 importer.ImportController.prototype.updateUi_ = | 256 importer.ImportController.prototype.updateUi_ = |
| 259 function(responseId, opt_scan) { | 257 function(responseId, opt_scan) { |
| 260 switch(responseId) { | 258 this.commandWidget_.update(responseId, opt_scan); |
| 261 case importer.ResponseId.EXECUTABLE: | |
| 262 this.commandWidget_.update({ | |
| 263 id: responseId, | |
| 264 label: strf( | |
| 265 'CLOUD_IMPORT_BUTTON_LABEL', | |
| 266 opt_scan.getFileEntries().length), | |
| 267 visible: true, | |
| 268 executable: true, | |
| 269 coreIcon: 'cloud-upload' | |
| 270 }); | |
| 271 this.commandWidget_.updateDetails(opt_scan); | |
| 272 break; | |
| 273 case importer.ResponseId.HIDDEN: | |
| 274 this.commandWidget_.update({ | |
| 275 id: responseId, | |
| 276 visible: false, | |
| 277 executable: false, | |
| 278 label: '** SHOULD NOT BE VISIBLE **', | |
| 279 coreIcon: 'cloud-off' | |
| 280 }); | |
| 281 this.commandWidget_.setDetailsVisible(false); | |
| 282 break; | |
| 283 case importer.ResponseId.ACTIVE_IMPORT: | |
| 284 this.commandWidget_.update({ | |
| 285 id: responseId, | |
| 286 visible: true, | |
| 287 executable: false, | |
| 288 label: str('CLOUD_IMPORT_ACTIVE_IMPORT_BUTTON_LABEL'), | |
| 289 coreIcon: 'swap-vert' | |
| 290 }); | |
| 291 this.commandWidget_.setDetailsVisible(false); | |
| 292 break; | |
| 293 case importer.ResponseId.INSUFFICIENT_SPACE: | |
| 294 this.commandWidget_.update({ | |
| 295 id: responseId, | |
| 296 visible: true, | |
| 297 executable: false, | |
| 298 label: strf( | |
| 299 'CLOUD_IMPORT_INSUFFICIENT_SPACE_BUTTON_LABEL', | |
| 300 util.bytesToString(opt_scan.getTotalBytes())), | |
| 301 coreIcon: 'report-problem' | |
| 302 }); | |
| 303 this.commandWidget_.updateDetails(opt_scan); | |
| 304 break; | |
| 305 case importer.ResponseId.NO_MEDIA: | |
| 306 this.commandWidget_.update({ | |
| 307 id: responseId, | |
| 308 visible: true, | |
| 309 executable: false, | |
| 310 label: str('CLOUD_IMPORT_EMPTY_SCAN_BUTTON_LABEL'), | |
| 311 coreIcon: 'cloud-done' | |
| 312 }); | |
| 313 this.commandWidget_.updateDetails( | |
| 314 /** @type {!importer.ScanResult} */ (opt_scan)); | |
| 315 break; | |
| 316 case importer.ResponseId.SCANNING: | |
| 317 this.commandWidget_.update({ | |
| 318 id: responseId, | |
| 319 visible: true, | |
| 320 executable: false, | |
| 321 label: str('CLOUD_IMPORT_SCANNING_BUTTON_LABEL'), | |
| 322 coreIcon: 'autorenew' | |
| 323 }); | |
| 324 this.commandWidget_.updateDetails( | |
| 325 /** @type {!importer.ScanResult} */ (opt_scan)); | |
| 326 break; | |
| 327 default: | |
| 328 assertNotReached('Unrecognized response id: ' + responseId); | |
| 329 } | |
| 330 }; | 259 }; |
| 331 | 260 |
| 332 /** | 261 /** |
| 333 * @return {boolean} true if the current directory is scan eligible. | 262 * @return {boolean} true if the current directory is scan eligible. |
| 334 * @private | 263 * @private |
| 335 */ | 264 */ |
| 336 importer.ImportController.prototype.isCurrentDirectoryScannable_ = | 265 importer.ImportController.prototype.isCurrentDirectoryScannable_ = |
| 337 function() { | 266 function() { |
| 338 var directory = this.environment_.getCurrentDirectory(); | 267 var directory = this.environment_.getCurrentDirectory(); |
| 339 return !!directory && | 268 return !!directory && |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 559 importer.CommandWidget = function() {}; | 488 importer.CommandWidget = function() {}; |
| 560 | 489 |
| 561 /** | 490 /** |
| 562 * Install a listener that get's called when the user wants to initiate | 491 * Install a listener that get's called when the user wants to initiate |
| 563 * import. | 492 * import. |
| 564 * | 493 * |
| 565 * @param {function()} listener | 494 * @param {function()} listener |
| 566 */ | 495 */ |
| 567 importer.CommandWidget.prototype.addImportClickedListener; | 496 importer.CommandWidget.prototype.addImportClickedListener; |
| 568 | 497 |
| 569 /** @param {!importer.CommandUpdate} update */ | 498 /** |
| 499 * Install a listener that get's called when the user wants to initiate | |
| 500 * import. | |
| 501 * | |
| 502 * @param {function()} listener | |
| 503 */ | |
| 504 importer.CommandWidget.prototype.addDestinationClickedListener; | |
| 505 | |
| 506 /** | |
| 507 * @param {importer.ResponseId} responseId | |
| 508 * @param {importer.ScanResult=} opt_scan | |
| 509 */ | |
| 570 importer.CommandWidget.prototype.update; | 510 importer.CommandWidget.prototype.update; |
| 571 | 511 |
| 572 /** @param {!importer.ScanResult} scan */ | |
| 573 importer.CommandWidget.prototype.updateDetails; | |
| 574 | |
| 575 /** Resets details to default. */ | 512 /** Resets details to default. */ |
| 576 importer.CommandWidget.prototype.resetDetails; | 513 importer.CommandWidget.prototype.resetDetails; |
| 577 | 514 |
| 578 /** | 515 /** |
| 579 * Runtime implementation of CommandWidget. | 516 * Runtime implementation of CommandWidget. |
| 580 * | 517 * |
| 581 * @constructor | 518 * @constructor |
| 582 * @implements {importer.CommandWidget} | 519 * @implements {importer.CommandWidget} |
| 583 * @struct | 520 * @struct |
| 584 */ | 521 */ |
| 585 importer.RuntimeCommandWidget = function() { | 522 importer.RuntimeCommandWidget = function() { |
| 586 | 523 |
| 587 /** @private {Element} */ | 524 /** @private {Element} */ |
| 588 this.importButton_ = document.getElementById('cloud-import-button'); | 525 this.importButton_ = document.getElementById('cloud-import-button'); |
| 589 this.importButton_.onclick = this.onImportClicked_.bind(this); | 526 this.importButton_.onclick = this.onImportClicked_.bind(this); |
| 590 | 527 |
| 591 /** @private {Element} */ | 528 /** @private {Element} */ |
| 592 this.detailsButton_ = document.getElementById('cloud-import-details-button'); | 529 this.detailsButton_ = document.getElementById('cloud-import-details-button'); |
| 593 this.detailsButton_.onclick = this.toggleDetails_.bind(this); | 530 this.detailsButton_.onclick = this.toggleDetails_.bind(this); |
| 594 | 531 |
| 595 /** @private {Element} */ | 532 /** @private {Element} */ |
| 596 this.detailsImportButton_ = | 533 this.detailsImportButton_ = |
| 597 document.querySelector('#cloud-import-details .import'); | 534 document.querySelector('#cloud-import-details paper-button.import'); |
| 598 this.detailsImportButton_.onclick = this.onImportClicked_.bind(this); | 535 this.detailsImportButton_.onclick = this.onImportClicked_.bind(this); |
| 599 | 536 |
| 600 /** @private {Element} */ | 537 /** @private {Element} */ |
| 601 this.detailsPanel_ = document.getElementById('cloud-import-details'); | 538 this.detailsPanel_ = document.getElementById('cloud-import-details'); |
| 602 | 539 |
| 603 /** @private {Element} */ | 540 /** @private {Element} */ |
| 604 this.photoCount_ = | 541 this.detailsPanelBody_ = |
| 605 document.querySelector('#cloud-import-details .photo-count'); | 542 document.querySelector('#cloud-import-details .main'); |
| 606 | 543 |
| 607 /** @private {Element} */ | 544 /** @private {Element} */ |
| 608 this.spaceRequired_ = | 545 this.statusContent_ = |
| 609 document.querySelector('#cloud-import-details .space-required'); | 546 document.querySelector('#cloud-import-details .status .content'); |
| 547 this.statusContent_.onclick = this.onStatusClicked_.bind(this); | |
| 610 | 548 |
| 611 /** @private {Element} */ | 549 /** @private {Element} */ |
| 612 this.icon_ = document.querySelector('#cloud-import-button core-icon'); | 550 this.toolbarIcon_ = |
| 551 document.querySelector('#cloud-import-button core-icon'); | |
| 552 this.statusIcon_ = | |
| 553 document.querySelector('#cloud-import-details .status core-icon'); | |
| 613 | 554 |
| 614 /** @private {function()} */ | 555 /** @private {function()} */ |
| 615 this.importListener_; | 556 this.importListener_; |
| 557 | |
| 558 /** @private {function()} */ | |
| 559 this.destinationListener_; | |
| 616 }; | 560 }; |
| 617 | 561 |
| 618 /** @override */ | 562 /** @override */ |
| 619 importer.RuntimeCommandWidget.prototype.addImportClickedListener = | 563 importer.RuntimeCommandWidget.prototype.addImportClickedListener = |
| 620 function(listener) { | 564 function(listener) { |
| 621 console.assert(!this.importListener_); | 565 console.assert(!this.importListener_); |
| 622 this.importListener_ = listener; | 566 this.importListener_ = listener; |
| 623 }; | 567 }; |
| 624 | 568 |
| 625 /** @private */ | 569 /** @override */ |
| 626 importer.RuntimeCommandWidget.prototype.onImportClicked_ = function() { | 570 importer.RuntimeCommandWidget.prototype.addDestinationClickedListener = |
| 571 function(listener) { | |
| 572 console.assert(!this.destinationListener_); | |
| 573 this.destinationListener_ = listener; | |
| 574 }; | |
| 575 | |
| 576 /** | |
| 577 * @param {Event} event Click event. | |
| 578 * @private | |
| 579 */ | |
| 580 importer.RuntimeCommandWidget.prototype.onImportClicked_ = function(event) { | |
| 627 console.assert(!!this.importListener_); | 581 console.assert(!!this.importListener_); |
| 628 this.importListener_(); | 582 this.importListener_(); |
| 629 }; | 583 }; |
| 630 | 584 |
| 585 /** | |
| 586 * @param {Event} event Click event. | |
| 587 * @private | |
| 588 */ | |
| 589 importer.RuntimeCommandWidget.prototype.onStatusClicked_ = function(event) { | |
| 590 console.assert(!!this.destinationListener_); | |
| 591 // TODO(smckay): Only if the element is "destination-link". | |
| 592 this.destinationListener_(); | |
| 593 }; | |
| 594 | |
| 631 /** @private */ | 595 /** @private */ |
| 632 importer.RuntimeCommandWidget.prototype.toggleDetails_ = function() { | 596 importer.RuntimeCommandWidget.prototype.toggleDetails_ = function() { |
| 633 this.setDetailsVisible(this.detailsPanel_.className === 'offscreen'); | 597 this.setDetailsVisible(this.detailsPanel_.className === 'hidden'); |
| 634 }; | 598 }; |
| 635 | 599 |
| 636 importer.RuntimeCommandWidget.prototype.setDetailsVisible = function(visible) { | 600 importer.RuntimeCommandWidget.prototype.setDetailsVisible = function(visible) { |
| 637 if (visible) { | 601 if (visible) { |
| 602 this.detailsPanel_.style.display = 'block'; | |
|
mtomasz
2015/02/12 03:22:01
nit: Can we use this.detailsPanel_.hidden = false/
Steve McKay
2015/02/12 23:15:54
Done.
| |
| 638 this.detailsPanel_.className = ''; | 603 this.detailsPanel_.className = ''; |
| 639 } else { | 604 } else { |
| 640 this.detailsPanel_.className = 'offscreen'; | 605 this.detailsPanel_.className = 'hidden'; |
| 606 | |
| 607 // When hiding outself, we want to wait for the visually | |
|
mtomasz
2015/02/12 03:22:01
We can listen to webkitTransitionEnd instead.
Steve McKay
2015/02/12 23:15:54
Oh, thank you for saving me from that. I felt so d
| |
| 608 // pleasing transition to finish before fully hiding | |
| 609 // the element. This is necessary because an invisible | |
| 610 // element is still on-screen (grapping mouse clicks) | |
| 611 // even if the user can't see it. And since CSS transitions | |
| 612 // don't cooperate with display: none...our hand was forced. | |
| 613 setTimeout( | |
| 614 /** @this {importer.RuntimeCommandWidget} */ | |
| 615 function() { | |
| 616 this.detailsPanel_.style.display = 'none'; | |
| 617 }.bind(this), | |
| 618 200); | |
| 641 } | 619 } |
| 642 }; | 620 }; |
| 643 | 621 |
| 644 /** @override */ | 622 /** @override */ |
| 645 importer.RuntimeCommandWidget.prototype.update = function(update) { | 623 importer.RuntimeCommandWidget.prototype.update = |
| 646 this.importButton_.setAttribute('title', update.label); | 624 function(responseId, opt_scan) { |
| 647 this.importButton_.disabled = !update.executable; | 625 switch(responseId) { |
| 648 this.importButton_.style.display = | 626 case importer.ResponseId.HIDDEN: |
| 649 update.visible ? 'block' : 'none'; | 627 this.importButton_.disabled = true; |
| 628 this.detailsButton_.disabled = true; | |
| 650 | 629 |
| 651 this.icon_.setAttribute('icon', update.coreIcon); | 630 this.importButton_.style.display = 'none'; |
|
mtomasz
2015/02/12 03:22:01
nit: hidden = true
here and in other places
Steve McKay
2015/02/12 23:15:54
Done.
| |
| 631 this.detailsButton_.style.display = 'none'; | |
| 652 | 632 |
| 653 this.detailsButton_.disabled = !update.executable; | 633 this.importButton_.setAttribute( |
| 654 this.detailsButton_.style.display = | 634 'title', |
| 655 update.visible ? 'block' : 'none'; | 635 '** SHOULD NOT BE VISIBLE **'); |
| 656 }; | 636 this.statusContent_.innerHTML = |
| 637 '** SHOULD NOT BE VISIBLE **'; | |
| 657 | 638 |
| 658 /** @override */ | 639 this.toolbarIcon_.setAttribute('icon', 'cloud-off'); |
| 659 importer.RuntimeCommandWidget.prototype.updateDetails = function(scan) { | 640 this.statusIcon_.setAttribute('icon', 'cloud-off'); |
| 660 this.photoCount_.textContent = scan.getFileEntries().length.toLocaleString(); | 641 |
| 661 this.spaceRequired_.textContent = util.bytesToString(scan.getTotalBytes()); | 642 break; |
| 643 | |
| 644 case importer.ResponseId.IMPORTING: | |
| 645 console.assert(!!opt_scan, 'Scan not defined, but is required.'); | |
| 646 | |
| 647 this.importButton_.setAttribute('title', strf( | |
| 648 'CLOUD_IMPORT_TOOLTIP_IMPORTING', | |
| 649 opt_scan.getFileEntries().length)); | |
| 650 this.statusContent_.innerHTML = strf( | |
| 651 'CLOUD_IMPORT_STATUS_IMPORTING', | |
| 652 opt_scan.getFileEntries().length); | |
| 653 | |
| 654 this.importButton_.disabled = true; | |
| 655 this.detailsButton_.disabled = true; | |
| 656 this.detailsImportButton_.disabled = true; | |
| 657 | |
| 658 this.importButton_.style.display = 'block'; | |
|
mtomasz
2015/02/12 03:22:01
nit: ditto here and in other places
Steve McKay
2015/02/12 23:15:54
Done.
| |
| 659 this.detailsButton_.style.display = 'block'; | |
| 660 this.detailsImportButton_.style.display = 'block'; | |
| 661 | |
| 662 this.toolbarIcon_.setAttribute('icon', 'autorenew'); | |
| 663 this.statusIcon_.setAttribute('icon', 'autorenew'); | |
| 664 | |
| 665 this.setDetailsVisible(false); | |
| 666 break; | |
| 667 | |
| 668 case importer.ResponseId.INSUFFICIENT_SPACE: | |
| 669 console.assert(!!opt_scan, 'Scan not defined, but is required.'); | |
| 670 | |
| 671 this.importButton_.setAttribute('title', strf( | |
| 672 'CLOUD_IMPORT_STATUS_INSUFFICIENT_SPACE')); | |
| 673 this.statusContent_.innerHTML = strf( | |
| 674 'CLOUD_IMPORT_STATUS_INSUFFICIENT_SPACE', | |
| 675 opt_scan.getFileEntries().length); | |
| 676 | |
| 677 this.importButton_.disabled = true; | |
| 678 this.detailsButton_.disabled = false; | |
| 679 this.detailsImportButton_.disabled = true; | |
| 680 | |
| 681 this.importButton_.style.display = 'block'; | |
| 682 this.detailsButton_.style.display = 'block'; | |
| 683 this.detailsImportButton_.style.display = 'block'; | |
| 684 | |
| 685 this.toolbarIcon_.setAttribute('icon', 'report-problem'); | |
| 686 this.statusIcon_.setAttribute('icon', 'report-problem'); | |
| 687 break; | |
| 688 | |
| 689 case importer.ResponseId.NO_MEDIA: | |
| 690 this.importButton_.setAttribute('title', str( | |
| 691 'CLOUD_IMPORT_STATUS_NO_MEDIA')); | |
| 692 this.statusContent_.innerHTML = str( | |
| 693 'CLOUD_IMPORT_STATUS_NO_MEDIA'); | |
| 694 | |
| 695 this.importButton_.disabled = false; | |
| 696 this.detailsButton_.disabled = false; | |
| 697 this.detailsImportButton_.disabled = true; | |
| 698 | |
| 699 this.importButton_.style.display = 'block'; | |
| 700 this.detailsButton_.style.display = 'block'; | |
| 701 // Hidden for now, since this is also the "done" importing case. | |
| 702 this.detailsImportButton_.style.display = 'none'; | |
| 703 | |
| 704 this.toolbarIcon_.setAttribute('icon', 'cloud-done'); | |
| 705 this.statusIcon_.setAttribute('icon', 'cloud-done'); | |
| 706 break; | |
| 707 | |
| 708 case importer.ResponseId.READY: | |
| 709 console.assert(!!opt_scan, 'Scan not defined, but is required.'); | |
| 710 | |
| 711 this.importButton_.setAttribute('title', strf( | |
| 712 'CLOUD_IMPORT_TOOLTIP_READY', | |
| 713 opt_scan.getFileEntries().length)); | |
| 714 this.statusContent_.innerHTML = strf( | |
| 715 'CLOUD_IMPORT_STATUS_READY', | |
| 716 opt_scan.getFileEntries().length); | |
| 717 | |
| 718 this.importButton_.disabled = false; | |
| 719 this.detailsButton_.disabled = false; | |
| 720 this.detailsImportButton_.disabled = false; | |
| 721 | |
| 722 this.importButton_.style.display = 'block'; | |
| 723 this.detailsButton_.style.display = 'block'; | |
| 724 this.detailsImportButton_.style.display = 'block'; | |
| 725 | |
| 726 this.toolbarIcon_.setAttribute('icon', 'cloud-upload'); | |
| 727 this.statusIcon_.setAttribute('icon', 'assignment'); | |
| 728 break; | |
| 729 | |
| 730 case importer.ResponseId.SCANNING: | |
| 731 console.assert(!!opt_scan, 'Scan not defined, but is required.'); | |
| 732 | |
| 733 this.importButton_.setAttribute('title', str( | |
| 734 'CLOUD_IMPORT_TOOLTIP_SCANNING')); | |
| 735 this.statusContent_.innerHTML = strf( | |
| 736 'CLOUD_IMPORT_STATUS_SCANNING', | |
| 737 opt_scan.getFileEntries().length); | |
| 738 | |
| 739 this.importButton_.disabled = true; | |
| 740 this.detailsButton_.disabled = true; | |
| 741 this.detailsImportButton_.disabled = true; | |
| 742 | |
| 743 this.importButton_.style.display = 'block'; | |
| 744 this.detailsButton_.style.display = 'block'; | |
| 745 this.detailsImportButton_.style.display = 'none'; | |
| 746 | |
| 747 this.toolbarIcon_.setAttribute('icon', 'autorenew'); | |
| 748 this.statusIcon_.setAttribute('icon', 'autorenew'); | |
| 749 break; | |
| 750 | |
| 751 default: | |
| 752 assertNotReached('Unrecognized response id: ' + responseId); | |
| 753 } | |
| 662 }; | 754 }; |
| 663 | 755 |
| 664 /** @override */ | 756 /** @override */ |
| 665 importer.RuntimeCommandWidget.prototype.resetDetails = function() { | 757 importer.RuntimeCommandWidget.prototype.resetDetails = function() { |
| 666 this.photoCount_.textContent = 0; | 758 // this.photoCount_.textContent = 0; |
|
mtomasz
2015/02/12 03:22:01
nit: Is this commented out on purpose?
Steve McKay
2015/02/12 23:15:54
Not needed anymore. Gone.
| |
| 667 this.spaceRequired_.textContent = 0; | 759 // this.spaceRequired_.textContent = 0; |
| 668 }; | 760 }; |
| 669 | 761 |
| 670 /** | 762 /** |
| 671 * A cache for ScanResults. | 763 * A cache for ScanResults. |
| 672 * | 764 * |
| 673 * @constructor | 765 * @constructor |
| 674 * @struct | 766 * @struct |
| 675 * | 767 * |
| 676 * @param {!importer.ControllerEnvironment} environment | 768 * @param {!importer.ControllerEnvironment} environment |
| 677 * @param {!importer.MediaScanner} scanner | 769 * @param {!importer.MediaScanner} scanner |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 766 var directory = this.environment_.getCurrentDirectory(); | 858 var directory = this.environment_.getCurrentDirectory(); |
| 767 var url = directory.toURL(); | 859 var url = directory.toURL(); |
| 768 var scan = this.directoryScans_[url]; | 860 var scan = this.directoryScans_[url]; |
| 769 if (!scan) { | 861 if (!scan) { |
| 770 scan = this.scanner_.scan([directory]); | 862 scan = this.scanner_.scan([directory]); |
| 771 this.directoryScans_[url] = scan; | 863 this.directoryScans_[url] = scan; |
| 772 } | 864 } |
| 773 | 865 |
| 774 return scan; | 866 return scan; |
| 775 }; | 867 }; |
| OLD | NEW |