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 ArrayDataModel = cr.ui.ArrayDataModel; | 8 var ArrayDataModel = cr.ui.ArrayDataModel; |
| 9 | 9 |
| 10 // State variables. | 10 // State variables. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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) { |
| 61 var selectedProfile = profilesList.selectedItem; | 61 var selectedProfile = profilesList.selectedItem; |
| 62 var hasSelection = selectedProfile != null; | 62 var hasSelection = selectedProfile != null; |
| 63 var hasSingleProfile = profilesList.dataModel.length == 1; | 63 var hasSingleProfile = profilesList.dataModel.length == 1; |
| 64 $('profiles-manage').disabled = !hasSelection; | 64 $('profiles-manage').disabled = !hasSelection; |
| 65 $('profiles-delete').disabled = !hasSingleProfile && !hasSelection; | 65 $('profiles-delete').disabled = !hasSelection || hasSingleProfile; |
| 66 }; | 66 }; |
| 67 $('profiles-create').onclick = function(event) { | 67 $('profiles-create').onclick = function(event) { |
| 68 chrome.send('createProfile'); | 68 chrome.send('createProfile'); |
| 69 }; | 69 }; |
| 70 $('profiles-manage').onclick = function(event) { | 70 $('profiles-manage').onclick = function(event) { |
| 71 var selectedProfile = self.getSelectedProfileItem_(); | 71 var selectedProfile = self.getSelectedProfileItem_(); |
| 72 if (selectedProfile) | 72 if (selectedProfile) |
| 73 ManageProfileOverlay.showManageDialog(selectedProfile); | 73 ManageProfileOverlay.showManageDialog(selectedProfile); |
| 74 }; | 74 }; |
| 75 $('profiles-delete').onclick = function(event) { | 75 $('profiles-delete').onclick = function(event) { |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 235 * @param {Array.<Object>} An array of profile info objects. | 235 * @param {Array.<Object>} An array of profile info objects. |
| 236 * each object is of the form: | 236 * each object is of the form: |
| 237 * profileInfo = { | 237 * profileInfo = { |
| 238 * name: "Profile Name", | 238 * name: "Profile Name", |
| 239 * iconURL: "chrome://path/to/icon/image", | 239 * iconURL: "chrome://path/to/icon/image", |
| 240 * filePath: "/path/to/profile/data/on/disk", | 240 * filePath: "/path/to/profile/data/on/disk", |
| 241 * isCurrentProfile: false | 241 * isCurrentProfile: false |
| 242 * }; | 242 * }; |
| 243 */ | 243 */ |
| 244 setProfilesInfo_: function(profiles) { | 244 setProfilesInfo_: function(profiles) { |
| 245 var profilesList = $('profiles-list'); | |
| 245 this.setProfileViewSingle_(profiles.length); | 246 this.setProfileViewSingle_(profiles.length); |
| 246 // add it to the list, even if the list is hidden so we can access it | 247 // add it to the list, even if the list is hidden so we can access it |
| 247 // later. | 248 // later. |
| 248 $('profiles-list').dataModel = new ArrayDataModel(profiles); | 249 profilesList.dataModel = new ArrayDataModel(profiles); |
| 250 // Enable/Disable delete and edit buttons based on the number of profiles | |
| 251 // and the selection status. | |
| 252 var hasSelection = profilesList.selectedItem != null; | |
| 253 var hasSingleProfile = profilesList.dataModel.length == 1; | |
| 254 this.setDeleteButtonEnabled_(!hasSingleProfile && hasSelection); | |
| 255 this.setEditButtonEnabled_(hasSelection); | |
|
binji
2011/10/19 22:07:11
Create a helper function consisting of these four
NaveenBobbili (Motorola)
2011/10/20 05:46:15
Done.
| |
| 256 }, | |
| 257 | |
| 258 setDeleteButtonEnabled_: function(enabled) { | |
|
binji
2011/10/19 22:07:11
Please remove this helper function. The similar fu
NaveenBobbili (Motorola)
2011/10/20 05:46:15
Done.
| |
| 259 $('profiles-delete').disabled = !enabled; | |
| 260 }, | |
| 261 | |
| 262 setEditButtonEnabled_: function(enabled) { | |
|
binji
2011/10/19 22:07:11
Please remove this helper function.
NaveenBobbili (Motorola)
2011/10/20 05:46:15
Done.
| |
| 263 $('profiles-manage').disabled = !enabled; | |
| 249 }, | 264 }, |
| 250 | 265 |
| 251 setStartStopButtonVisible_: function(visible) { | 266 setStartStopButtonVisible_: function(visible) { |
| 252 $('start-stop-sync').hidden = !visible; | 267 $('start-stop-sync').hidden = !visible; |
| 253 }, | 268 }, |
| 254 | 269 |
| 255 setStartStopButtonEnabled_: function(enabled) { | 270 setStartStopButtonEnabled_: function(enabled) { |
| 256 $('start-stop-sync').disabled = !enabled; | 271 $('start-stop-sync').disabled = !enabled; |
| 257 }, | 272 }, |
| 258 | 273 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 334 PersonalOptions.getInstance()[name + '_'](value); | 349 PersonalOptions.getInstance()[name + '_'](value); |
| 335 }; | 350 }; |
| 336 }); | 351 }); |
| 337 | 352 |
| 338 // Export | 353 // Export |
| 339 return { | 354 return { |
| 340 PersonalOptions: PersonalOptions | 355 PersonalOptions: PersonalOptions |
| 341 }; | 356 }; |
| 342 | 357 |
| 343 }); | 358 }); |
| OLD | NEW |