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

Side by Side Diff: chrome/browser/resources/settings/people_page/change_picture.js

Issue 1720533002: Settings People Revamp: Change Picture: Add accessibility-key usage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@0095-settings-change-picture-announce-messags-old-image-alt-text
Patch Set: Created 4 years, 9 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 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 cr.define('settings_test', function() { 5 cr.define('settings_test', function() {
6 var changePictureOptions = settings_test.changePictureOptions || { 6 var changePictureOptions = settings_test.changePictureOptions || {
7 /** 7 /**
8 * True if property changes should fire events for testing purposes. 8 * True if property changes should fire events for testing purposes.
9 * @type {boolean} 9 * @type {boolean}
10 */ 10 */
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 break; 212 break;
213 case 'default': 213 case 'default':
214 settings.ChangePicturePrivateApi.selectDefaultImage(image.src); 214 settings.ChangePicturePrivateApi.selectDefaultImage(image.src);
215 break; 215 break;
216 default: 216 default:
217 assertNotReached('Selected unknown image type'); 217 assertNotReached('Selected unknown image type');
218 } 218 }
219 }, 219 },
220 220
221 /** 221 /**
222 * Handler for when accessibility-specific keys are pressed.
223 * @param {!{detail: !{key: string}}} e
224 */
225 onKeysPress_: function(e) {
226 if (!this.selectedItem_)
227 return;
228
229 // In the old Options user images grid, the 'up' and 'down' keys had
230 // different behavior depending on whether ChromeVox was on or off.
231 // If ChromeVox was on, 'up' or 'down' would select the next or previous
232 // image on the left or right. If ChromeVox was off, it would select the
233 // image spatially above or below using calculated columns.
234 //
235 // The code below implements the simple behavior of selecting the image
236 // to the left or right (as if ChromeVox was always on).
237 //
238 // TODO(tommycli): Investigate if it's necessary to calculate columns
239 // and select the image on the top or bottom for non-ChromeVox users.
240 switch (e.detail.key) {
241 case 'up':
242 case 'left':
243 // This loop always terminates because the file and profile icons are
244 // never hidden.
245 do {
246 this.$.selector.selectPrevious();
247 } while (this.selectedItem_.hidden);
248
249 this.lastSelectedImageType_ = this.selectedItem_.dataset.type;
250 break;
251
252 case 'down':
253 case 'right':
254 // This loop always terminates because the file and profile icons are
255 // never hidden.
256 do {
257 this.$.selector.selectNext();
258 } while (this.selectedItem_.hidden);
259
260 this.lastSelectedImageType_ = this.selectedItem_.dataset.type;
261 break;
262
263 case 'enter':
264 case 'space':
265 if (this.selectedItem_.dataset.type == 'camera')
266 this.$.camera.takePhoto();
267 else if (this.selectedItem_.dataset.type == 'file')
268 settings.ChangePicturePrivateApi.chooseFile();
269 else if (this.selectedItem_.dataset.type == 'old')
270 this.onTapDiscardOldImage_();
271 break;
272 }
273 },
274
275 /**
222 * Handler for when the an image is activated. 276 * Handler for when the an image is activated.
223 * @param {!Event} event 277 * @param {!Event} event
224 * @private 278 * @private
225 */ 279 */
226 onImageActivate_: function(event) { 280 onImageActivate_: function(event) {
227 var image = event.detail.item; 281 var image = event.detail.item;
228 this.lastSelectedImageType_ = image.dataset.type; 282 this.lastSelectedImageType_ = image.dataset.type;
229 this.selectImage_(image); 283 this.selectImage_(image);
230 }, 284 },
231 285
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 * @private 325 * @private
272 */ 326 */
273 isOldImageHidden_: function(oldImageUrl) { return oldImageUrl.length == 0; }, 327 isOldImageHidden_: function(oldImageUrl) { return oldImageUrl.length == 0; },
274 328
275 /** 329 /**
276 * @param {settings.ChangePictureImageElement} selectedItem 330 * @param {settings.ChangePictureImageElement} selectedItem
277 * @return {boolean} True if the preview image should be hidden. 331 * @return {boolean} True if the preview image should be hidden.
278 * @private 332 * @private
279 */ 333 */
280 isPreviewImageHidden_: function(selectedItem) { 334 isPreviewImageHidden_: function(selectedItem) {
281 if (selectedItem == undefined) 335 if (!selectedItem)
282 return true; 336 return true;
283 337
284 var type = selectedItem.dataset.type; 338 var type = selectedItem.dataset.type;
285 return type != 'default' && type != 'profile' && type != 'old'; 339 return type != 'default' && type != 'profile' && type != 'old';
286 }, 340 },
287 341
288 /** 342 /**
289 * @param {settings.ChangePictureImageElement} selectedItem 343 * @param {settings.ChangePictureImageElement} selectedItem
290 * @return {boolean} True if the camera is selected in the image grid. 344 * @return {boolean} True if the camera is selected in the image grid.
291 * @private 345 * @private
292 */ 346 */
293 isCameraActive_: function(cameraPresent, selectedItem) { 347 isCameraActive_: function(cameraPresent, selectedItem) {
294 return cameraPresent && 348 return cameraPresent && selectedItem &&
295 selectedItem != undefined && 349 selectedItem.dataset.type == 'camera';
296 selectedItem.dataset.type == 'camera';
297 }, 350 },
298 351
299 /** 352 /**
300 * @param {settings.ChangePictureImageElement} selectedItem 353 * @param {settings.ChangePictureImageElement} selectedItem
301 * @return {boolean} True if the discard controls should be hidden. 354 * @return {boolean} True if the discard controls should be hidden.
302 * @private 355 * @private
303 */ 356 */
304 isDiscardHidden_: function(selectedItem) { 357 isDiscardHidden_: function(selectedItem) {
305 return selectedItem == undefined || selectedItem.dataset.type != 'old'; 358 return !selectedItem || selectedItem.dataset.type != 'old';
306 }, 359 },
307 360
308 /** 361 /**
309 * @param {settings.ChangePictureImageElement} selectedItem 362 * @param {settings.ChangePictureImageElement} selectedItem
310 * @return {boolean} True if the author credit text is shown. 363 * @return {boolean} True if the author credit text is shown.
311 * @private 364 * @private
312 */ 365 */
313 isAuthorCreditShown_: function(selectedItem) { 366 isAuthorCreditShown_: function(selectedItem) {
314 return selectedItem && selectedItem.dataset.type == 'default'; 367 return selectedItem && selectedItem.dataset.type == 'default';
315 }, 368 },
(...skipping 21 matching lines...) Expand all
337 * @private 390 * @private
338 */ 391 */
339 getAuthorWebsite_: function(selectedItem, defaultImages) { 392 getAuthorWebsite_: function(selectedItem, defaultImages) {
340 if (!this.isAuthorCreditShown_(selectedItem)) 393 if (!this.isAuthorCreditShown_(selectedItem))
341 return ''; 394 return '';
342 395
343 assert(selectedItem.dataset.defaultImageIndex < defaultImages.length); 396 assert(selectedItem.dataset.defaultImageIndex < defaultImages.length);
344 return defaultImages[selectedItem.dataset.defaultImageIndex].website; 397 return defaultImages[selectedItem.dataset.defaultImageIndex].website;
345 }, 398 },
346 }); 399 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698