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

Side by Side Diff: chrome/browser/resources/chromeos/user_images_grid.js

Issue 10376003: Improve accessibility of user image selection screen. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Manually verified with fresh Chrome OS build. Created 8 years, 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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('options', function() { 5 cr.define('options', function() {
6 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; 6 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel;
7 /** @const */ var Grid = cr.ui.Grid; 7 /** @const */ var Grid = cr.ui.Grid;
8 /** @const */ var GridItem = cr.ui.GridItem; 8 /** @const */ var GridItem = cr.ui.GridItem;
9 /** @const */ var GridSelectionController = cr.ui.GridSelectionController; 9 /** @const */ var GridSelectionController = cr.ui.GridSelectionController;
10 /** @const */ var ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; 10 /** @const */ var ListSingleSelectionModel = cr.ui.ListSingleSelectionModel;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 UserImagesGridItem.prototype = { 60 UserImagesGridItem.prototype = {
61 __proto__: GridItem.prototype, 61 __proto__: GridItem.prototype,
62 62
63 /** @inheritDoc */ 63 /** @inheritDoc */
64 decorate: function() { 64 decorate: function() {
65 GridItem.prototype.decorate.call(this); 65 GridItem.prototype.decorate.call(this);
66 var imageEl = cr.doc.createElement('img'); 66 var imageEl = cr.doc.createElement('img');
67 imageEl.src = this.dataItem.url; 67 imageEl.src = this.dataItem.url;
68 imageEl.title = this.dataItem.title || ''; 68 imageEl.title = this.dataItem.title || '';
69 var label = imageEl.src.replace(/(.*\/|\.png)/g, '');
70 imageEl.setAttribute('aria-label', label.replace(/_/g, ' '));
71 if (typeof this.dataItem.clickHandler == 'function') 69 if (typeof this.dataItem.clickHandler == 'function')
72 imageEl.addEventListener('mousedown', this.dataItem.clickHandler); 70 imageEl.addEventListener('mousedown', this.dataItem.clickHandler);
73 // Remove any garbage added by GridItem and ListItem decorators. 71 // Remove any garbage added by GridItem and ListItem decorators.
74 this.textContent = ''; 72 this.textContent = '';
75 this.appendChild(imageEl); 73 this.appendChild(imageEl);
76 if (typeof this.dataItem.decorateFn == 'function') 74 if (typeof this.dataItem.decorateFn == 'function')
77 this.dataItem.decorateFn(this); 75 this.dataItem.decorateFn(this);
76 this.setAttribute('role', 'option');
78 } 77 }
79 }; 78 };
80 79
81 /** 80 /**
82 * Creates a selection controller that wraps selection on grid ends 81 * Creates a selection controller that wraps selection on grid ends
83 * and translates Enter presses into 'activate' events. 82 * and translates Enter presses into 'activate' events.
84 * @param {cr.ui.ListSelectionModel} selectionModel The selection model to 83 * @param {cr.ui.ListSelectionModel} selectionModel The selection model to
85 * interact with. 84 * interact with.
86 * @param {cr.ui.Grid} grid The grid to interact with. 85 * @param {cr.ui.Grid} grid The grid to interact with.
87 * @constructor 86 * @constructor
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 134
136 /** @inheritDoc */ 135 /** @inheritDoc */
137 decorate: function() { 136 decorate: function() {
138 Grid.prototype.decorate.call(this); 137 Grid.prototype.decorate.call(this);
139 this.dataModel = new ArrayDataModel([]); 138 this.dataModel = new ArrayDataModel([]);
140 this.itemConstructor = UserImagesGridItem; 139 this.itemConstructor = UserImagesGridItem;
141 this.selectionModel = new ListSingleSelectionModel(); 140 this.selectionModel = new ListSingleSelectionModel();
142 this.inProgramSelection_ = false; 141 this.inProgramSelection_ = false;
143 this.addEventListener('dblclick', this.handleDblClick_.bind(this)); 142 this.addEventListener('dblclick', this.handleDblClick_.bind(this));
144 this.addEventListener('change', this.handleChange_.bind(this)); 143 this.addEventListener('change', this.handleChange_.bind(this));
144 this.setAttribute('role', 'listbox');
145 }, 145 },
146 146
147 /** 147 /**
148 * Handles double click on the image grid. 148 * Handles double click on the image grid.
149 * @param {Event} e Double click Event. 149 * @param {Event} e Double click Event.
150 * @private 150 * @private
151 */ 151 */
152 handleDblClick_: function(e) { 152 handleDblClick_: function(e) {
153 // If a child element is double-clicked and not the grid itself, handle 153 // If a child element is double-clicked and not the grid itself, handle
154 // this as 'Enter' keypress. 154 // this as 'Enter' keypress.
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 UserImagesGrid.ButtonImages = { 651 UserImagesGrid.ButtonImages = {
652 TAKE_PHOTO: 'chrome://theme/IDR_BUTTON_USER_IMAGE_TAKE_PHOTO', 652 TAKE_PHOTO: 'chrome://theme/IDR_BUTTON_USER_IMAGE_TAKE_PHOTO',
653 CHOOSE_FILE: 'chrome://theme/IDR_BUTTON_USER_IMAGE_CHOOSE_FILE', 653 CHOOSE_FILE: 'chrome://theme/IDR_BUTTON_USER_IMAGE_CHOOSE_FILE',
654 PROFILE_PICTURE: 'chrome://theme/IDR_PROFILE_PICTURE_LOADING' 654 PROFILE_PICTURE: 'chrome://theme/IDR_PROFILE_PICTURE_LOADING'
655 }; 655 };
656 656
657 return { 657 return {
658 UserImagesGrid: UserImagesGrid 658 UserImagesGrid: UserImagesGrid
659 }; 659 };
660 }); 660 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698