| 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 cr.define('options', function() { | 5 cr.define('options', function() { |
| 6 | 6 |
| 7 var OptionsPage = options.OptionsPage; | 7 var OptionsPage = options.OptionsPage; |
| 8 var UserImagesGrid = options.UserImagesGrid; | 8 var UserImagesGrid = options.UserImagesGrid; |
| 9 var ButtonImages = UserImagesGrid.ButtonImages; | 9 var ButtonImages = UserImagesGrid.ButtonImages; |
| 10 | 10 |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 handleImageSelected_: function() { | 385 handleImageSelected_: function() { |
| 386 var imageGrid = $('user-image-grid'); | 386 var imageGrid = $('user-image-grid'); |
| 387 var url = imageGrid.selectedItemUrl; | 387 var url = imageGrid.selectedItemUrl; |
| 388 // Ignore selection change caused by program itself and selection of one | 388 // Ignore selection change caused by program itself and selection of one |
| 389 // of the action buttons. | 389 // of the action buttons. |
| 390 if (!imageGrid.inProgramSelection && | 390 if (!imageGrid.inProgramSelection && |
| 391 url != ButtonImages.TAKE_PHOTO && url != ButtonImages.CHOOSE_FILE) { | 391 url != ButtonImages.TAKE_PHOTO && url != ButtonImages.CHOOSE_FILE) { |
| 392 chrome.send('selectImage', [url]); | 392 chrome.send('selectImage', [url]); |
| 393 } | 393 } |
| 394 // Start/stop camera on (de)selection. | 394 // Start/stop camera on (de)selection. |
| 395 if (!imageGrid.inProgramSelection) { | 395 if (!imageGrid.inProgramSelection && |
| 396 if (imageGrid.selectionType == 'camera' && !imageGrid.cameraOnline) { | 396 imageGrid.selectionType != e.oldSelectionType) { |
| 397 if (imageGrid.selectionType == 'camera') { |
| 397 imageGrid.checkCameraPresence( | 398 imageGrid.checkCameraPresence( |
| 398 function() { // When present. | 399 function() { // When present. |
| 399 // Start capture if camera is still the selected item. | 400 // Start capture if camera is still the selected item. |
| 400 return imageGrid.selectedItem == imageGrid.cameraImage; | 401 return imageGrid.selectedItem == imageGrid.cameraImage; |
| 401 }, | 402 }, |
| 402 function() { // When absent. | 403 function() { // When absent. |
| 403 return true; // Check again after some time. | 404 return true; // Check again after some time. |
| 404 }); | 405 }); |
| 405 } else if (imageGrid.selectionType != 'camera' && | 406 } else { |
| 406 imageGrid.cameraOnline) { | |
| 407 imageGrid.stopCamera(); | 407 imageGrid.stopCamera(); |
| 408 } | 408 } |
| 409 } | 409 } |
| 410 // Update image attribution text. | 410 // Update image attribution text. |
| 411 var image = imageGrid.selectedItem; | 411 var image = imageGrid.selectedItem; |
| 412 $('user-image-author-name').textContent = image.author; | 412 $('user-image-author-name').textContent = image.author; |
| 413 $('user-image-author-website').textContent = image.website; | 413 $('user-image-author-website').textContent = image.website; |
| 414 $('user-image-author-website').href = image.website; | 414 $('user-image-author-website').href = image.website; |
| 415 $('user-image-attribution').style.visibility = | 415 $('user-image-attribution').style.visibility = |
| 416 (image.author || image.website) ? 'visible' : 'hidden'; | 416 (image.author || image.website) ? 'visible' : 'hidden'; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 return instance[name + '_'].apply(instance, arguments); | 514 return instance[name + '_'].apply(instance, arguments); |
| 515 }; | 515 }; |
| 516 }); | 516 }); |
| 517 | 517 |
| 518 // Export | 518 // Export |
| 519 return { | 519 return { |
| 520 ChangePictureOptions: ChangePictureOptions | 520 ChangePictureOptions: ChangePictureOptions |
| 521 }; | 521 }; |
| 522 | 522 |
| 523 }); | 523 }); |
| OLD | NEW |