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

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: Update people to compiled_resources2 to allow passing of closure 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 var /** IronSelectorElement */ selector = this.$.selector;
241 switch (e.detail.key) {
242 case 'up':
243 case 'left':
244 // This loop always terminates because the file and profile icons are
245 // never hidden.
246 do {
247 selector.selectPrevious();
248 } while (this.selectedItem_.hidden);
249
250 this.lastSelectedImageType_ = this.selectedItem_.dataset.type;
251 break;
252
253 case 'down':
254 case 'right':
255 // This loop always terminates because the file and profile icons are
256 // never hidden.
257 do {
258 selector.selectNext();
259 } while (this.selectedItem_.hidden);
260
261 this.lastSelectedImageType_ = this.selectedItem_.dataset.type;
262 break;
263
264 case 'enter':
265 case 'space':
266 if (this.selectedItem_.dataset.type == 'camera') {
267 var /** SettingsCameraElement */ camera = this.$.camera;
268 camera.takePhoto();
269 } else if (this.selectedItem_.dataset.type == 'file') {
270 settings.ChangePicturePrivateApi.chooseFile();
271 } else if (this.selectedItem_.dataset.type == 'old') {
272 this.onTapDiscardOldImage_();
273 }
274 break;
275 }
Dan Beam 2016/03/01 22:58:24 we should probably test this as well, btw
tommycli 2016/03/01 23:10:37 I'm down with that. I'll add that in a follow up C
276 },
277
278 /**
222 * Handler for when the an image is activated. 279 * Handler for when the an image is activated.
223 * @param {!Event} event 280 * @param {!Event} event
224 * @private 281 * @private
225 */ 282 */
226 onImageActivate_: function(event) { 283 onImageActivate_: function(event) {
227 var image = event.detail.item; 284 var image = event.detail.item;
228 this.lastSelectedImageType_ = image.dataset.type; 285 this.lastSelectedImageType_ = image.dataset.type;
229 this.selectImage_(image); 286 this.selectImage_(image);
230 }, 287 },
231 288
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 * @private 328 * @private
272 */ 329 */
273 isOldImageHidden_: function(oldImageUrl) { return oldImageUrl.length == 0; }, 330 isOldImageHidden_: function(oldImageUrl) { return oldImageUrl.length == 0; },
274 331
275 /** 332 /**
276 * @param {settings.ChangePictureImageElement} selectedItem 333 * @param {settings.ChangePictureImageElement} selectedItem
277 * @return {boolean} True if the preview image should be hidden. 334 * @return {boolean} True if the preview image should be hidden.
278 * @private 335 * @private
279 */ 336 */
280 isPreviewImageHidden_: function(selectedItem) { 337 isPreviewImageHidden_: function(selectedItem) {
281 if (selectedItem == undefined) 338 if (!selectedItem)
282 return true; 339 return true;
283 340
284 var type = selectedItem.dataset.type; 341 var type = selectedItem.dataset.type;
285 return type != 'default' && type != 'profile' && type != 'old'; 342 return type != 'default' && type != 'profile' && type != 'old';
286 }, 343 },
287 344
288 /** 345 /**
289 * @param {settings.ChangePictureImageElement} selectedItem 346 * @param {settings.ChangePictureImageElement} selectedItem
290 * @return {boolean} True if the camera is selected in the image grid. 347 * @return {boolean} True if the camera is selected in the image grid.
291 * @private 348 * @private
292 */ 349 */
293 isCameraActive_: function(cameraPresent, selectedItem) { 350 isCameraActive_: function(cameraPresent, selectedItem) {
294 return cameraPresent && 351 return cameraPresent && selectedItem &&
295 selectedItem != undefined && 352 selectedItem.dataset.type == 'camera';
296 selectedItem.dataset.type == 'camera';
297 }, 353 },
298 354
299 /** 355 /**
300 * @param {settings.ChangePictureImageElement} selectedItem 356 * @param {settings.ChangePictureImageElement} selectedItem
301 * @return {boolean} True if the discard controls should be hidden. 357 * @return {boolean} True if the discard controls should be hidden.
302 * @private 358 * @private
303 */ 359 */
304 isDiscardHidden_: function(selectedItem) { 360 isDiscardHidden_: function(selectedItem) {
305 return selectedItem == undefined || selectedItem.dataset.type != 'old'; 361 return !selectedItem || selectedItem.dataset.type != 'old';
306 }, 362 },
307 363
308 /** 364 /**
309 * @param {settings.ChangePictureImageElement} selectedItem 365 * @param {settings.ChangePictureImageElement} selectedItem
310 * @return {boolean} True if the author credit text is shown. 366 * @return {boolean} True if the author credit text is shown.
311 * @private 367 * @private
312 */ 368 */
313 isAuthorCreditShown_: function(selectedItem) { 369 isAuthorCreditShown_: function(selectedItem) {
314 return selectedItem && selectedItem.dataset.type == 'default'; 370 return selectedItem && selectedItem.dataset.type == 'default';
315 }, 371 },
(...skipping 21 matching lines...) Expand all
337 * @private 393 * @private
338 */ 394 */
339 getAuthorWebsite_: function(selectedItem, defaultImages) { 395 getAuthorWebsite_: function(selectedItem, defaultImages) {
340 if (!this.isAuthorCreditShown_(selectedItem)) 396 if (!this.isAuthorCreditShown_(selectedItem))
341 return ''; 397 return '';
342 398
343 assert(selectedItem.dataset.defaultImageIndex < defaultImages.length); 399 assert(selectedItem.dataset.defaultImageIndex < defaultImages.length);
344 return defaultImages[selectedItem.dataset.defaultImageIndex].website; 400 return defaultImages[selectedItem.dataset.defaultImageIndex].website;
345 }, 401 },
346 }); 402 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698