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 /** | 5 /** |
6 * @fileoverview Oobe user image screen implementation. | 6 * @fileoverview Oobe user image screen implementation. |
7 */ | 7 */ |
8 | 8 |
9 cr.define('oobe', function() { | 9 cr.define('oobe', function() { |
10 var UserImagesGrid = options.UserImagesGrid; | 10 var UserImagesGrid = options.UserImagesGrid; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 62 |
63 // Whether a button image is selected. | 63 // Whether a button image is selected. |
64 this.buttonImageSelected_ = false; | 64 this.buttonImageSelected_ = false; |
65 | 65 |
66 // Photo image data (if present). | 66 // Photo image data (if present). |
67 this.photoImage_ = null; | 67 this.photoImage_ = null; |
68 | 68 |
69 // Profile image data (if present). | 69 // Profile image data (if present). |
70 this.profileImage_ = imageGrid.addItem( | 70 this.profileImage_ = imageGrid.addItem( |
71 ButtonImages.PROFILE_PICTURE, | 71 ButtonImages.PROFILE_PICTURE, |
72 undefined, undefined, undefined, | 72 localStrings.getString('profilePhoto'), |
| 73 undefined, |
| 74 undefined, |
73 function(el) { // Custom decorator for Profile image element. | 75 function(el) { // Custom decorator for Profile image element. |
74 var spinner = el.ownerDocument.createElement('div'); | 76 var spinner = el.ownerDocument.createElement('div'); |
75 spinner.className = 'spinner'; | 77 spinner.className = 'spinner'; |
76 var spinnerBg = el.ownerDocument.createElement('div'); | 78 var spinnerBg = el.ownerDocument.createElement('div'); |
77 spinnerBg.className = 'spinner-bg'; | 79 spinnerBg.className = 'spinner-bg'; |
78 spinnerBg.appendChild(spinner); | 80 spinnerBg.appendChild(spinner); |
79 el.appendChild(spinnerBg); | 81 el.appendChild(spinnerBg); |
80 el.id = 'profile-image'; | 82 el.id = 'profile-image'; |
81 }); | 83 }); |
82 this.profileImageUrl_ = this.profileImage_.url; | 84 this.profileImageUrl_ = this.profileImage_.url; |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 /** | 238 /** |
237 * Notifies about camera presence change. | 239 * Notifies about camera presence change. |
238 * @param {boolean} present Whether a camera is present or not. | 240 * @param {boolean} present Whether a camera is present or not. |
239 * @private | 241 * @private |
240 */ | 242 */ |
241 setCameraPresent_: function(present) { | 243 setCameraPresent_: function(present) { |
242 var imageGrid = $('user-image-grid'); | 244 var imageGrid = $('user-image-grid'); |
243 if (present && !this.takePhotoButton_) { | 245 if (present && !this.takePhotoButton_) { |
244 this.takePhotoButton_ = imageGrid.addItem( | 246 this.takePhotoButton_ = imageGrid.addItem( |
245 ButtonImages.TAKE_PHOTO, | 247 ButtonImages.TAKE_PHOTO, |
246 undefined, | 248 localStrings.getString('takePhoto'), |
247 this.handleTakePhoto_.bind(this), | 249 this.handleTakePhoto_.bind(this), |
248 0); | 250 0); |
249 } else if (!present && this.takePhotoButton_) { | 251 } else if (!present && this.takePhotoButton_) { |
250 imageGrid.removeItem(this.takePhotoButton_); | 252 imageGrid.removeItem(this.takePhotoButton_); |
251 this.takePhotoButton_ = null; | 253 this.takePhotoButton_ = null; |
252 } | 254 } |
253 }, | 255 }, |
254 | 256 |
255 /** | 257 /** |
256 * Adds or updates image with user photo and sets it as preview. | 258 * Adds or updates image with user photo and sets it as preview. |
(...skipping 20 matching lines...) Expand all Loading... |
277 this.profileImageLoading = false; | 279 this.profileImageLoading = false; |
278 if (imageUrl !== null) { | 280 if (imageUrl !== null) { |
279 this.profileImagePresent_ = true; | 281 this.profileImagePresent_ = true; |
280 this.profileImageUrl_ = imageUrl; | 282 this.profileImageUrl_ = imageUrl; |
281 this.profileImage_ = | 283 this.profileImage_ = |
282 $('user-image-grid').updateItem(this.profileImage_, imageUrl); | 284 $('user-image-grid').updateItem(this.profileImage_, imageUrl); |
283 } | 285 } |
284 }, | 286 }, |
285 | 287 |
286 /** | 288 /** |
| 289 <<<<<<< HEAD |
287 * Appends default images to the image grid. Should only be called once. | 290 * Appends default images to the image grid. Should only be called once. |
288 * @param {Array.<{url: string, author: string, website: string}>} images | 291 * @param {Array.<{url: string, author: string, website: string, |
289 * An array of default images data, including URL, author and website. | 292 * title: string}>} images An array of default images data, |
| 293 * including URL, title, author and website. |
290 * @private | 294 * @private |
291 */ | 295 */ |
292 setDefaultImages_: function(images) { | 296 setDefaultImages_: function(images) { |
293 var imageGrid = $('user-image-grid'); | 297 var imageGrid = $('user-image-grid'); |
294 for (var i = 0, data; data = imagesData[i]; i++) { | 298 for (var i = 0, data; data = imagesData[i]; i++) { |
295 imageGrid.addItem(data.url); | 299 imageGrid.addItem(data.url, data.title); |
296 } | 300 } |
297 }, | 301 }, |
298 | 302 |
299 /** | 303 /** |
300 * Selects user image with the given URL. | 304 * Selects user image with the given URL. |
301 * @param {string} url URL of the image to select. | 305 * @param {string} url URL of the image to select. |
302 * @private | 306 * @private |
303 */ | 307 */ |
304 setSelectedImage_: function(url) { | 308 setSelectedImage_: function(url) { |
305 var imageGrid = $('user-image-grid'); | 309 var imageGrid = $('user-image-grid'); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 | 545 |
542 /** | 546 /** |
543 * Appends default images to the image grid. Should only be called once. | 547 * Appends default images to the image grid. Should only be called once. |
544 * @param {Array.<{url: string, author: string, website: string}>} images | 548 * @param {Array.<{url: string, author: string, website: string}>} images |
545 * An array of default images data, including URL, author and website. | 549 * An array of default images data, including URL, author and website. |
546 * @private | 550 * @private |
547 */ | 551 */ |
548 setDefaultImages_: function(imagesData) { | 552 setDefaultImages_: function(imagesData) { |
549 var imageGrid = $('user-image-grid'); | 553 var imageGrid = $('user-image-grid'); |
550 for (var i = 0, data; data = imagesData[i]; i++) { | 554 for (var i = 0, data; data = imagesData[i]; i++) { |
551 var item = imageGrid.addItem(data.url); | 555 var item = imageGrid.addItem(data.url, data.title); |
552 item.type = 'default'; | 556 item.type = 'default'; |
553 item.author = data.author || ''; | 557 item.author = data.author || ''; |
554 item.website = data.website || ''; | 558 item.website = data.website || ''; |
555 } | 559 } |
556 }, | 560 }, |
557 | 561 |
558 /** | 562 /** |
559 * Selects user image with the given URL. | 563 * Selects user image with the given URL. |
560 * @param {string} url URL of the image to select. | 564 * @param {string} url URL of the image to select. |
561 * @private | 565 * @private |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 ].forEach(function(name) { | 607 ].forEach(function(name) { |
604 UserImageScreen[name] = function(value) { | 608 UserImageScreen[name] = function(value) { |
605 $('user-image')[name + '_'](value); | 609 $('user-image')[name + '_'](value); |
606 }; | 610 }; |
607 }); | 611 }); |
608 | 612 |
609 return { | 613 return { |
610 UserImageScreen: UserImageScreen | 614 UserImageScreen: UserImageScreen |
611 }; | 615 }; |
612 }); | 616 }); |
OLD | NEW |