Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 30 matching lines...) Expand all Loading... | |
| 41 /** | 41 /** |
| 42 * Initializes ChangePictureOptions page. | 42 * Initializes ChangePictureOptions page. |
| 43 */ | 43 */ |
| 44 initializePage: function() { | 44 initializePage: function() { |
| 45 // Call base class implementation to start preferences initialization. | 45 // Call base class implementation to start preferences initialization. |
| 46 OptionsPage.prototype.initializePage.call(this); | 46 OptionsPage.prototype.initializePage.call(this); |
| 47 | 47 |
| 48 var imageGrid = $('images-grid'); | 48 var imageGrid = $('images-grid'); |
| 49 UserImagesGrid.decorate(imageGrid); | 49 UserImagesGrid.decorate(imageGrid); |
| 50 | 50 |
| 51 imageGrid.addEventListener('change', function(e) { | 51 imageGrid.addEventListener('change', |
| 52 // Ignore programmatical selection. | 52 this.handleImageSelected_.bind(this)); |
| 53 if (!imageGrid.inProgramSelection) { | |
| 54 // Button selections will be ignored by Chrome handler. | |
| 55 chrome.send('selectImage', [this.selectedItemUrl || '']); | |
| 56 } | |
| 57 }); | |
| 58 imageGrid.addEventListener('activate', | 53 imageGrid.addEventListener('activate', |
| 59 this.handleImageActivated_.bind(this)); | 54 this.handleImageActivated_.bind(this)); |
| 60 imageGrid.addEventListener('dblclick', | 55 imageGrid.addEventListener('dblclick', |
| 61 this.handleImageDblClick_.bind(this)); | 56 this.handleImageDblClick_.bind(this)); |
| 62 | 57 |
| 63 // Add the "Choose file" button. | 58 // Add the "Choose file" button. |
| 64 imageGrid.addItem(ButtonImages.CHOOSE_FILE, | 59 imageGrid.addItem(ButtonImages.CHOOSE_FILE, |
| 65 localStrings.getString('chooseFile'), | 60 localStrings.getString('chooseFile'), |
| 66 this.handleChooseFile_.bind(this)); | 61 this.handleChooseFile_.bind(this)); |
| 67 | 62 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 /** | 108 /** |
| 114 * Handles "Choose a file" button activation. | 109 * Handles "Choose a file" button activation. |
| 115 * @private | 110 * @private |
| 116 */ | 111 */ |
| 117 handleChooseFile_: function() { | 112 handleChooseFile_: function() { |
| 118 chrome.send('chooseFile'); | 113 chrome.send('chooseFile'); |
| 119 this.closePage_(); | 114 this.closePage_(); |
| 120 }, | 115 }, |
| 121 | 116 |
| 122 /** | 117 /** |
| 118 * Handles image selection change. | |
| 119 * @private | |
| 120 */ | |
| 121 handleImageSelected_: function() { | |
| 122 var imageGrid = $('images-grid'); | |
| 123 var url = imageGrid.selectedItemUrl; | |
| 124 // Ignore empty, programmatical and button selection. | |
|
whywhat
2011/12/08 17:27:50
I'd rather tell reader here what empty url and pro
Ivan Korotkov
2011/12/09 09:30:23
Done.
| |
| 125 if (!imageGrid.inProgramSelection && | |
|
whywhat
2011/12/08 17:27:50
I'd reorder and reformat like this:
if (url &&
Ivan Korotkov
2011/12/09 09:30:23
Done.
| |
| 126 url && ButtonImageUrls.indexOf(url) == -1) { | |
| 127 chrome.send('selectImage', [url]); | |
| 128 } | |
| 129 }, | |
| 130 | |
| 131 /** | |
| 123 * Handles image activation (by pressing Enter). | 132 * Handles image activation (by pressing Enter). |
| 124 * @private | 133 * @private |
| 125 */ | 134 */ |
| 126 handleImageActivated_: function() { | 135 handleImageActivated_: function() { |
| 127 switch ($('images-grid').selectedItemUrl) { | 136 switch ($('images-grid').selectedItemUrl) { |
| 128 case ButtonImages.TAKE_PHOTO: | 137 case ButtonImages.TAKE_PHOTO: |
| 129 this.handleTakePhoto_(); | 138 this.handleTakePhoto_(); |
| 130 break; | 139 break; |
| 131 case ButtonImages.CHOOSE_FILE: | 140 case ButtonImages.CHOOSE_FILE: |
| 132 this.handleChooseFile_(); | 141 this.handleChooseFile_(); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 }; | 253 }; |
| 245 }); | 254 }); |
| 246 | 255 |
| 247 // Export | 256 // Export |
| 248 return { | 257 return { |
| 249 ChangePictureOptions: ChangePictureOptions | 258 ChangePictureOptions: ChangePictureOptions |
| 250 }; | 259 }; |
| 251 | 260 |
| 252 }); | 261 }); |
| 253 | 262 |
| OLD | NEW |