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(); | |
Ben Kwa
2015/02/12 23:31:15
Remove this?
Steve McKay
2015/02/12 23:39:36
Done.
| |
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'); |
539 this.detailsPanel_.addEventListener( | |
540 'transitionend', | |
541 this.onDetailsTransitionEnd_.bind(this), | |
542 false); | |
602 | 543 |
603 /** @private {Element} */ | 544 /** @private {Element} */ |
604 this.photoCount_ = | 545 this.detailsPanelBody_ = |
605 document.querySelector('#cloud-import-details .photo-count'); | 546 document.querySelector('#cloud-import-details .main'); |
606 | 547 |
607 /** @private {Element} */ | 548 /** @private {Element} */ |
608 this.spaceRequired_ = | 549 this.statusContent_ = |
609 document.querySelector('#cloud-import-details .space-required'); | 550 document.querySelector('#cloud-import-details .status .content'); |
551 this.statusContent_.onclick = this.onStatusClicked_.bind(this); | |
610 | 552 |
611 /** @private {Element} */ | 553 /** @private {Element} */ |
612 this.icon_ = document.querySelector('#cloud-import-button core-icon'); | 554 this.toolbarIcon_ = |
555 document.querySelector('#cloud-import-button core-icon'); | |
556 this.statusIcon_ = | |
557 document.querySelector('#cloud-import-details .status core-icon'); | |
613 | 558 |
614 /** @private {function()} */ | 559 /** @private {function()} */ |
615 this.importListener_; | 560 this.importListener_; |
561 | |
562 /** @private {function()} */ | |
563 this.destinationListener_; | |
616 }; | 564 }; |
617 | 565 |
618 /** @override */ | 566 /** @override */ |
619 importer.RuntimeCommandWidget.prototype.addImportClickedListener = | 567 importer.RuntimeCommandWidget.prototype.addImportClickedListener = |
620 function(listener) { | 568 function(listener) { |
621 console.assert(!this.importListener_); | 569 console.assert(!this.importListener_); |
622 this.importListener_ = listener; | 570 this.importListener_ = listener; |
623 }; | 571 }; |
624 | 572 |
625 /** @private */ | 573 /** @override */ |
626 importer.RuntimeCommandWidget.prototype.onImportClicked_ = function() { | 574 importer.RuntimeCommandWidget.prototype.addDestinationClickedListener = |
575 function(listener) { | |
576 console.assert(!this.destinationListener_); | |
577 this.destinationListener_ = listener; | |
578 }; | |
579 | |
580 /** | |
581 * @param {Event} event Click event. | |
582 * @private | |
583 */ | |
584 importer.RuntimeCommandWidget.prototype.onImportClicked_ = function(event) { | |
627 console.assert(!!this.importListener_); | 585 console.assert(!!this.importListener_); |
628 this.importListener_(); | 586 this.importListener_(); |
629 }; | 587 }; |
630 | 588 |
589 /** | |
590 * @param {Event} event Click event. | |
591 * @private | |
592 */ | |
593 importer.RuntimeCommandWidget.prototype.onStatusClicked_ = function(event) { | |
594 console.assert(!!this.destinationListener_); | |
Ben Kwa
2015/02/12 23:31:15
nit: add an assert message
Steve McKay
2015/02/12 23:39:36
Done.
| |
595 // TODO(smckay): Only if the element is "destination-link". | |
596 this.destinationListener_(); | |
597 }; | |
598 | |
631 /** @private */ | 599 /** @private */ |
632 importer.RuntimeCommandWidget.prototype.toggleDetails_ = function() { | 600 importer.RuntimeCommandWidget.prototype.toggleDetails_ = function() { |
633 this.setDetailsVisible(this.detailsPanel_.className === 'offscreen'); | 601 this.setDetailsVisible(this.detailsPanel_.className === 'hidden'); |
634 }; | 602 }; |
635 | 603 |
636 importer.RuntimeCommandWidget.prototype.setDetailsVisible = function(visible) { | 604 importer.RuntimeCommandWidget.prototype.setDetailsVisible = function(visible) { |
637 if (visible) { | 605 if (visible) { |
606 this.detailsPanel_.hidden = false; | |
638 this.detailsPanel_.className = ''; | 607 this.detailsPanel_.className = ''; |
639 } else { | 608 } else { |
640 this.detailsPanel_.className = 'offscreen'; | 609 this.detailsPanel_.className = 'hidden'; |
610 } | |
611 }; | |
612 | |
613 /** @private */ | |
614 importer.RuntimeCommandWidget.prototype.onDetailsTransitionEnd_ = | |
615 function() { | |
616 if (this.detailsPanel_.className === 'hidden') { | |
617 // if we simply make the panel invisible (via opacity) | |
618 // it'll still be sitting there grabing mouse events | |
619 // and so-on. So we *hide* hide it. | |
620 this.detailsPanel_.hidden = true; | |
641 } | 621 } |
642 }; | 622 }; |
643 | 623 |
644 /** @override */ | 624 /** @override */ |
645 importer.RuntimeCommandWidget.prototype.update = function(update) { | 625 importer.RuntimeCommandWidget.prototype.update = |
646 this.importButton_.setAttribute('title', update.label); | 626 function(responseId, opt_scan) { |
647 this.importButton_.disabled = !update.executable; | 627 switch(responseId) { |
648 this.importButton_.style.display = | 628 case importer.ResponseId.HIDDEN: |
649 update.visible ? 'block' : 'none'; | 629 this.setDetailsVisible(false); |
650 | 630 |
651 this.icon_.setAttribute('icon', update.coreIcon); | 631 this.importButton_.disabled = true; |
632 this.detailsButton_.disabled = true; | |
652 | 633 |
653 this.detailsButton_.disabled = !update.executable; | 634 this.importButton_.hidden = true; |
654 this.detailsButton_.style.display = | 635 this.detailsButton_.hidden = true; |
655 update.visible ? 'block' : 'none'; | |
656 }; | |
657 | 636 |
658 /** @override */ | 637 this.importButton_.setAttribute( |
659 importer.RuntimeCommandWidget.prototype.updateDetails = function(scan) { | 638 'title', |
660 this.photoCount_.textContent = scan.getFileEntries().length.toLocaleString(); | 639 '** SHOULD NOT BE VISIBLE **'); |
661 this.spaceRequired_.textContent = util.bytesToString(scan.getTotalBytes()); | 640 this.statusContent_.innerHTML = |
641 '** SHOULD NOT BE VISIBLE **'; | |
642 | |
643 this.toolbarIcon_.setAttribute('icon', 'cloud-off'); | |
644 this.statusIcon_.setAttribute('icon', 'cloud-off'); | |
645 | |
646 break; | |
647 | |
648 case importer.ResponseId.IMPORTING: | |
649 console.assert(!!opt_scan, 'Scan not defined, but is required.'); | |
650 this.setDetailsVisible(false); | |
651 | |
652 this.importButton_.setAttribute('title', strf( | |
653 'CLOUD_IMPORT_TOOLTIP_IMPORTING', | |
654 opt_scan.getFileEntries().length)); | |
655 this.statusContent_.innerHTML = strf( | |
656 'CLOUD_IMPORT_STATUS_IMPORTING', | |
657 opt_scan.getFileEntries().length); | |
658 | |
659 this.importButton_.disabled = true; | |
660 this.detailsButton_.disabled = true; | |
661 this.detailsImportButton_.disabled = true; | |
662 | |
663 this.importButton_.hidden = false; | |
664 this.detailsButton_.hidden = false; | |
665 this.detailsImportButton_.hidden = false; | |
666 | |
667 this.toolbarIcon_.setAttribute('icon', 'autorenew'); | |
668 this.statusIcon_.setAttribute('icon', 'autorenew'); | |
669 | |
670 break; | |
671 | |
672 case importer.ResponseId.INSUFFICIENT_SPACE: | |
673 console.assert(!!opt_scan, 'Scan not defined, but is required.'); | |
674 | |
675 this.importButton_.setAttribute('title', strf( | |
676 'CLOUD_IMPORT_STATUS_INSUFFICIENT_SPACE')); | |
677 this.statusContent_.innerHTML = strf( | |
678 'CLOUD_IMPORT_STATUS_INSUFFICIENT_SPACE', | |
679 opt_scan.getFileEntries().length); | |
680 | |
681 this.importButton_.disabled = true; | |
682 this.detailsButton_.disabled = false; | |
683 this.detailsImportButton_.disabled = true; | |
684 | |
685 this.importButton_.hidden = false; | |
686 this.detailsButton_.hidden = false; | |
687 this.detailsImportButton_.hidden = false; | |
688 | |
689 this.toolbarIcon_.setAttribute('icon', 'image:photo'); | |
690 this.statusIcon_.setAttribute('icon', 'cloud-off'); | |
691 break; | |
692 | |
693 case importer.ResponseId.NO_MEDIA: | |
694 this.importButton_.setAttribute('title', str( | |
695 'CLOUD_IMPORT_STATUS_NO_MEDIA')); | |
696 this.statusContent_.innerHTML = str( | |
697 'CLOUD_IMPORT_STATUS_NO_MEDIA'); | |
698 | |
699 this.importButton_.disabled = false; | |
700 this.detailsButton_.disabled = false; | |
701 this.detailsImportButton_.disabled = true; | |
702 | |
703 this.importButton_.hidden = false; | |
704 this.detailsButton_.hidden = false; | |
705 // Hidden for now, since this is also the "done" importing case. | |
706 this.detailsImportButton_.hidden = true; | |
707 | |
708 this.toolbarIcon_.setAttribute('icon', 'cloud-done'); | |
709 this.statusIcon_.setAttribute('icon', 'cloud-done'); | |
710 break; | |
711 | |
712 case importer.ResponseId.READY: | |
713 console.assert(!!opt_scan, 'Scan not defined, but is required.'); | |
714 | |
715 this.importButton_.setAttribute('title', strf( | |
716 'CLOUD_IMPORT_TOOLTIP_READY', | |
717 opt_scan.getFileEntries().length)); | |
718 this.statusContent_.innerHTML = strf( | |
719 'CLOUD_IMPORT_STATUS_READY', | |
720 opt_scan.getFileEntries().length); | |
721 | |
722 this.importButton_.disabled = false; | |
723 this.detailsButton_.disabled = false; | |
724 this.detailsImportButton_.disabled = false; | |
725 | |
726 this.importButton_.hidden = false; | |
727 this.detailsButton_.hidden = false; | |
728 this.detailsImportButton_.hidden = false; | |
729 | |
730 this.toolbarIcon_.setAttribute('icon', 'cloud-upload'); | |
731 this.statusIcon_.setAttribute('icon', 'image:photo'); | |
732 break; | |
733 | |
734 case importer.ResponseId.SCANNING: | |
735 console.assert(!!opt_scan, 'Scan not defined, but is required.'); | |
736 | |
737 this.importButton_.setAttribute('title', str( | |
738 'CLOUD_IMPORT_TOOLTIP_SCANNING')); | |
739 this.statusContent_.innerHTML = strf( | |
740 'CLOUD_IMPORT_STATUS_SCANNING', | |
741 opt_scan.getFileEntries().length); | |
742 | |
743 this.importButton_.disabled = true; | |
744 this.detailsButton_.disabled = true; | |
745 this.detailsImportButton_.disabled = true; | |
746 | |
747 this.importButton_.hidden = false; | |
748 this.detailsButton_.hidden = false; | |
749 this.detailsImportButton_.hidden = true; | |
750 | |
751 this.toolbarIcon_.setAttribute('icon', 'autorenew'); | |
752 this.statusIcon_.setAttribute('icon', 'autorenew'); | |
753 break; | |
754 | |
755 default: | |
756 assertNotReached('Unrecognized response id: ' + responseId); | |
757 } | |
662 }; | 758 }; |
663 | 759 |
664 /** @override */ | 760 /** @override */ |
665 importer.RuntimeCommandWidget.prototype.resetDetails = function() { | 761 importer.RuntimeCommandWidget.prototype.resetDetails = function() { |
666 this.photoCount_.textContent = 0; | 762 // this.photoCount_.textContent = 0; |
Ben Kwa
2015/02/12 23:31:15
Remove this?
Steve McKay
2015/02/12 23:39:36
Done.
| |
667 this.spaceRequired_.textContent = 0; | 763 // this.spaceRequired_.textContent = 0; |
668 }; | 764 }; |
669 | 765 |
670 /** | 766 /** |
671 * A cache for ScanResults. | 767 * A cache for ScanResults. |
672 * | 768 * |
673 * @constructor | 769 * @constructor |
674 * @struct | 770 * @struct |
675 * | 771 * |
676 * @param {!importer.ControllerEnvironment} environment | 772 * @param {!importer.ControllerEnvironment} environment |
677 * @param {!importer.MediaScanner} scanner | 773 * @param {!importer.MediaScanner} scanner |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
766 var directory = this.environment_.getCurrentDirectory(); | 862 var directory = this.environment_.getCurrentDirectory(); |
767 var url = directory.toURL(); | 863 var url = directory.toURL(); |
768 var scan = this.directoryScans_[url]; | 864 var scan = this.directoryScans_[url]; |
769 if (!scan) { | 865 if (!scan) { |
770 scan = this.scanner_.scan([directory]); | 866 scan = this.scanner_.scan([directory]); |
771 this.directoryScans_[url] = scan; | 867 this.directoryScans_[url] = scan; |
772 } | 868 } |
773 | 869 |
774 return scan; | 870 return scan; |
775 }; | 871 }; |
OLD | NEW |