OLD | NEW |
---|---|
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 Loading... | |
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_ == undefined) | |
Dan Beam
2016/02/22 20:41:31
nit: just if (!this.selectedItem_)
tommycli
2016/02/29 19:18:33
Done.
| |
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 do { | |
244 this.$.selector.selectPrevious(); | |
245 } while (this.selectedItem_.hidden); | |
Dan Beam
2016/02/22 20:41:31
what assurance do we have that this breaks out of
tommycli
2016/02/29 19:18:33
I added a comment: This loop always terminates bec
| |
246 | |
247 this.lastSelectedImageType_ = this.selectedItem_.dataset.type; | |
248 break; | |
Dan Beam
2016/02/22 20:41:31
nit: \n
tommycli
2016/02/29 19:18:33
Done.
| |
249 case 'down': | |
250 case 'right': | |
251 do { | |
252 this.$.selector.selectNext(); | |
253 } while (this.selectedItem_.hidden); | |
254 | |
255 this.lastSelectedImageType_ = this.selectedItem_.dataset.type; | |
256 break; | |
Dan Beam
2016/02/22 20:41:31
nit: \n
tommycli
2016/02/29 19:18:33
Done.
| |
257 case 'enter': | |
258 case 'space': | |
259 if (this.selectedItem_.dataset.type == 'camera') | |
260 this.$.camera.takePhoto(); | |
261 else if (this.selectedItem_.dataset.type == 'file') | |
262 settings.ChangePicturePrivateApi.chooseFile(); | |
263 else if (this.selectedItem_.dataset.type == 'old') | |
264 this.onTapDiscardOldImage_(); | |
265 break; | |
266 } | |
267 }, | |
268 | |
269 /** | |
222 * Handler for when the an image is activated. | 270 * Handler for when the an image is activated. |
223 * @param {!Event} event | 271 * @param {!Event} event |
224 * @private | 272 * @private |
225 */ | 273 */ |
226 onImageActivate_: function(event) { | 274 onImageActivate_: function(event) { |
227 var image = event.detail.item; | 275 var image = event.detail.item; |
228 this.lastSelectedImageType_ = image.dataset.type; | 276 this.lastSelectedImageType_ = image.dataset.type; |
229 this.selectImage_(image); | 277 this.selectImage_(image); |
230 }, | 278 }, |
231 | 279 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
337 * @private | 385 * @private |
338 */ | 386 */ |
339 getAuthorWebsite_: function(selectedItem, defaultImages) { | 387 getAuthorWebsite_: function(selectedItem, defaultImages) { |
340 if (!this.isAuthorCreditShown_(selectedItem)) | 388 if (!this.isAuthorCreditShown_(selectedItem)) |
341 return ''; | 389 return ''; |
342 | 390 |
343 assert(selectedItem.dataset.defaultImageIndex < defaultImages.length); | 391 assert(selectedItem.dataset.defaultImageIndex < defaultImages.length); |
344 return defaultImages[selectedItem.dataset.defaultImageIndex].website; | 392 return defaultImages[selectedItem.dataset.defaultImageIndex].website; |
345 }, | 393 }, |
346 }); | 394 }); |
OLD | NEW |