OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 * Thumbnail Mode. | 6 * Thumbnail Mode. |
7 * @param {!HTMLElement} container A container. | 7 * @param {!HTMLElement} container A container. |
8 * @param {!ErrorBanner} errorBanner Error banner. | 8 * @param {!ErrorBanner} errorBanner Error banner. |
9 * @param {!GalleryDataModel} dataModel Gallery data model. | 9 * @param {!GalleryDataModel} dataModel Gallery data model. |
10 * @param {!cr.ui.ListSelectionModel} selectionModel List selection model. | 10 * @param {!cr.ui.ListSelectionModel} selectionModel List selection model. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 * @return {boolean} Always true. Toolbar is always visible. | 76 * @return {boolean} Always true. Toolbar is always visible. |
77 */ | 77 */ |
78 ThumbnailMode.prototype.hasActiveTool = function() { return true; }; | 78 ThumbnailMode.prototype.hasActiveTool = function() { return true; }; |
79 | 79 |
80 /** | 80 /** |
81 * Handles key down event. | 81 * Handles key down event. |
82 * @param {!Event} event An event. | 82 * @param {!Event} event An event. |
83 * @return {boolean} True when an event is handled. | 83 * @return {boolean} True when an event is handled. |
84 */ | 84 */ |
85 ThumbnailMode.prototype.onKeyDown = function(event) { | 85 ThumbnailMode.prototype.onKeyDown = function(event) { |
86 switch (event.keyIdentifier) { | 86 switch (event.key) { |
87 case 'Enter': | 87 case 'Enter': |
88 if (event.target.matches('li.thumbnail')) { | 88 if (event.target.matches('li.thumbnail')) { |
89 this.changeToSlideModeCallback_(); | 89 this.changeToSlideModeCallback_(); |
90 return true; | 90 return true; |
91 } | 91 } |
92 break; | 92 break; |
93 } | 93 } |
94 | 94 |
95 return false; | 95 return false; |
96 }; | 96 }; |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 * Handles scroll of viewport. | 345 * Handles scroll of viewport. |
346 * @param {!Event} event An event. | 346 * @param {!Event} event An event. |
347 * @private | 347 * @private |
348 */ | 348 */ |
349 ThumbnailView.prototype.onScroll_ = function(event) { | 349 ThumbnailView.prototype.onScroll_ = function(event) { |
350 this.updateScrollBar_(); | 350 this.updateScrollBar_(); |
351 }; | 351 }; |
352 | 352 |
353 /** | 353 /** |
354 * Moves selection to specified direction. | 354 * Moves selection to specified direction. |
355 * @param {string} direction Direction. Should be 'Left', 'Right', 'Up', or | 355 * @param {string} direction Direction. Should be 'ArrowLeft', 'ArrowRight', |
356 * 'Down'. | 356 * 'ArrowUp', or 'ArrowDown'. |
357 * @param {boolean} selectRange True to perform range selection. | 357 * @param {boolean} selectRange True to perform range selection. |
358 * @private | 358 * @private |
359 */ | 359 */ |
360 ThumbnailView.prototype.moveSelection_ = function(direction, selectRange) { | 360 ThumbnailView.prototype.moveSelection_ = function(direction, selectRange) { |
361 var step; | 361 var step; |
362 if ((direction === 'Left' && !isRTL()) || | 362 if ((direction === 'ArrowLeft' && !isRTL()) || |
363 (direction === 'Right' && isRTL()) || | 363 (direction === 'ArrowRight' && isRTL()) || |
364 (direction === 'Up')) { | 364 (direction === 'ArrowUp')) { |
365 step = -1; | 365 step = -1; |
366 } else if ((direction === 'Right' && !isRTL()) || | 366 } else if ((direction === 'ArrowRight' && !isRTL()) || |
367 (direction === 'Left' && isRTL()) || | 367 (direction === 'ArrowLeft' && isRTL()) || |
368 (direction === 'Down')) { | 368 (direction === 'ArrowDown')) { |
369 step = 1; | 369 step = 1; |
370 } else { | 370 } else { |
371 assertNotReached(); | 371 assertNotReached(); |
372 } | 372 } |
373 | 373 |
374 var vertical = direction === 'Up' || direction === 'Down'; | 374 var vertical = direction === 'ArrowUp' || direction === 'ArrowDown'; |
375 var baseIndex = this.selectionModel_.leadIndex !== -1 ? | 375 var baseIndex = this.selectionModel_.leadIndex !== -1 ? |
376 this.selectionModel_.leadIndex : | 376 this.selectionModel_.leadIndex : |
377 this.selectionModel_.selectedIndex; | 377 this.selectionModel_.selectedIndex; |
378 var baseRect = this.getThumbnailRect(baseIndex); | 378 var baseRect = this.getThumbnailRect(baseIndex); |
379 var baseCenter = baseRect.left + baseRect.width / 2; | 379 var baseCenter = baseRect.left + baseRect.width / 2; |
380 var minHorizontalGap = Number.MAX_VALUE; | 380 var minHorizontalGap = Number.MAX_VALUE; |
381 var index = null; | 381 var index = null; |
382 | 382 |
383 for (var i = baseIndex + step; | 383 for (var i = baseIndex + step; |
384 0 <= i && i < this.dataModel_.length; | 384 0 <= i && i < this.dataModel_.length; |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 this.dispatchEvent(thumbnailDoubleClickEvent); | 616 this.dispatchEvent(thumbnailDoubleClickEvent); |
617 } | 617 } |
618 }; | 618 }; |
619 | 619 |
620 /** | 620 /** |
621 * Handles keydown event. | 621 * Handles keydown event. |
622 * @param {!Event} event | 622 * @param {!Event} event |
623 * @private | 623 * @private |
624 */ | 624 */ |
625 ThumbnailView.prototype.onKeydown_ = function(event) { | 625 ThumbnailView.prototype.onKeydown_ = function(event) { |
626 var keyString = util.getKeyModifiers(event) + event.keyIdentifier; | 626 var keyString = util.getKeyModifiers(event) + event.key; |
627 | 627 |
628 switch (keyString) { | 628 switch (keyString) { |
629 case 'Right': | 629 case 'ArrowRight': |
630 case 'Left': | 630 case 'ArrowLeft': |
631 case 'Up': | 631 case 'ArrowUp': |
632 case 'Down': | 632 case 'ArrowDown': |
633 case 'Shift-Right': | 633 case 'Shift-ArrowRight': |
634 case 'Shift-Left': | 634 case 'Shift-ArrowLeft': |
635 case 'Shift-Up': | 635 case 'Shift-ArrowUp': |
636 case 'Shift-Down': | 636 case 'Shift-ArrowDown': |
637 this.moveSelection_(event.keyIdentifier, event.shiftKey); | 637 this.moveSelection_(event.key, event.shiftKey); |
638 event.stopPropagation(); | 638 event.stopPropagation(); |
639 break; | 639 break; |
640 case 'Ctrl-U+0041': // Crtl+A | 640 case 'Ctrl-a': // Crtl+A |
641 this.selectionModel_.selectAll(); | 641 this.selectionModel_.selectAll(); |
642 event.stopPropagation(); | 642 event.stopPropagation(); |
643 break; | 643 break; |
644 } | 644 } |
645 }; | 645 }; |
646 | 646 |
647 /** | 647 /** |
648 * Selects a thumbnail. | 648 * Selects a thumbnail. |
649 * @param {!ThumbnailView.Thumbnail} thumbnail Thumbnail to be selected. | 649 * @param {!ThumbnailView.Thumbnail} thumbnail Thumbnail to be selected. |
650 * @param {ThumbnailView.SelectionMode} selectionMode | 650 * @param {ThumbnailView.SelectionMode} selectionMode |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1018 }; | 1018 }; |
1019 }.bind(this, this.thumbnailLoadRequestId_)) | 1019 }.bind(this, this.thumbnailLoadRequestId_)) |
1020 .catch(function(requestId, error) { | 1020 .catch(function(requestId, error) { |
1021 if (requestId !== this.thumbnailLoadRequestId_) | 1021 if (requestId !== this.thumbnailLoadRequestId_) |
1022 return null; | 1022 return null; |
1023 | 1023 |
1024 this.setError_(error); | 1024 this.setError_(error); |
1025 return null; | 1025 return null; |
1026 }.bind(this, this.thumbnailLoadRequestId_)); | 1026 }.bind(this, this.thumbnailLoadRequestId_)); |
1027 }; | 1027 }; |
OLD | NEW |