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

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: Review fixes 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)
141 chrome.send('selectImage', [userImageList.children[nextIndex].src]);
132 e.stopPropagation(); 142 e.stopPropagation();
133 }); 143 });
134 }; 144 };
135 145
136 /** 146 /**
137 * Selects the specified user image and shows it in preview. 147 * Selects the specified user image and shows it in preview.
138 * @param {number} index The index of the image to select. 148 * @param {number} index The index of the image to select.
139 */ 149 */
140 UserImageScreen.selectUserImage = function(index) { 150 UserImageScreen.selectUserImage = function(index) {
141 var userImageList = $('user-image-list'); 151 var userImageList = $('user-image-list');
(...skipping 10 matching lines...) Expand all
152 selectedImage.focus(); 162 selectedImage.focus();
153 $('user-image-preview').src = selectedImage.src; 163 $('user-image-preview').src = selectedImage.src;
154 } 164 }
155 userImageScreen.selectedUserImage_ = index; 165 userImageScreen.selectedUserImage_ = index;
156 }; 166 };
157 167
158 return { 168 return {
159 UserImageScreen: UserImageScreen 169 UserImageScreen: UserImageScreen
160 }; 170 };
161 }); 171 });
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