| 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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 this.handleTakePhoto_(); | 468 this.handleTakePhoto_(); |
| 469 break; | 469 break; |
| 470 default: | 470 default: |
| 471 this.acceptImage_(); | 471 this.acceptImage_(); |
| 472 break; | 472 break; |
| 473 } | 473 } |
| 474 }, | 474 }, |
| 475 | 475 |
| 476 /** | 476 /** |
| 477 * Handles selection change. | 477 * Handles selection change. |
| 478 * @param {cr.Event} e Selection change event. |
| 478 * @private | 479 * @private |
| 479 */ | 480 */ |
| 480 handleSelect_: function() { | 481 handleSelect_: function(e) { |
| 481 var imageGrid = $('user-image-grid'); | 482 var imageGrid = $('user-image-grid'); |
| 482 if (imageGrid.selectionType == 'camera' && imageGrid.cameraLive) { | 483 if (imageGrid.selectionType == 'camera' && imageGrid.cameraLive) { |
| 483 // No current image selected. | 484 // No current image selected. |
| 484 $('ok-button').disabled = true; | 485 $('ok-button').disabled = true; |
| 485 } else { | 486 } else { |
| 486 $('ok-button').disabled = false; | 487 $('ok-button').disabled = false; |
| 487 chrome.send('selectImage', [imageGrid.selectedItemUrl]); | 488 chrome.send('selectImage', [imageGrid.selectedItemUrl]); |
| 488 } | 489 } |
| 489 // Start/stop camera on (de)selection. | 490 // Start/stop camera on (de)selection. |
| 490 if (!imageGrid.inProgramSelection) { | 491 if (!imageGrid.inProgramSelection && |
| 491 if (imageGrid.selectionType == 'camera' && !imageGrid.cameraOnline) { | 492 imageGrid.selectionType != e.oldSelectionType) { |
| 493 if (imageGrid.selectionType == 'camera') { |
| 492 // Programmatic selection of camera item is done in | 494 // Programmatic selection of camera item is done in |
| 493 // checkCameraPresence callback where streaming is started by itself. | 495 // checkCameraPresence callback where streaming is started by itself. |
| 494 imageGrid.checkCameraPresence( | 496 imageGrid.checkCameraPresence( |
| 495 function() { // When present. | 497 function() { // When present. |
| 496 // Start capture if camera is still the selected item. | 498 // Start capture if camera is still the selected item. |
| 497 return imageGrid.selectedItem == imageGrid.cameraImage; | 499 return imageGrid.selectedItem == imageGrid.cameraImage; |
| 498 }, | 500 }, |
| 499 function() { // When absent. | 501 function() { // When absent. |
| 500 return true; // Check again after some time. | 502 return true; // Check again after some time. |
| 501 }); | 503 }); |
| 502 } else if (imageGrid.selectionType != 'camera' && | 504 } else { |
| 503 imageGrid.cameraOnline) { | |
| 504 imageGrid.stopCamera(); | 505 imageGrid.stopCamera(); |
| 505 } | 506 } |
| 506 } | 507 } |
| 507 this.updateCaption_(); | 508 this.updateCaption_(); |
| 508 // Update image attribution text. | 509 // Update image attribution text. |
| 509 var image = imageGrid.selectedItem; | 510 var image = imageGrid.selectedItem; |
| 510 $('user-image-author-name').textContent = image.author; | 511 $('user-image-author-name').textContent = image.author; |
| 511 $('user-image-author-website').textContent = image.website; | 512 $('user-image-author-website').textContent = image.website; |
| 512 $('user-image-author-website').href = image.website; | 513 $('user-image-author-website').href = image.website; |
| 513 $('user-image-attribution').style.visibility = | 514 $('user-image-attribution').style.visibility = |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 ].forEach(function(name) { | 644 ].forEach(function(name) { |
| 644 UserImageScreen[name] = function(value) { | 645 UserImageScreen[name] = function(value) { |
| 645 $('user-image')[name + '_'](value); | 646 $('user-image')[name + '_'](value); |
| 646 }; | 647 }; |
| 647 }); | 648 }); |
| 648 | 649 |
| 649 return { | 650 return { |
| 650 UserImageScreen: UserImageScreen | 651 UserImageScreen: UserImageScreen |
| 651 }; | 652 }; |
| 652 }); | 653 }); |
| OLD | NEW |