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 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Slide mode displays a single image and has a set of controls to navigate | 8 * Slide mode displays a single image and has a set of controls to navigate |
| 9 * between the images and to edit an image. | 9 * between the images and to edit an image. |
| 10 * | 10 * |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 600 } else { | 600 } else { |
| 601 return advance(this.getSelectedIndex(), this.getItemCount_()); | 601 return advance(this.getSelectedIndex(), this.getItemCount_()); |
| 602 } | 602 } |
| 603 }; | 603 }; |
| 604 | 604 |
| 605 /** | 605 /** |
| 606 * Advance the selection based on the pressed key ID. | 606 * Advance the selection based on the pressed key ID. |
| 607 * @param {string} keyID Key identifier. | 607 * @param {string} keyID Key identifier. |
| 608 */ | 608 */ |
| 609 SlideMode.prototype.advanceWithKeyboard = function(keyID) { | 609 SlideMode.prototype.advanceWithKeyboard = function(keyID) { |
| 610 this.advanceManually(keyID === 'Up' || keyID === 'Left' ? -1 : 1); | 610 var prev = (keyID === 'Up' || keyID === 'Left' || keyID === 'MediaPreviousTrac k'); |
|
yoshiki
2014/07/14 02:28:06
nit: Please fit a line within 80-columns width.
etrunko
2014/07/14 13:27:32
Done.
| |
| 611 this.advanceManually(prev ? -1 : 1); | |
| 611 }; | 612 }; |
| 612 | 613 |
| 613 /** | 614 /** |
| 614 * Advance the selection as a result of a user action (as opposed to an | 615 * Advance the selection as a result of a user action (as opposed to an |
| 615 * automatic change in the slideshow mode). | 616 * automatic change in the slideshow mode). |
| 616 * @param {number} direction -1 for left, 1 for right. | 617 * @param {number} direction -1 for left, 1 for right. |
| 617 */ | 618 */ |
| 618 SlideMode.prototype.advanceManually = function(direction) { | 619 SlideMode.prototype.advanceManually = function(direction) { |
| 619 if (this.isSlideshowPlaying_()) | 620 if (this.isSlideshowPlaying_()) |
| 620 this.pauseSlideshow_(); | 621 this.pauseSlideshow_(); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 799 * | 800 * |
| 800 * @param {Event} event Event. | 801 * @param {Event} event Event. |
| 801 * @return {boolean} True if handled. | 802 * @return {boolean} True if handled. |
| 802 */ | 803 */ |
| 803 SlideMode.prototype.onKeyDown = function(event) { | 804 SlideMode.prototype.onKeyDown = function(event) { |
| 804 var keyID = util.getKeyModifiers(event) + event.keyIdentifier; | 805 var keyID = util.getKeyModifiers(event) + event.keyIdentifier; |
| 805 | 806 |
| 806 if (this.isSlideshowOn_()) { | 807 if (this.isSlideshowOn_()) { |
| 807 switch (keyID) { | 808 switch (keyID) { |
| 808 case 'U+001B': // Escape exits the slideshow. | 809 case 'U+001B': // Escape exits the slideshow. |
| 810 case 'MediaStop': | |
| 809 this.stopSlideshow_(event); | 811 this.stopSlideshow_(event); |
| 810 break; | 812 break; |
| 811 | 813 |
| 812 case 'U+0020': // Space pauses/resumes the slideshow. | 814 case 'U+0020': // Space pauses/resumes the slideshow. |
| 815 case 'MediaPlayPause': | |
| 813 this.toggleSlideshowPause_(); | 816 this.toggleSlideshowPause_(); |
| 814 break; | 817 break; |
| 815 | 818 |
| 816 case 'Up': | 819 case 'Up': |
| 817 case 'Down': | 820 case 'Down': |
| 818 case 'Left': | 821 case 'Left': |
| 819 case 'Right': | 822 case 'Right': |
| 823 case 'MediaNextTrack': | |
| 824 case 'MediaPreviousTrack': | |
| 820 this.advanceWithKeyboard(keyID); | 825 this.advanceWithKeyboard(keyID); |
| 821 break; | 826 break; |
| 822 } | 827 } |
| 823 return true; // Consume all keystrokes in the slideshow mode. | 828 return true; // Consume all keystrokes in the slideshow mode. |
| 824 } | 829 } |
| 825 | 830 |
| 826 if (this.isEditing() && this.editor_.onKeyDown(event)) | 831 if (this.isEditing() && this.editor_.onKeyDown(event)) |
| 827 return true; | 832 return true; |
| 828 | 833 |
| 829 switch (keyID) { | 834 switch (keyID) { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 846 case 'Home': | 851 case 'Home': |
| 847 this.selectFirst(); | 852 this.selectFirst(); |
| 848 break; | 853 break; |
| 849 case 'End': | 854 case 'End': |
| 850 this.selectLast(); | 855 this.selectLast(); |
| 851 break; | 856 break; |
| 852 case 'Up': | 857 case 'Up': |
| 853 case 'Down': | 858 case 'Down': |
| 854 case 'Left': | 859 case 'Left': |
| 855 case 'Right': | 860 case 'Right': |
| 861 case 'MediaNextTrack': | |
| 862 case 'MediaPreviousTrack': | |
| 856 this.advanceWithKeyboard(keyID); | 863 this.advanceWithKeyboard(keyID); |
| 857 break; | 864 break; |
| 858 | 865 |
| 859 default: return false; | 866 default: return false; |
| 860 } | 867 } |
| 861 | 868 |
| 862 return true; | 869 return true; |
| 863 }; | 870 }; |
| 864 | 871 |
| 865 /** | 872 /** |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1263 done = true; | 1270 done = true; |
| 1264 } | 1271 } |
| 1265 }.bind(this); | 1272 }.bind(this); |
| 1266 }; | 1273 }; |
| 1267 | 1274 |
| 1268 /** | 1275 /** |
| 1269 * If the user touched the image and moved the finger more than SWIPE_THRESHOLD | 1276 * If the user touched the image and moved the finger more than SWIPE_THRESHOLD |
| 1270 * horizontally it's considered as a swipe gesture (change the current image). | 1277 * horizontally it's considered as a swipe gesture (change the current image). |
| 1271 */ | 1278 */ |
| 1272 SwipeOverlay.SWIPE_THRESHOLD = 100; | 1279 SwipeOverlay.SWIPE_THRESHOLD = 100; |
| OLD | NEW |