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

Side by Side Diff: chrome/browser/resources/chromeos/login/oobe_screen_user_image.js

Issue 10850036: [cros] Add attribution (author & website) strings to stock user images. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compile fix Created 8 years, 4 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 /** 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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 this.profileImageLoading = false; 277 this.profileImageLoading = false;
278 if (imageUrl !== null) { 278 if (imageUrl !== null) {
279 this.profileImagePresent_ = true; 279 this.profileImagePresent_ = true;
280 this.profileImageUrl_ = imageUrl; 280 this.profileImageUrl_ = imageUrl;
281 this.profileImage_ = 281 this.profileImage_ =
282 $('user-image-grid').updateItem(this.profileImage_, imageUrl); 282 $('user-image-grid').updateItem(this.profileImage_, imageUrl);
283 } 283 }
284 }, 284 },
285 285
286 /** 286 /**
287 * Appends received images to the list. 287 * Appends default images to the image grid. Should only be called once.
288 * @param {Array.<string>} images An array of URLs to user images. 288 * @param {Array.<{url: string, author: string, website: string}>} images
289 * An array of default images data, including URL, author and website.
289 * @private 290 * @private
290 */ 291 */
291 setUserImages_: function(images) { 292 setDefaultImages_: function(images) {
292 var imageGrid = $('user-image-grid'); 293 var imageGrid = $('user-image-grid');
293 for (var i = 0, url; url = images[i]; i++) 294 for (var i = 0, data; data = imagesData[i]; i++) {
294 imageGrid.addItem(url); 295 imageGrid.addItem(data.url);
296 }
295 }, 297 },
296 298
297 /** 299 /**
298 * Selects user image with the given URL. 300 * Selects user image with the given URL.
299 * @param {string} url URL of the image to select. 301 * @param {string} url URL of the image to select.
300 * @private 302 * @private
301 */ 303 */
302 setSelectedImage_: function(url) { 304 setSelectedImage_: function(url) {
303 var imageGrid = $('user-image-grid'); 305 var imageGrid = $('user-image-grid');
304 imageGrid.selectedItemUrl = url; 306 imageGrid.selectedItemUrl = url;
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 handleSelect_: function() { 466 handleSelect_: function() {
465 var imageGrid = $('user-image-grid'); 467 var imageGrid = $('user-image-grid');
466 if (imageGrid.selectionType == 'camera' && imageGrid.cameraLive) { 468 if (imageGrid.selectionType == 'camera' && imageGrid.cameraLive) {
467 // No current image selected. 469 // No current image selected.
468 $('ok-button').disabled = true; 470 $('ok-button').disabled = true;
469 } else { 471 } else {
470 $('ok-button').disabled = false; 472 $('ok-button').disabled = false;
471 chrome.send('selectImage', [imageGrid.selectedItemUrl]); 473 chrome.send('selectImage', [imageGrid.selectedItemUrl]);
472 } 474 }
473 this.updateCaption_(); 475 this.updateCaption_();
476 // Update image attribution text.
477 var image = imageGrid.selectedItem;
478 $('user-image-author-name').textContent = image.author;
Nikita (slow) 2012/08/03 17:52:54 image.author / image.website might be undefined fo
Ivan Korotkov 2012/08/03 20:13:41 Done.
479 $('user-image-author-website').textContent = image.website;
480 $('user-image-author-website').href = image.website;
481 $('user-image-attribution').style.visibility =
482 (image.author || image.website) ? 'visible' : 'hidden';
474 }, 483 },
475 484
476 /** 485 /**
477 * Handle photo capture from the live camera stream. 486 * Handle photo capture from the live camera stream.
478 */ 487 */
479 handleTakePhoto_: function(e) { 488 handleTakePhoto_: function(e) {
480 $('user-image-grid').takePhoto(function(photoURL) { 489 $('user-image-grid').takePhoto(function(photoURL) {
481 chrome.send('photoTaken', [photoURL]); 490 chrome.send('photoTaken', [photoURL]);
482 }); 491 });
483 }, 492 },
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 */ 533 */
525 setProfileImage_: function(imageUrl) { 534 setProfileImage_: function(imageUrl) {
526 this.profileImageLoading = false; 535 this.profileImageLoading = false;
527 if (imageUrl !== null) { 536 if (imageUrl !== null) {
528 this.profileImage_ = 537 this.profileImage_ =
529 $('user-image-grid').updateItem(this.profileImage_, imageUrl); 538 $('user-image-grid').updateItem(this.profileImage_, imageUrl);
530 } 539 }
531 }, 540 },
532 541
533 /** 542 /**
534 * Appends received images to the list. 543 * Appends default images to the image grid. Should only be called once.
535 * @param {Array.<string>} images An array of URLs to user images. 544 * @param {Array.<{url: string, author: string, website: string}>} images
545 * An array of default images data, including URL, author and website.
536 * @private 546 * @private
537 */ 547 */
538 setUserImages_: function(images) { 548 setDefaultImages_: function(imagesData) {
539 var imageGrid = $('user-image-grid'); 549 var imageGrid = $('user-image-grid');
540 for (var i = 0, url; url = images[i]; i++) 550 for (var i = 0, data; data = imagesData[i]; i++) {
541 imageGrid.addItem(url).type = 'default'; 551 var item = imageGrid.addItem(data.url);
552 item.type = 'default';
553 item.author = data.author;
Nikita (slow) 2012/08/03 17:52:54 Add check that data.author / data.website is defin
Ivan Korotkov 2012/08/03 20:13:41 Done.
554 item.website = data.website;
555 }
542 }, 556 },
543 557
544 /** 558 /**
545 * Selects user image with the given URL. 559 * Selects user image with the given URL.
546 * @param {string} url URL of the image to select. 560 * @param {string} url URL of the image to select.
547 * @private 561 * @private
548 */ 562 */
549 setSelectedImage_: function(url) { 563 setSelectedImage_: function(url) {
550 var imageGrid = $('user-image-grid'); 564 var imageGrid = $('user-image-grid');
551 imageGrid.selectedItemUrl = url; 565 imageGrid.selectedItemUrl = url;
(...skipping 22 matching lines...) Expand all
574 * @private 588 * @private
575 */ 589 */
576 updateProfileImageCaption_: function() { 590 updateProfileImageCaption_: function() {
577 this.profileImageCaption = localStrings.getString( 591 this.profileImageCaption = localStrings.getString(
578 this.profileImageLoading_ ? 'profilePhotoLoading' : 'profilePhoto'); 592 this.profileImageLoading_ ? 'profilePhotoLoading' : 'profilePhoto');
579 } 593 }
580 }; 594 };
581 595
582 // Forward public APIs to private implementations. 596 // Forward public APIs to private implementations.
583 [ 597 [
598 'setDefaultImages',
584 'setCameraPresent', 599 'setCameraPresent',
585 'setProfileImage', 600 'setProfileImage',
586 'setSelectedImage', 601 'setSelectedImage',
587 'setUserImages',
588 'setUserPhoto', 602 'setUserPhoto',
589 ].forEach(function(name) { 603 ].forEach(function(name) {
590 UserImageScreen[name] = function(value) { 604 UserImageScreen[name] = function(value) {
591 $('user-image')[name + '_'](value); 605 $('user-image')[name + '_'](value);
592 }; 606 };
593 }); 607 });
594 608
595 return { 609 return {
596 UserImageScreen: UserImageScreen 610 UserImageScreen: UserImageScreen
597 }; 611 };
598 }); 612 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698