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

Side by Side Diff: chrome/browser/resources/chromeos/login/oobe_screen_user_image.js

Issue 7792036: [cros] User image selection with keyboard arrows works. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 * @fileoverview Oobe user image screen implementation. 6 * @fileoverview Oobe user image screen implementation.
7 */ 7 */
8 8
9 cr.define('oobe', function() { 9 cr.define('oobe', function() {
10 /** 10 /**
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 UserImageScreen.addUserImage( 118 UserImageScreen.addUserImage(
119 imageUrl, 119 imageUrl,
120 UserImageScreen.handleImageClick); 120 UserImageScreen.handleImageClick);
121 } 121 }
122 122
123 var userImageScreen = $('user-image'); 123 var userImageScreen = $('user-image');
124 var userImageList = $('user-image-list'); 124 var userImageList = $('user-image-list');
125 userImageList.addEventListener('keydown', function(e) { 125 userImageList.addEventListener('keydown', function(e) {
126 var prevIndex = userImageScreen.selectedUserImage_; 126 var prevIndex = userImageScreen.selectedUserImage_;
127 var len = userImageList.children.length; 127 var len = userImageList.children.length;
128 var nextIndex;
128 if (e.keyCode == 39 || e.keyCode == 40) // right or down 129 if (e.keyCode == 39 || e.keyCode == 40) // right or down
129 UserImageScreen.selectUserImage((prevIndex + 1) % len); 130 nextIndex = (prevIndex + 1) % len;
130 else if (e.keyCode == 37 || e.keyCode == 38) // left or up 131 else if (e.keyCode == 37 || e.keyCode == 38) // left or up
131 UserImageScreen.selectUserImage((prevIndex - 1 + len) % len); 132 nextIndex = (prevIndex - 1 + len) % len;
133 else if (e.keyCode == 13 && prevIndex == 0)
134 // Enter pressed while "Take photo" button active.
135 chrome.send('takePhoto');
136 if (nextIndex == 0)
137 // "Take photo" button: don't send a selection event to Chrome,
138 // just focus element and update selected index.
139 UserImageScreen.selectUserImage(0);
140 else if (nextIndex) {
whywhat 2011/08/30 12:03:14 nit: be consistent when using {}: I'd use it in bo
Ivan Korotkov 2011/08/30 12:16:40 Done.
141 chrome.send('selectImage', [userImageList.children[nextIndex].src]);
142 }
132 e.stopPropagation(); 143 e.stopPropagation();
133 }); 144 });
134 }; 145 };
135 146
136 /** 147 /**
137 * Selects the specified user image and shows it in preview. 148 * Selects the specified user image and shows it in preview.
138 * @param {number} index The index of the image to select. 149 * @param {number} index The index of the image to select.
139 */ 150 */
140 UserImageScreen.selectUserImage = function(index) { 151 UserImageScreen.selectUserImage = function(index) {
141 var userImageList = $('user-image-list'); 152 var userImageList = $('user-image-list');
(...skipping 10 matching lines...) Expand all
152 selectedImage.focus(); 163 selectedImage.focus();
153 $('user-image-preview').src = selectedImage.src; 164 $('user-image-preview').src = selectedImage.src;
154 } 165 }
155 userImageScreen.selectedUserImage_ = index; 166 userImageScreen.selectedUserImage_ = index;
156 }; 167 };
157 168
158 return { 169 return {
159 UserImageScreen: UserImageScreen 170 UserImageScreen: UserImageScreen
160 }; 171 };
161 }); 172 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698