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

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

Issue 10532048: [cros] Initial WebRTC-enabled implementation of user image picker on OOBE. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revert ImageDecoder changes. Created 8 years, 6 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) {
224 var index = this.indexOf(imageInfo); 229 var index = this.indexOf(imageInfo);
225 if (index != -1) { 230 if (index != -1) {
231 var wasSelected = this.selectionModel.selectedIndex == index;
226 this.inProgramSelection_ = true; 232 this.inProgramSelection_ = true;
227 this.dataModel.splice(index, 1); 233 this.dataModel.splice(index, 1);
234 if (wasSelected) {
235 // If item removed was selected, select the item next to it.
236 this.selectedItem = this.dataModel.item(
237 Math.min(this.dataModel.length - 1, index));
238 }
228 this.inProgramSelection_ = false; 239 this.inProgramSelection_ = false;
229 } 240 }
230 }, 241 },
231 242
232 /** 243 /**
233 * Forces re-display, size re-calculation and focuses grid. 244 * Forces re-display, size re-calculation and focuses grid.
234 */ 245 */
235 updateAndFocus: function() { 246 updateAndFocus: function() {
236 // Recalculate the measured item size. 247 // Recalculate the measured item size.
237 this.measured_ = null; 248 this.measured_ = null;
(...skipping 10 matching lines...) Expand all
248 UserImagesGrid.ButtonImages = { 259 UserImagesGrid.ButtonImages = {
249 TAKE_PHOTO: 'chrome://theme/IDR_BUTTON_USER_IMAGE_TAKE_PHOTO', 260 TAKE_PHOTO: 'chrome://theme/IDR_BUTTON_USER_IMAGE_TAKE_PHOTO',
250 CHOOSE_FILE: 'chrome://theme/IDR_BUTTON_USER_IMAGE_CHOOSE_FILE', 261 CHOOSE_FILE: 'chrome://theme/IDR_BUTTON_USER_IMAGE_CHOOSE_FILE',
251 PROFILE_PICTURE: 'chrome://theme/IDR_PROFILE_PICTURE_LOADING' 262 PROFILE_PICTURE: 'chrome://theme/IDR_PROFILE_PICTURE_LOADING'
252 }; 263 };
253 264
254 return { 265 return {
255 UserImagesGrid: UserImagesGrid 266 UserImagesGrid: UserImagesGrid
256 }; 267 };
257 }); 268 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698