Chromium Code Reviews| 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() { |
|
yoshiki
2013/05/28 02:26:48
Why moved to here? The logic doesn't seem changed.
hirono
2013/05/28 04:08:44
If a callback function is assigned to a variable,
yoshiki
2013/05/28 04:20:33
Got it. Thanks for explanation.
| |
| 482 if (this.selection != selection) return; | |
|
yoshiki
2013/05/28 02:26:48
nit: New line after condition.
hirono
2013/05/28 04:08:44
Done.
| |
| 483 selection.tasks.display(this.taskItems_); | |
| 484 selection.tasks.updateMenuItem(); | |
| 485 }.bind(this)); | |
| 488 } else { | 486 } else { |
| 489 this.taskItems_.hidden = true; | 487 this.taskItems_.hidden = true; |
| 490 } | 488 } |
| 491 | 489 |
| 492 // Update the UI. | 490 // Update preview panels. |
| 493 var wasVisible = this.isPreviewPanelVisibile_(); | 491 var wasVisible = this.isPreviewPanelVisibile_(); |
| 492 var thumbnailEntries = null; | |
| 493 if (util.platform.newUI() && selection.totalCount == 0) { | |
| 494 thumbnailEntries = [ | |
| 495 this.fileManager_.getCurrentDirectoryEntry() | |
| 496 ]; | |
| 497 } else { | |
| 498 thumbnailEntries = selection.entries; | |
| 499 selection.computeBytes(function() { | |
|
yoshiki
2013/05/28 02:26:48
if selection.totalCount == 1, we don't need to com
hirono
2013/05/28 04:08:44
Done.
| |
| 500 if (this.selection != selection) return; | |
|
yoshiki
2013/05/28 02:26:48
nit: New line after condition.
hirono
2013/05/28 04:08:44
Done.
| |
| 501 this.updatePreviewPanelText_(); | |
| 502 }.bind(this)); | |
| 503 } | |
| 494 this.updatePreviewPanelVisibility_(); | 504 this.updatePreviewPanelVisibility_(); |
| 505 this.updatePreviewPanelText_(); | |
| 506 this.showPreviewThumbnails_(thumbnailEntries); | |
| 495 | 507 |
| 496 if (util.platform.newUI() && selection.totalCount == 0) { | 508 // Update breadcrums. |
| 509 var updateTarget = null; | |
| 510 if (util.platform.newUI()) { | |
| 497 var path = this.fileManager_.getCurrentDirectory(); | 511 var path = this.fileManager_.getCurrentDirectory(); |
| 498 // Hides the breadcrumbs list on the root path. | 512 if (selection.totalCount == 1) { |
| 499 if (PathUtil.isRootPath(path)) | 513 // Shows the breadcrumb list. |
| 500 this.updatePreviewPanelBreadcrumbs_(null); | 514 updateTarget = selection.entries[0].fullPath; |
| 501 else | 515 } else if (selection.totalCount == 0 && !PathUtil.isRootPath(path)) { |
| 502 this.updatePreviewPanelBreadcrumbs_(path); | 516 // Hides the breadcrumbs list on the root path. |
|
yoshiki
2013/05/28 02:26:48
Does this comment appropriate for this block?
May
hirono
2013/05/28 04:08:44
Done.
| |
| 503 var entry = this.fileManager_.getCurrentDirectoryEntry(); | 517 updateTarget = path; |
| 504 this.showPreviewThumbnails_([entry]); | 518 } |
| 505 this.updatePreviewPanelText_(); | |
| 506 return; | |
| 507 } | 519 } |
| 520 this.updatePreviewPanelBreadcrumbs_(updateTarget); | |
| 508 | 521 |
| 509 this.fileManager_.updateContextMenuActionItems(null, false); | 522 // Scroll to item |
| 510 if (!wasVisible && this.selection.totalCount == 1) { | 523 if (!wasVisible && this.selection.totalCount == 1) { |
| 511 var list = this.fileManager_.getCurrentList(); | 524 var list = this.fileManager_.getCurrentList(); |
| 512 list.scrollIndexIntoView(list.selectionModel.selectedIndex); | 525 list.scrollIndexIntoView(list.selectionModel.selectedIndex); |
| 513 } | 526 } |
| 514 | 527 |
| 515 // Sync the commands availability. | 528 // Sync the commands availability. |
| 516 var commands = this.fileManager_.dialogDom_.querySelectorAll('command'); | 529 var commands = this.fileManager_.dialogDom_.querySelectorAll('command'); |
|
yoshiki
2013/05/28 02:26:48
We don't need to do it when no file is selected.
hirono
2013/05/28 04:08:44
Done.
| |
| 517 for (var i = 0; i < commands.length; i++) | 530 for (var i = 0; i < commands.length; i++) |
| 518 commands[i].canExecuteChange(); | 531 commands[i].canExecuteChange(); |
| 519 | 532 |
| 520 if (!util.platform.newUI()) { | 533 // Update context menu. |
| 521 this.updateSearchBreadcrumbs_(); | 534 this.fileManager_.updateContextMenuActionItems(null, false); |
| 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 } | |
| 547 | 535 |
| 548 // Inform tests it's OK to click buttons now. | 536 // Inform tests it's OK to click buttons now. |
| 549 chrome.test.sendMessage('selection-change-complete'); | 537 chrome.test.sendMessage('selection-change-complete'); |
| 550 | |
| 551 // Show thumbnails. | |
| 552 this.showPreviewThumbnails_(selection.entries); | |
| 553 }; | 538 }; |
| 554 | 539 |
| 555 /** | 540 /** |
| 556 * Renders preview thumbnails in preview panel. | 541 * Renders preview thumbnails in preview panel. |
| 557 * | 542 * |
| 558 * @param {Array.<FileEntry>} entries The entries of selected object. | 543 * @param {Array.<FileEntry>} entries The entries of selected object. |
| 559 * @private | 544 * @private |
| 560 */ | 545 */ |
| 561 FileSelectionHandler.prototype.showPreviewThumbnails_ = function(entries) { | 546 FileSelectionHandler.prototype.showPreviewThumbnails_ = function(entries) { |
| 562 var selection = this.selection; | 547 var selection = this.selection; |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 758 style.left = (boxWidth - imageWidth) / 2 + 'px'; | 743 style.left = (boxWidth - imageWidth) / 2 + 'px'; |
| 759 style.top = (boxHeight - imageHeight) / 2 + 'px'; | 744 style.top = (boxHeight - imageHeight) / 2 + 'px'; |
| 760 style.position = 'relative'; | 745 style.position = 'relative'; |
| 761 | 746 |
| 762 util.applyTransform(largeImage, transform); | 747 util.applyTransform(largeImage, transform); |
| 763 | 748 |
| 764 largeImageBox.appendChild(largeImage); | 749 largeImageBox.appendChild(largeImage); |
| 765 largeImageBox.style.zIndex = 1000; | 750 largeImageBox.style.zIndex = 1000; |
| 766 return true; | 751 return true; |
| 767 }; | 752 }; |
| OLD | NEW |