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 ArrayDataModel = cr.ui.ArrayDataModel; | 8 var ArrayDataModel = cr.ui.ArrayDataModel; |
9 | 9 |
10 // State variables. | 10 // State variables. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 }; | 50 }; |
51 $('customize-sync').onclick = function(event) { | 51 $('customize-sync').onclick = function(event) { |
52 SyncSetupOverlay.showSetupUI(); | 52 SyncSetupOverlay.showSetupUI(); |
53 }; | 53 }; |
54 | 54 |
55 // Profiles. | 55 // Profiles. |
56 var profilesList = $('profiles-list'); | 56 var profilesList = $('profiles-list'); |
57 options.personal_options.ProfileList.decorate(profilesList); | 57 options.personal_options.ProfileList.decorate(profilesList); |
58 profilesList.autoExpands = true; | 58 profilesList.autoExpands = true; |
59 | 59 |
60 profilesList.onchange = function(event) { | 60 profilesList.onchange = function(event) { |
Evan Stade
2011/10/21 01:13:07
this should be
profilesList.onchange = this.setPr
NaveenBobbili (Motorola)
2011/10/22 17:34:35
Done.
| |
61 var selectedProfile = profilesList.selectedItem; | 61 self.setProfileViewButtonsStatus_(); |
62 var hasSelection = selectedProfile != null; | |
63 var hasSingleProfile = profilesList.dataModel.length == 1; | |
64 $('profiles-manage').disabled = !hasSelection; | |
65 $('profiles-delete').disabled = !hasSingleProfile && !hasSelection; | |
66 }; | 62 }; |
67 $('profiles-create').onclick = function(event) { | 63 $('profiles-create').onclick = function(event) { |
68 chrome.send('createProfile'); | 64 chrome.send('createProfile'); |
69 }; | 65 }; |
70 $('profiles-manage').onclick = function(event) { | 66 $('profiles-manage').onclick = function(event) { |
71 var selectedProfile = self.getSelectedProfileItem_(); | 67 var selectedProfile = self.getSelectedProfileItem_(); |
72 if (selectedProfile) | 68 if (selectedProfile) |
73 ManageProfileOverlay.showManageDialog(selectedProfile); | 69 ManageProfileOverlay.showManageDialog(selectedProfile); |
74 }; | 70 }; |
75 $('profiles-delete').onclick = function(event) { | 71 $('profiles-delete').onclick = function(event) { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
209 if (profilesList.hidden) { | 205 if (profilesList.hidden) { |
210 if (profilesList.dataModel.length > 0) | 206 if (profilesList.dataModel.length > 0) |
211 return profilesList.dataModel.item(0); | 207 return profilesList.dataModel.item(0); |
212 } else { | 208 } else { |
213 return profilesList.selectedItem; | 209 return profilesList.selectedItem; |
214 } | 210 } |
215 return null; | 211 return null; |
216 }, | 212 }, |
217 | 213 |
218 /** | 214 /** |
215 * Helper function to set the status of profile view buttons to disabled or | |
216 * enabled, depending on the number of profiles and selection status of the | |
217 * profiles list. | |
218 */ | |
219 setProfileViewButtonsStatus_: function() { | |
220 var profilesList = $('profiles-list'); | |
221 var selectedProfile = profilesList.selectedItem; | |
222 var hasSelection = selectedProfile != null; | |
223 var hasSingleProfile = profilesList.dataModel.length == 1; | |
224 $('profiles-manage').disabled = !hasSelection; | |
225 $('profiles-delete').disabled = !hasSelection || hasSingleProfile; | |
226 }, | |
227 | |
228 /** | |
219 * Display the correct dialog layout, depending on how many profiles are | 229 * Display the correct dialog layout, depending on how many profiles are |
220 * available. | 230 * available. |
221 * @param {number} numProfiles The number of profiles to display. | 231 * @param {number} numProfiles The number of profiles to display. |
222 */ | 232 */ |
223 setProfileViewSingle_: function(numProfiles) { | 233 setProfileViewSingle_: function(numProfiles) { |
224 var hasSingleProfile = numProfiles == 1; | 234 var hasSingleProfile = numProfiles == 1; |
225 $('profiles-list').hidden = hasSingleProfile; | 235 $('profiles-list').hidden = hasSingleProfile; |
226 $('profiles-single-message').hidden = !hasSingleProfile; | 236 $('profiles-single-message').hidden = !hasSingleProfile; |
227 $('profiles-manage').hidden = hasSingleProfile; | 237 $('profiles-manage').hidden = hasSingleProfile; |
228 $('profiles-delete').textContent = hasSingleProfile ? | 238 $('profiles-delete').textContent = hasSingleProfile ? |
(...skipping 10 matching lines...) Expand all Loading... | |
239 * iconURL: "chrome://path/to/icon/image", | 249 * iconURL: "chrome://path/to/icon/image", |
240 * filePath: "/path/to/profile/data/on/disk", | 250 * filePath: "/path/to/profile/data/on/disk", |
241 * isCurrentProfile: false | 251 * isCurrentProfile: false |
242 * }; | 252 * }; |
243 */ | 253 */ |
244 setProfilesInfo_: function(profiles) { | 254 setProfilesInfo_: function(profiles) { |
245 this.setProfileViewSingle_(profiles.length); | 255 this.setProfileViewSingle_(profiles.length); |
246 // add it to the list, even if the list is hidden so we can access it | 256 // add it to the list, even if the list is hidden so we can access it |
247 // later. | 257 // later. |
248 $('profiles-list').dataModel = new ArrayDataModel(profiles); | 258 $('profiles-list').dataModel = new ArrayDataModel(profiles); |
259 this.setProfileViewButtonsStatus_(); | |
249 }, | 260 }, |
250 | 261 |
251 setStartStopButtonVisible_: function(visible) { | 262 setStartStopButtonVisible_: function(visible) { |
252 $('start-stop-sync').hidden = !visible; | 263 $('start-stop-sync').hidden = !visible; |
253 }, | 264 }, |
254 | 265 |
255 setStartStopButtonEnabled_: function(enabled) { | 266 setStartStopButtonEnabled_: function(enabled) { |
256 $('start-stop-sync').disabled = !enabled; | 267 $('start-stop-sync').disabled = !enabled; |
257 }, | 268 }, |
258 | 269 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
334 PersonalOptions.getInstance()[name + '_'](value); | 345 PersonalOptions.getInstance()[name + '_'](value); |
335 }; | 346 }; |
336 }); | 347 }); |
337 | 348 |
338 // Export | 349 // Export |
339 return { | 350 return { |
340 PersonalOptions: PersonalOptions | 351 PersonalOptions: PersonalOptions |
341 }; | 352 }; |
342 | 353 |
343 }); | 354 }); |
OLD | NEW |