OLD | NEW |
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 ArrayDataModel = cr.ui.ArrayDataModel; | 6 const ArrayDataModel = cr.ui.ArrayDataModel; |
7 const Grid = cr.ui.Grid; | 7 const Grid = cr.ui.Grid; |
8 const GridItem = cr.ui.GridItem; | 8 const GridItem = cr.ui.GridItem; |
9 const GridSelectionController = cr.ui.GridSelectionController; | 9 const GridSelectionController = cr.ui.GridSelectionController; |
10 const ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; | 10 const ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 UserImagesGridItem.prototype = { | 26 UserImagesGridItem.prototype = { |
27 __proto__: GridItem.prototype, | 27 __proto__: GridItem.prototype, |
28 | 28 |
29 /** @inheritDoc */ | 29 /** @inheritDoc */ |
30 decorate: function() { | 30 decorate: function() { |
31 GridItem.prototype.decorate.call(this); | 31 GridItem.prototype.decorate.call(this); |
32 var imageEl = cr.doc.createElement('img'); | 32 var imageEl = cr.doc.createElement('img'); |
33 imageEl.src = this.dataItem.url; | 33 imageEl.src = this.dataItem.url; |
34 imageEl.title = this.dataItem.title || ''; | 34 imageEl.title = this.dataItem.title || ''; |
35 var label = imageEl.src.replace(/(.*\/|\.png)/g, ''); | |
36 imageEl.setAttribute('aria-label', label.replace(/_/g, ' ')); | |
37 if (typeof this.dataItem.clickHandler == 'function') | 35 if (typeof this.dataItem.clickHandler == 'function') |
38 imageEl.addEventListener('click', this.dataItem.clickHandler); | 36 imageEl.addEventListener('click', this.dataItem.clickHandler); |
39 // Remove any garbage added by GridItem and ListItem decorators. | 37 // Remove any garbage added by GridItem and ListItem decorators. |
40 this.textContent = ''; | 38 this.textContent = ''; |
41 this.appendChild(imageEl); | 39 this.appendChild(imageEl); |
42 if (typeof this.dataItem.decorateFn == 'function') | 40 if (typeof this.dataItem.decorateFn == 'function') |
43 this.dataItem.decorateFn(this); | 41 this.dataItem.decorateFn(this); |
44 } | 42 } |
45 }; | 43 }; |
46 | 44 |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 UserImagesGrid.ButtonImages = { | 246 UserImagesGrid.ButtonImages = { |
249 TAKE_PHOTO: 'chrome://theme/IDR_BUTTON_USER_IMAGE_TAKE_PHOTO', | 247 TAKE_PHOTO: 'chrome://theme/IDR_BUTTON_USER_IMAGE_TAKE_PHOTO', |
250 CHOOSE_FILE: 'chrome://theme/IDR_BUTTON_USER_IMAGE_CHOOSE_FILE', | 248 CHOOSE_FILE: 'chrome://theme/IDR_BUTTON_USER_IMAGE_CHOOSE_FILE', |
251 PROFILE_PICTURE: 'chrome://theme/IDR_PROFILE_PICTURE_LOADING' | 249 PROFILE_PICTURE: 'chrome://theme/IDR_PROFILE_PICTURE_LOADING' |
252 }; | 250 }; |
253 | 251 |
254 return { | 252 return { |
255 UserImagesGrid: UserImagesGrid | 253 UserImagesGrid: UserImagesGrid |
256 }; | 254 }; |
257 }); | 255 }); |
OLD | NEW |