Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(344)

Side by Side Diff: ui/file_manager/gallery/js/slide_mode.js

Issue 385263005: Gallery: Add support for Media Keys (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adjust to 80 columns as suggested Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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' ||
611 keyID === 'Left' ||
612 keyID === 'MediaPreviousTrack');
613 this.advanceManually(prev ? -1 : 1);
611 }; 614 };
612 615
613 /** 616 /**
614 * Advance the selection as a result of a user action (as opposed to an 617 * Advance the selection as a result of a user action (as opposed to an
615 * automatic change in the slideshow mode). 618 * automatic change in the slideshow mode).
616 * @param {number} direction -1 for left, 1 for right. 619 * @param {number} direction -1 for left, 1 for right.
617 */ 620 */
618 SlideMode.prototype.advanceManually = function(direction) { 621 SlideMode.prototype.advanceManually = function(direction) {
619 if (this.isSlideshowPlaying_()) 622 if (this.isSlideshowPlaying_())
620 this.pauseSlideshow_(); 623 this.pauseSlideshow_();
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 * 802 *
800 * @param {Event} event Event. 803 * @param {Event} event Event.
801 * @return {boolean} True if handled. 804 * @return {boolean} True if handled.
802 */ 805 */
803 SlideMode.prototype.onKeyDown = function(event) { 806 SlideMode.prototype.onKeyDown = function(event) {
804 var keyID = util.getKeyModifiers(event) + event.keyIdentifier; 807 var keyID = util.getKeyModifiers(event) + event.keyIdentifier;
805 808
806 if (this.isSlideshowOn_()) { 809 if (this.isSlideshowOn_()) {
807 switch (keyID) { 810 switch (keyID) {
808 case 'U+001B': // Escape exits the slideshow. 811 case 'U+001B': // Escape exits the slideshow.
812 case 'MediaStop':
809 this.stopSlideshow_(event); 813 this.stopSlideshow_(event);
810 break; 814 break;
811 815
812 case 'U+0020': // Space pauses/resumes the slideshow. 816 case 'U+0020': // Space pauses/resumes the slideshow.
817 case 'MediaPlayPause':
813 this.toggleSlideshowPause_(); 818 this.toggleSlideshowPause_();
814 break; 819 break;
815 820
816 case 'Up': 821 case 'Up':
817 case 'Down': 822 case 'Down':
818 case 'Left': 823 case 'Left':
819 case 'Right': 824 case 'Right':
825 case 'MediaNextTrack':
826 case 'MediaPreviousTrack':
820 this.advanceWithKeyboard(keyID); 827 this.advanceWithKeyboard(keyID);
821 break; 828 break;
822 } 829 }
823 return true; // Consume all keystrokes in the slideshow mode. 830 return true; // Consume all keystrokes in the slideshow mode.
824 } 831 }
825 832
826 if (this.isEditing() && this.editor_.onKeyDown(event)) 833 if (this.isEditing() && this.editor_.onKeyDown(event))
827 return true; 834 return true;
828 835
829 switch (keyID) { 836 switch (keyID) {
(...skipping 16 matching lines...) Expand all
846 case 'Home': 853 case 'Home':
847 this.selectFirst(); 854 this.selectFirst();
848 break; 855 break;
849 case 'End': 856 case 'End':
850 this.selectLast(); 857 this.selectLast();
851 break; 858 break;
852 case 'Up': 859 case 'Up':
853 case 'Down': 860 case 'Down':
854 case 'Left': 861 case 'Left':
855 case 'Right': 862 case 'Right':
863 case 'MediaNextTrack':
864 case 'MediaPreviousTrack':
856 this.advanceWithKeyboard(keyID); 865 this.advanceWithKeyboard(keyID);
857 break; 866 break;
858 867
859 default: return false; 868 default: return false;
860 } 869 }
861 870
862 return true; 871 return true;
863 }; 872 };
864 873
865 /** 874 /**
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 done = true; 1272 done = true;
1264 } 1273 }
1265 }.bind(this); 1274 }.bind(this);
1266 }; 1275 };
1267 1276
1268 /** 1277 /**
1269 * If the user touched the image and moved the finger more than SWIPE_THRESHOLD 1278 * 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). 1279 * horizontally it's considered as a swipe gesture (change the current image).
1271 */ 1280 */
1272 SwipeOverlay.SWIPE_THRESHOLD = 100; 1281 SwipeOverlay.SWIPE_THRESHOLD = 100;
OLDNEW
« no previous file with comments | « ui/file_manager/gallery/js/gallery.js ('k') | ui/webui/resources/js/cr/ui/list_selection_controller.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698