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