| 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 21 matching lines...) Expand all Loading... |
| 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 /** |
| 287 * Appends received images to the list. | 289 * Appends received images to the list. |
| 288 * @param {Array.<string>} images An array of URLs to user images. | 290 * @param {Array.<Object>} imageInfos An array of data about user images. |
| 289 * @private | 291 * @private |
| 290 */ | 292 */ |
| 291 setUserImages_: function(images) { | 293 setUserImages_: function(imageInfos) { |
| 292 var imageGrid = $('user-image-grid'); | 294 var imageGrid = $('user-image-grid'); |
| 293 for (var i = 0, url; url = images[i]; i++) | 295 for (var i = 0, imageInfo; imageInfo = imageInfos[i]; i++) { |
| 294 imageGrid.addItem(url); | 296 imageGrid.addItem(imageInfo.url, imageInfo.title).type = 'default'; |
| 297 } |
| 295 }, | 298 }, |
| 296 | 299 |
| 297 /** | 300 /** |
| 298 * Selects user image with the given URL. | 301 * Selects user image with the given URL. |
| 299 * @param {string} url URL of the image to select. | 302 * @param {string} url URL of the image to select. |
| 300 * @private | 303 * @private |
| 301 */ | 304 */ |
| 302 setSelectedImage_: function(url) { | 305 setSelectedImage_: function(url) { |
| 303 var imageGrid = $('user-image-grid'); | 306 var imageGrid = $('user-image-grid'); |
| 304 imageGrid.selectedItemUrl = url; | 307 imageGrid.selectedItemUrl = url; |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 setProfileImage_: function(imageUrl) { | 528 setProfileImage_: function(imageUrl) { |
| 526 this.profileImageLoading = false; | 529 this.profileImageLoading = false; |
| 527 if (imageUrl !== null) { | 530 if (imageUrl !== null) { |
| 528 this.profileImage_ = | 531 this.profileImage_ = |
| 529 $('user-image-grid').updateItem(this.profileImage_, imageUrl); | 532 $('user-image-grid').updateItem(this.profileImage_, imageUrl); |
| 530 } | 533 } |
| 531 }, | 534 }, |
| 532 | 535 |
| 533 /** | 536 /** |
| 534 * Appends received images to the list. | 537 * Appends received images to the list. |
| 535 * @param {Array.<string>} images An array of URLs to user images. | 538 * @param {Array.<Object>} imageInfos An array of data about user images. |
| 536 * @private | 539 * @private |
| 537 */ | 540 */ |
| 538 setUserImages_: function(images) { | 541 setUserImages_: function(imageInfos) { |
| 539 var imageGrid = $('user-image-grid'); | 542 var imageGrid = $('user-image-grid'); |
| 540 for (var i = 0, url; url = images[i]; i++) | 543 for (var i = 0, imageInfo; imageInfo = imageInfos[i]; i++) { |
| 541 imageGrid.addItem(url).type = 'default'; | 544 imageGrid.addItem(imageInfo.url, imageInfo.title).type = 'default'; |
| 545 } |
| 542 }, | 546 }, |
| 543 | 547 |
| 544 /** | 548 /** |
| 545 * Selects user image with the given URL. | 549 * Selects user image with the given URL. |
| 546 * @param {string} url URL of the image to select. | 550 * @param {string} url URL of the image to select. |
| 547 * @private | 551 * @private |
| 548 */ | 552 */ |
| 549 setSelectedImage_: function(url) { | 553 setSelectedImage_: function(url) { |
| 550 var imageGrid = $('user-image-grid'); | 554 var imageGrid = $('user-image-grid'); |
| 551 imageGrid.selectedItemUrl = url; | 555 imageGrid.selectedItemUrl = url; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 ].forEach(function(name) { | 593 ].forEach(function(name) { |
| 590 UserImageScreen[name] = function(value) { | 594 UserImageScreen[name] = function(value) { |
| 591 $('user-image')[name + '_'](value); | 595 $('user-image')[name + '_'](value); |
| 592 }; | 596 }; |
| 593 }); | 597 }); |
| 594 | 598 |
| 595 return { | 599 return { |
| 596 UserImageScreen: UserImageScreen | 600 UserImageScreen: UserImageScreen |
| 597 }; | 601 }; |
| 598 }); | 602 }); |
| OLD | NEW |