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 | 8 |
9 // State variables. | 9 // State variables. |
10 var syncEnabled = false; | 10 var syncEnabled = false; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 }, | 107 }, |
108 | 108 |
109 showStopSyncingOverlay_: function() { | 109 showStopSyncingOverlay_: function() { |
110 AlertOverlay.show(localStrings.getString('stop_syncing_title'), | 110 AlertOverlay.show(localStrings.getString('stop_syncing_title'), |
111 localStrings.getString('stop_syncing_explanation'), | 111 localStrings.getString('stop_syncing_explanation'), |
112 localStrings.getString('stop_syncing_confirm'), | 112 localStrings.getString('stop_syncing_confirm'), |
113 localStrings.getString('cancel'), | 113 localStrings.getString('cancel'), |
114 function() { chrome.send('stopSyncing'); }); | 114 function() { chrome.send('stopSyncing'); }); |
115 }, | 115 }, |
116 | 116 |
117 setElementVisible_: function(element, visible) { | |
118 element.hidden = !visible; | |
119 if (visible) | |
120 element.classList.remove('hidden'); | |
121 else | |
122 element.classList.add('hidden'); | |
123 }, | |
124 | |
125 setSyncEnabled_: function(enabled) { | 117 setSyncEnabled_: function(enabled) { |
126 this.syncEnabled = enabled; | 118 this.syncEnabled = enabled; |
127 }, | 119 }, |
128 | 120 |
129 setSyncSetupCompleted_: function(completed) { | 121 setSyncSetupCompleted_: function(completed) { |
130 this.syncSetupCompleted = completed; | 122 this.syncSetupCompleted = completed; |
131 this.setElementVisible_($('customize-sync'), completed); | 123 $('customize-sync').hidden = !completed; |
132 $('privacy-dashboard-link').hidden = !completed; | 124 $('privacy-dashboard-link').hidden = !completed; |
133 }, | 125 }, |
134 | 126 |
135 setAccountPicture_: function(image) { | 127 setAccountPicture_: function(image) { |
136 $('account-picture').src = image; | 128 $('account-picture').src = image; |
137 }, | 129 }, |
138 | 130 |
139 setSyncStatus_: function(status) { | 131 setSyncStatus_: function(status) { |
140 var statusSet = status != ''; | 132 var statusSet = status != ''; |
141 $('sync-overview').hidden = statusSet; | 133 $('sync-overview').hidden = statusSet; |
142 $('sync-status').hidden = !statusSet; | 134 $('sync-status').hidden = !statusSet; |
143 $('sync-status-text').innerHTML = status; | 135 $('sync-status-text').innerHTML = status; |
144 }, | 136 }, |
145 | 137 |
146 setSyncStatusErrorVisible_: function(visible) { | 138 setSyncStatusErrorVisible_: function(visible) { |
147 visible ? $('sync-status').classList.add('sync-error') : | 139 visible ? $('sync-status').classList.add('sync-error') : |
148 $('sync-status').classList.remove('sync-error'); | 140 $('sync-status').classList.remove('sync-error'); |
149 }, | 141 }, |
150 | 142 |
151 setSyncActionLinkEnabled_: function(enabled) { | 143 setSyncActionLinkEnabled_: function(enabled) { |
152 $('sync-action-link').disabled = !enabled; | 144 $('sync-action-link').disabled = !enabled; |
153 }, | 145 }, |
154 | 146 |
155 setSyncActionLinkLabel_: function(status) { | 147 setSyncActionLinkLabel_: function(status) { |
156 $('sync-action-link').textContent = status; | 148 $('sync-action-link').textContent = status; |
157 | 149 |
158 // link-button does is not zero-area when the contents of the button are | 150 // link-button does is not zero-area when the contents of the button are |
159 // empty, so explicitly hide the element. | 151 // empty, so explicitly hide the element. |
160 this.setElementVisible_($('sync-action-link'), status.length != 0); | 152 $('sync-action-link').hidden = !status.length; |
161 }, | 153 }, |
162 | 154 |
163 setProfilesSectionVisible_: function(visible) { | 155 setProfilesSectionVisible_: function(visible) { |
164 this.setElementVisible_($('profiles-create'), visible); | 156 $('profiles-create').hidden = !visible; |
165 }, | 157 }, |
166 | 158 |
167 setNewProfileButtonEnabled_: function(enabled) { | 159 setNewProfileButtonEnabled_: function(enabled) { |
168 $('new-profile').disabled = !enabled; | 160 $('new-profile').disabled = !enabled; |
169 if (enabled) | 161 if (enabled) |
170 $('profiles-create').classList.remove('disabled'); | 162 $('profiles-create').classList.remove('disabled'); |
171 else | 163 else |
172 $('profiles-create').classList.add('disabled'); | 164 $('profiles-create').classList.add('disabled'); |
173 }, | 165 }, |
174 | 166 |
175 setStartStopButtonVisible_: function(visible) { | 167 setStartStopButtonVisible_: function(visible) { |
176 this.setElementVisible_($('start-stop-sync'), visible); | 168 $('start-stop-sync').hidden = !visible; |
177 }, | 169 }, |
178 | 170 |
179 setStartStopButtonEnabled_: function(enabled) { | 171 setStartStopButtonEnabled_: function(enabled) { |
180 $('start-stop-sync').disabled = !enabled; | 172 $('start-stop-sync').disabled = !enabled; |
181 }, | 173 }, |
182 | 174 |
183 setStartStopButtonLabel_: function(label) { | 175 setStartStopButtonLabel_: function(label) { |
184 $('start-stop-sync').textContent = label; | 176 $('start-stop-sync').textContent = label; |
185 }, | 177 }, |
186 | 178 |
187 setGtkThemeButtonEnabled_: function(enabled) { | 179 setGtkThemeButtonEnabled_: function(enabled) { |
188 if (!cr.isChromeOS && navigator.platform.match(/linux|BSD/i)) { | 180 if (!cr.isChromeOS && navigator.platform.match(/linux|BSD/i)) { |
189 $('themes-GTK-button').disabled = !enabled; | 181 $('themes-GTK-button').disabled = !enabled; |
190 } | 182 } |
191 }, | 183 }, |
192 | 184 |
193 setThemesResetButtonEnabled_: function(enabled) { | 185 setThemesResetButtonEnabled_: function(enabled) { |
194 $('themes-reset').disabled = !enabled; | 186 $('themes-reset').disabled = !enabled; |
195 }, | 187 }, |
196 | 188 |
197 hideSyncSection_: function() { | 189 hideSyncSection_: function() { |
198 this.setElementVisible_($('sync-section'), false); | 190 $('sync-section').hidden = true; |
199 }, | 191 }, |
200 | 192 |
201 /** | 193 /** |
202 * Toggles the visibility of the data type checkboxes based on whether they | 194 * Toggles the visibility of the data type checkboxes based on whether they |
203 * are enabled on not. | 195 * are enabled on not. |
204 * @param {Object} dict A mapping from data type to a boolean indicating | 196 * @param {Object} dict A mapping from data type to a boolean indicating |
205 * whether it is enabled. | 197 * whether it is enabled. |
206 * @private | 198 * @private |
207 */ | 199 */ |
208 setRegisteredDataTypes_: function(dict) { | 200 setRegisteredDataTypes_: function(dict) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 PersonalOptions.getInstance()[name + '_'](value); | 249 PersonalOptions.getInstance()[name + '_'](value); |
258 }; | 250 }; |
259 }); | 251 }); |
260 | 252 |
261 // Export | 253 // Export |
262 return { | 254 return { |
263 PersonalOptions: PersonalOptions | 255 PersonalOptions: PersonalOptions |
264 }; | 256 }; |
265 | 257 |
266 }); | 258 }); |
OLD | NEW |