| 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 22 matching lines...) Expand all Loading... |
| 33 var self = this; | 33 var self = this; |
| 34 $('sync-action-link').onclick = function(event) { | 34 $('sync-action-link').onclick = function(event) { |
| 35 chrome.send('showSyncLoginDialog'); | 35 chrome.send('showSyncLoginDialog'); |
| 36 }; | 36 }; |
| 37 $('start-stop-sync').onclick = function(event) { | 37 $('start-stop-sync').onclick = function(event) { |
| 38 if (self.syncSetupCompleted) | 38 if (self.syncSetupCompleted) |
| 39 self.showStopSyncingOverlay_(); | 39 self.showStopSyncingOverlay_(); |
| 40 else | 40 else |
| 41 chrome.send('showSyncLoginDialog'); | 41 chrome.send('showSyncLoginDialog'); |
| 42 }; | 42 }; |
| 43 $('customize-sync').onclick = function(event) { |
| 44 chrome.send('showCustomizeSyncDialog'); |
| 45 }; |
| 43 $('privacy-dashboard-link').onclick = function(event) { | 46 $('privacy-dashboard-link').onclick = function(event) { |
| 44 chrome.send('openPrivacyDashboardTabAndActivate'); | 47 chrome.send('openPrivacyDashboardTabAndActivate'); |
| 45 }; | 48 }; |
| 46 $('manage-passwords').onclick = function(event) { | 49 $('manage-passwords').onclick = function(event) { |
| 47 OptionsPage.showPageByName('passwordManager'); | 50 OptionsPage.showPageByName('passwordManager'); |
| 48 OptionsPage.showTab($('passwords-nav-tab')); | 51 OptionsPage.showTab($('passwords-nav-tab')); |
| 49 chrome.send('coreOptionsUserMetricsAction', | 52 chrome.send('coreOptionsUserMetricsAction', |
| 50 ['Options_ShowPasswordManager']); | 53 ['Options_ShowPasswordManager']); |
| 51 }; | 54 }; |
| 52 $('autofill-settings').onclick = function(event) { | 55 $('autofill-settings').onclick = function(event) { |
| 53 OptionsPage.showPageByName('autoFillOptions'); | 56 OptionsPage.showPageByName('autoFillOptions'); |
| 54 chrome.send('coreOptionsUserMetricsAction', | 57 chrome.send('coreOptionsUserMetricsAction', |
| 55 ['Options_ShowAutoFillSettings']); | 58 ['Options_ShowAutoFillSettings']); |
| 56 }; | 59 }; |
| 57 $('themes-reset').onclick = function(event) { | 60 $('themes-reset').onclick = function(event) { |
| 58 chrome.send('themesReset'); | 61 chrome.send('themesReset'); |
| 59 }; | 62 }; |
| 60 | 63 |
| 61 // Initialize sync select control. | |
| 62 $('sync-select').onchange = function(event) { | |
| 63 self.updateSyncSelection_(); | |
| 64 } | |
| 65 | |
| 66 var syncCheckboxes = $('sync-table').getElementsByTagName('input'); | |
| 67 for (var i = 0; i < syncCheckboxes.length; i++) { | |
| 68 if (syncCheckboxes[i].type == "checkbox") { | |
| 69 syncCheckboxes[i].onclick = function(event) { | |
| 70 chrome.send('updatePreferredDataTypes'); | |
| 71 }; | |
| 72 } | |
| 73 } | |
| 74 | |
| 75 if (!cr.isChromeOS) { | 64 if (!cr.isChromeOS) { |
| 76 $('import-data').onclick = function(event) { | 65 $('import-data').onclick = function(event) { |
| 77 OptionsPage.showOverlay('importDataOverlay'); | 66 OptionsPage.showOverlay('importDataOverlay'); |
| 78 chrome.send('coreOptionsUserMetricsAction', ['Import_ShowDlg']); | 67 chrome.send('coreOptionsUserMetricsAction', ['Import_ShowDlg']); |
| 79 }; | 68 }; |
| 80 | 69 |
| 81 if (navigator.platform.match(/linux|BSD/i)) { | 70 if (navigator.platform.match(/linux|BSD/i)) { |
| 82 $('themes-GTK-button').onclick = function(event) { | 71 $('themes-GTK-button').onclick = function(event) { |
| 83 chrome.send('themesSetGTK'); | 72 chrome.send('themesSetGTK'); |
| 84 }; | 73 }; |
| 85 } | 74 } |
| 86 } else { | 75 } else { |
| 87 chrome.send('loadAccountPicture'); | 76 chrome.send('loadAccountPicture'); |
| 88 } | 77 } |
| 89 | 78 |
| 90 // Disable the screen lock checkbox for the guest mode. | 79 // Disable the screen lock checkbox for the guest mode. |
| 91 if (cr.commandLine.options['--bwsi']) | 80 if (cr.commandLine.options['--bwsi']) |
| 92 $('enable-screen-lock').disabled = true; | 81 $('enable-screen-lock').disabled = true; |
| 93 }, | 82 }, |
| 94 | 83 |
| 95 /** | |
| 96 * Updates the sync datatype checkboxes based on the selected sync option. | |
| 97 * @private | |
| 98 */ | |
| 99 updateSyncSelection_: function() { | |
| 100 var idx = $('sync-select').selectedIndex; | |
| 101 var syncCheckboxes = $('sync-table').getElementsByTagName('input'); | |
| 102 if (idx == 0) { | |
| 103 // 'Choose what to sync.' | |
| 104 for (var i = 0; i < syncCheckboxes.length; i++) { | |
| 105 syncCheckboxes[i].disabled = false; | |
| 106 } | |
| 107 } else if (idx == 1) { | |
| 108 // 'Everything' is synced. | |
| 109 for (var i = 0; i < syncCheckboxes.length; i++) { | |
| 110 if (!syncCheckboxes[i].checked) { | |
| 111 syncCheckboxes[i].checked = true; | |
| 112 | |
| 113 // Merely setting checked = true is not enough to trigger the pref | |
| 114 // being set; thus, we dispatch a change event to notify | |
| 115 // PrefCheckbox |checked| has changed. | |
| 116 cr.dispatchSimpleEvent(syncCheckboxes[i], 'change'); | |
| 117 } | |
| 118 | |
| 119 syncCheckboxes[i].disabled = true; | |
| 120 } | |
| 121 } | |
| 122 }, | |
| 123 | |
| 124 showStopSyncingOverlay_: function(event) { | 84 showStopSyncingOverlay_: function(event) { |
| 125 AlertOverlay.show(localStrings.getString('stop_syncing_title'), | 85 AlertOverlay.show(localStrings.getString('stop_syncing_title'), |
| 126 localStrings.getString('stop_syncing_explanation'), | 86 localStrings.getString('stop_syncing_explanation'), |
| 127 localStrings.getString('stop_syncing_confirm'), | 87 localStrings.getString('stop_syncing_confirm'), |
| 128 localStrings.getString('cancel'), | 88 localStrings.getString('cancel'), |
| 129 function() { chrome.send('stopSyncing'); }); | 89 function() { chrome.send('stopSyncing'); }); |
| 130 }, | 90 }, |
| 131 | 91 |
| 132 setElementVisible_: function(element, visible) { | 92 setElementVisible_: function(element, visible) { |
| 133 if (visible) | 93 if (visible) |
| 134 element.classList.remove('hidden'); | 94 element.classList.remove('hidden'); |
| 135 else | 95 else |
| 136 element.classList.add('hidden'); | 96 element.classList.add('hidden'); |
| 137 }, | 97 }, |
| 138 | 98 |
| 139 setElementClassSyncError_: function(element, visible) { | 99 setElementClassSyncError_: function(element, visible) { |
| 140 visible ? element.classList.add('sync-error') : | 100 visible ? element.classList.add('sync-error') : |
| 141 element.classList.remove('sync-error'); | 101 element.classList.remove('sync-error'); |
| 142 }, | 102 }, |
| 143 | 103 |
| 144 setSyncEnabled_: function(enabled) { | 104 setSyncEnabled_: function(enabled) { |
| 145 this.syncEnabled = enabled; | 105 this.syncEnabled = enabled; |
| 146 }, | 106 }, |
| 147 | 107 |
| 148 setSyncSetupCompleted_: function(completed) { | 108 setSyncSetupCompleted_: function(completed) { |
| 149 this.syncSetupCompleted = completed; | 109 this.syncSetupCompleted = completed; |
| 110 this.setElementVisible_($('customize-sync'), completed); |
| 150 }, | 111 }, |
| 151 | 112 |
| 152 setAccountPicture_: function(image) { | 113 setAccountPicture_: function(image) { |
| 153 $('account-picture').src = image; | 114 $('account-picture').src = image; |
| 154 }, | 115 }, |
| 155 | 116 |
| 156 setSyncStatus_: function(status) { | 117 setSyncStatus_: function(status) { |
| 157 $('sync-status').textContent = status; | 118 $('sync-status').textContent = status; |
| 158 }, | 119 }, |
| 159 | 120 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 PersonalOptions.getInstance()[name + '_'](value); | 205 PersonalOptions.getInstance()[name + '_'](value); |
| 245 }; | 206 }; |
| 246 }); | 207 }); |
| 247 | 208 |
| 248 // Export | 209 // Export |
| 249 return { | 210 return { |
| 250 PersonalOptions: PersonalOptions | 211 PersonalOptions: PersonalOptions |
| 251 }; | 212 }; |
| 252 | 213 |
| 253 }); | 214 }); |
| OLD | NEW |