Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 | 8 |
| 9 // State variables. | 9 // State variables. |
| 10 var syncEnabled = false; | 10 var syncEnabled = false; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 }, | 93 }, |
| 94 | 94 |
| 95 /** | 95 /** |
| 96 * Updates the sync datatype checkboxes based on the selected sync option. | 96 * Updates the sync datatype checkboxes based on the selected sync option. |
| 97 * @private | 97 * @private |
| 98 */ | 98 */ |
| 99 updateSyncSelection_: function() { | 99 updateSyncSelection_: function() { |
| 100 var idx = $('sync-select').selectedIndex; | 100 var idx = $('sync-select').selectedIndex; |
| 101 var syncCheckboxes = $('sync-table').getElementsByTagName('input'); | 101 var syncCheckboxes = $('sync-table').getElementsByTagName('input'); |
| 102 if (idx == 0) { | 102 if (idx == 0) { |
| 103 // 'Choose what to sync.' | |
| 103 for (var i = 0; i < syncCheckboxes.length; i++) { | 104 for (var i = 0; i < syncCheckboxes.length; i++) { |
| 104 syncCheckboxes[i].disabled = false; | 105 syncCheckboxes[i].disabled = false; |
| 105 } | 106 } |
| 106 } else if (idx == 1) { | 107 } else if (idx == 1) { |
| 108 // 'Everything' is synced. | |
| 107 for (var i = 0; i < syncCheckboxes.length; i++) { | 109 for (var i = 0; i < syncCheckboxes.length; i++) { |
| 110 syncCheckboxes[i].checked = true; | |
| 111 syncCheckboxes[i].disabled = true; | |
| 112 | |
| 108 // Merely setting checked = true is not enough to trigger the pref | 113 // Merely setting checked = true is not enough to trigger the pref |
| 109 // being set; thus, we simulate the click. | 114 // being set; thus, we dispatch a change even to notify PrefCheckbox |
| 110 if (!syncCheckboxes[i].checked) | 115 // |checked| has changed. |
| 111 syncCheckboxes[i].click(); | 116 cr.dispatchSimpleEvent(syncCheckboxes[i], 'change') |
|
stuartmorgan
2011/01/20 18:19:42
Shouldn't you only send this if it wasn't previous
James Hawkins
2011/01/20 18:25:13
Done.
| |
| 112 | |
| 113 syncCheckboxes[i].disabled = true; | |
| 114 } | 117 } |
| 115 } | 118 } |
| 116 }, | 119 }, |
| 117 | 120 |
| 118 showStopSyncingOverlay_: function(event) { | 121 showStopSyncingOverlay_: function(event) { |
| 119 AlertOverlay.show(localStrings.getString('stop_syncing_title'), | 122 AlertOverlay.show(localStrings.getString('stop_syncing_title'), |
| 120 localStrings.getString('stop_syncing_explanation'), | 123 localStrings.getString('stop_syncing_explanation'), |
| 121 localStrings.getString('stop_syncing_confirm'), | 124 localStrings.getString('stop_syncing_confirm'), |
| 122 localStrings.getString('cancel'), | 125 localStrings.getString('cancel'), |
| 123 function() { chrome.send('stopSyncing'); }); | 126 function() { chrome.send('stopSyncing'); }); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 238 PersonalOptions.getInstance()[name + '_'](value); | 241 PersonalOptions.getInstance()[name + '_'](value); |
| 239 }; | 242 }; |
| 240 }); | 243 }); |
| 241 | 244 |
| 242 // Export | 245 // Export |
| 243 return { | 246 return { |
| 244 PersonalOptions: PersonalOptions | 247 PersonalOptions: PersonalOptions |
| 245 }; | 248 }; |
| 246 | 249 |
| 247 }); | 250 }); |
| OLD | NEW |