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 */ 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 updateItem: function(imageInfo, imageUrl, opt_title) { | 204 updateItem: function(imageInfo, imageUrl, opt_title) { |
205 var imageIndex = this.indexOf(imageInfo); | 205 var imageIndex = this.indexOf(imageInfo); |
206 var wasSelected = this.selectionModel.selectedIndex == imageIndex; | 206 var wasSelected = this.selectionModel.selectedIndex == imageIndex; |
207 this.removeItem(imageInfo); | 207 this.removeItem(imageInfo); |
208 var newInfo = this.addItem( | 208 var newInfo = this.addItem( |
209 imageUrl, | 209 imageUrl, |
210 opt_title === undefined ? imageInfo.title : opt_title, | 210 opt_title === undefined ? imageInfo.title : opt_title, |
211 imageInfo.clickHandler, | 211 imageInfo.clickHandler, |
212 imageIndex, | 212 imageIndex, |
213 imageInfo.decorateFn); | 213 imageInfo.decorateFn); |
| 214 // Update image data with the reset of the keys from the old data. |
| 215 for (k in imageInfo) { |
| 216 if (!(k in newInfo)) |
| 217 newInfo[k] = imageInfo[k]; |
| 218 } |
214 if (wasSelected) | 219 if (wasSelected) |
215 this.selectedItem = newInfo; | 220 this.selectedItem = newInfo; |
216 return newInfo; | 221 return newInfo; |
217 }, | 222 }, |
218 | 223 |
219 /** | 224 /** |
220 * Removes previously added image from the grid. | 225 * Removes previously added image from the grid. |
221 * @param {Object} imageInfo Image data returned from the addItem() call. | 226 * @param {Object} imageInfo Image data returned from the addItem() call. |
222 */ | 227 */ |
223 removeItem: function(imageInfo) { | 228 removeItem: function(imageInfo) { |
(...skipping 24 matching lines...) Expand all Loading... |
248 UserImagesGrid.ButtonImages = { | 253 UserImagesGrid.ButtonImages = { |
249 TAKE_PHOTO: 'chrome://theme/IDR_BUTTON_USER_IMAGE_TAKE_PHOTO', | 254 TAKE_PHOTO: 'chrome://theme/IDR_BUTTON_USER_IMAGE_TAKE_PHOTO', |
250 CHOOSE_FILE: 'chrome://theme/IDR_BUTTON_USER_IMAGE_CHOOSE_FILE', | 255 CHOOSE_FILE: 'chrome://theme/IDR_BUTTON_USER_IMAGE_CHOOSE_FILE', |
251 PROFILE_PICTURE: 'chrome://theme/IDR_PROFILE_PICTURE_LOADING' | 256 PROFILE_PICTURE: 'chrome://theme/IDR_PROFILE_PICTURE_LOADING' |
252 }; | 257 }; |
253 | 258 |
254 return { | 259 return { |
255 UserImagesGrid: UserImagesGrid | 260 UserImagesGrid: UserImagesGrid |
256 }; | 261 }; |
257 }); | 262 }); |
OLD | NEW |