OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** | 7 /** |
8 * The current selection object. | 8 * The current selection object. |
9 * | 9 * |
10 * @param {FileManager} fileManager FileManager instance. | 10 * @param {FileManager} fileManager FileManager instance. |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 | 469 |
470 /** | 470 /** |
471 * Calculates async selection stats and updates secondary UI elements. | 471 * Calculates async selection stats and updates secondary UI elements. |
472 * | 472 * |
473 * @param {FileSelection} selection The selection object. | 473 * @param {FileSelection} selection The selection object. |
474 */ | 474 */ |
475 FileSelectionHandler.prototype.updateFileSelectionAsync = function(selection) { | 475 FileSelectionHandler.prototype.updateFileSelectionAsync = function(selection) { |
476 if (this.selection != selection) return; | 476 if (this.selection != selection) return; |
477 | 477 |
478 // Update the file tasks. | 478 // Update the file tasks. |
479 var onTasks = function() { | |
480 if (this.selection != selection) return; | |
481 selection.tasks.display(this.taskItems_); | |
482 selection.tasks.updateMenuItem(); | |
483 }.bind(this); | |
484 | |
485 if (this.fileManager_.dialogType == DialogType.FULL_PAGE && | 479 if (this.fileManager_.dialogType == DialogType.FULL_PAGE && |
486 selection.directoryCount == 0 && selection.fileCount > 0) { | 480 selection.directoryCount == 0 && selection.fileCount > 0) { |
487 selection.createTasks(onTasks); | 481 selection.createTasks(function() { |
| 482 if (this.selection != selection) |
| 483 return; |
| 484 selection.tasks.display(this.taskItems_); |
| 485 selection.tasks.updateMenuItem(); |
| 486 }.bind(this)); |
488 } else { | 487 } else { |
489 this.taskItems_.hidden = true; | 488 this.taskItems_.hidden = true; |
490 } | 489 } |
491 | 490 |
492 // Update the UI. | 491 // Update preview panels. |
493 var wasVisible = this.isPreviewPanelVisibile_(); | 492 var wasVisible = this.isPreviewPanelVisibile_(); |
| 493 var thumbnailEntries; |
| 494 if (util.platform.newUI() && selection.totalCount == 0) { |
| 495 thumbnailEntries = [ |
| 496 this.fileManager_.getCurrentDirectoryEntry() |
| 497 ]; |
| 498 } else { |
| 499 thumbnailEntries = selection.entries; |
| 500 if (selection.totalCount != 1) { |
| 501 selection.computeBytes(function() { |
| 502 if (this.selection != selection) |
| 503 return; |
| 504 this.updatePreviewPanelText_(); |
| 505 }.bind(this)); |
| 506 } |
| 507 } |
494 this.updatePreviewPanelVisibility_(); | 508 this.updatePreviewPanelVisibility_(); |
| 509 this.updatePreviewPanelText_(); |
| 510 this.showPreviewThumbnails_(thumbnailEntries); |
495 | 511 |
496 if (util.platform.newUI() && selection.totalCount == 0) { | 512 // Update breadcrums. |
| 513 var updateTarget = null; |
| 514 if (util.platform.newUI()) { |
497 var path = this.fileManager_.getCurrentDirectory(); | 515 var path = this.fileManager_.getCurrentDirectory(); |
498 // Hides the breadcrumbs list on the root path. | 516 if (selection.totalCount == 1) { |
499 if (PathUtil.isRootPath(path)) | 517 // Shows the breadcrumb list when a file is selected. |
500 this.updatePreviewPanelBreadcrumbs_(null); | 518 updateTarget = selection.entries[0].fullPath; |
501 else | 519 } else if (selection.totalCount == 0 && !PathUtil.isRootPath(path)) { |
502 this.updatePreviewPanelBreadcrumbs_(path); | 520 // Shows the breadcrumb list when no file is selected and the current |
503 var entry = this.fileManager_.getCurrentDirectoryEntry(); | 521 // directory is non-root path. |
504 this.showPreviewThumbnails_([entry]); | 522 updateTarget = path; |
505 this.updatePreviewPanelText_(); | 523 } |
506 return; | |
507 } | 524 } |
| 525 this.updatePreviewPanelBreadcrumbs_(updateTarget); |
508 | 526 |
509 this.fileManager_.updateContextMenuActionItems(null, false); | 527 // Scroll to item |
510 if (!wasVisible && this.selection.totalCount == 1) { | 528 if (!wasVisible && this.selection.totalCount == 1) { |
511 var list = this.fileManager_.getCurrentList(); | 529 var list = this.fileManager_.getCurrentList(); |
512 list.scrollIndexIntoView(list.selectionModel.selectedIndex); | 530 list.scrollIndexIntoView(list.selectionModel.selectedIndex); |
513 } | 531 } |
514 | 532 |
515 // Sync the commands availability. | 533 // Sync the commands availability. |
516 var commands = this.fileManager_.dialogDom_.querySelectorAll('command'); | 534 if (selection.totalCount != 0) { |
517 for (var i = 0; i < commands.length; i++) | 535 var commands = this.fileManager_.dialogDom_.querySelectorAll('command'); |
518 commands[i].canExecuteChange(); | 536 for (var i = 0; i < commands.length; i++) |
519 | 537 commands[i].canExecuteChange(); |
520 if (!util.platform.newUI()) { | |
521 this.updateSearchBreadcrumbs_(); | |
522 // Update the summary information. | |
523 var onBytes = function() { | |
524 if (this.selection != selection) return; | |
525 this.updatePreviewPanelText_(); | |
526 }.bind(this); | |
527 selection.computeBytes(onBytes); | |
528 this.updatePreviewPanelText_(); | |
529 } else { | |
530 if (selection.totalCount == 1) { | |
531 // Shows the breadcrumb list. | |
532 var firstEntry = selection.entries[0]; | |
533 this.updatePreviewPanelBreadcrumbs_(firstEntry.fullPath); | |
534 this.updatePreviewPanelText_(); | |
535 } else { | |
536 this.updatePreviewPanelBreadcrumbs_(null); | |
537 | |
538 // Update the summary information. | |
539 var onBytes = function() { | |
540 if (this.selection != selection) return; | |
541 this.updatePreviewPanelText_(); | |
542 }.bind(this); | |
543 selection.computeBytes(onBytes); | |
544 this.updatePreviewPanelText_(); | |
545 } | |
546 } | 538 } |
547 | 539 |
| 540 // Update context menu. |
| 541 this.fileManager_.updateContextMenuActionItems(null, false); |
| 542 |
548 // Inform tests it's OK to click buttons now. | 543 // Inform tests it's OK to click buttons now. |
549 chrome.test.sendMessage('selection-change-complete'); | 544 if (selection.totalCount > 0) { |
550 | 545 chrome.test.sendMessage('selection-change-complete'); |
551 // Show thumbnails. | 546 } |
552 this.showPreviewThumbnails_(selection.entries); | |
553 }; | 547 }; |
554 | 548 |
555 /** | 549 /** |
556 * Renders preview thumbnails in preview panel. | 550 * Renders preview thumbnails in preview panel. |
557 * | 551 * |
558 * @param {Array.<FileEntry>} entries The entries of selected object. | 552 * @param {Array.<FileEntry>} entries The entries of selected object. |
559 * @private | 553 * @private |
560 */ | 554 */ |
561 FileSelectionHandler.prototype.showPreviewThumbnails_ = function(entries) { | 555 FileSelectionHandler.prototype.showPreviewThumbnails_ = function(entries) { |
562 var selection = this.selection; | 556 var selection = this.selection; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 style.left = (boxWidth - imageWidth) / 2 + 'px'; | 752 style.left = (boxWidth - imageWidth) / 2 + 'px'; |
759 style.top = (boxHeight - imageHeight) / 2 + 'px'; | 753 style.top = (boxHeight - imageHeight) / 2 + 'px'; |
760 style.position = 'relative'; | 754 style.position = 'relative'; |
761 | 755 |
762 util.applyTransform(largeImage, transform); | 756 util.applyTransform(largeImage, transform); |
763 | 757 |
764 largeImageBox.appendChild(largeImage); | 758 largeImageBox.appendChild(largeImage); |
765 largeImageBox.style.zIndex = 1000; | 759 largeImageBox.style.zIndex = 1000; |
766 return true; | 760 return true; |
767 }; | 761 }; |
OLD | NEW |