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 = hasSingleProfile ? |
| 66 false : !hasSelection; | |
|
Miranda Callahan
2011/10/19 12:42:23
This logic is incorrect. Please reread my comments
NaveenBobbili (Motorola)
2011/10/19 13:01:09
Done.
| |
| 66 }; | 67 }; |
| 67 $('profiles-create').onclick = function(event) { | 68 $('profiles-create').onclick = function(event) { |
| 68 chrome.send('createProfile'); | 69 chrome.send('createProfile'); |
| 69 }; | 70 }; |
| 70 $('profiles-manage').onclick = function(event) { | 71 $('profiles-manage').onclick = function(event) { |
| 71 var selectedProfile = self.getSelectedProfileItem_(); | 72 var selectedProfile = self.getSelectedProfileItem_(); |
| 72 if (selectedProfile) | 73 if (selectedProfile) |
| 73 ManageProfileOverlay.showManageDialog(selectedProfile); | 74 ManageProfileOverlay.showManageDialog(selectedProfile); |
| 74 }; | 75 }; |
| 75 $('profiles-delete').onclick = function(event) { | 76 $('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. | 236 * @param {Array.<Object>} An array of profile info objects. |
| 236 * each object is of the form: | 237 * each object is of the form: |
| 237 * profileInfo = { | 238 * profileInfo = { |
| 238 * name: "Profile Name", | 239 * name: "Profile Name", |
| 239 * iconURL: "chrome://path/to/icon/image", | 240 * iconURL: "chrome://path/to/icon/image", |
| 240 * filePath: "/path/to/profile/data/on/disk", | 241 * filePath: "/path/to/profile/data/on/disk", |
| 241 * isCurrentProfile: false | 242 * isCurrentProfile: false |
| 242 * }; | 243 * }; |
| 243 */ | 244 */ |
| 244 setProfilesInfo_: function(profiles) { | 245 setProfilesInfo_: function(profiles) { |
| 246 var profilesList = $('profiles-list'); | |
| 245 this.setProfileViewSingle_(profiles.length); | 247 this.setProfileViewSingle_(profiles.length); |
| 246 // add it to the list, even if the list is hidden so we can access it | 248 // add it to the list, even if the list is hidden so we can access it |
| 247 // later. | 249 // later. |
| 248 $('profiles-list').dataModel = new ArrayDataModel(profiles); | 250 profilesList.dataModel = new ArrayDataModel(profiles); |
| 251 // Enable/Disable delete and edit buttons based on the number of profiles | |
| 252 // and the selection status. | |
| 253 var hasSelection = profilesList.selectedItem != null; | |
| 254 var hasSingleProfile = profilesList.dataModel.length == 1; | |
| 255 this.setDeleteButtonEnabled_(hasSingleProfile || hasSelection); | |
|
Miranda Callahan
2011/10/19 12:42:23
This logic is also wrong; for now, the delete butt
NaveenBobbili (Motorola)
2011/10/19 13:01:09
Done.
| |
| 256 this.setEditButtonEnabled_(hasSelection); | |
| 257 }, | |
| 258 | |
| 259 setDeleteButtonEnabled_: function(enabled) { | |
| 260 $('profiles-delete').disabled = !enabled; | |
| 261 }, | |
| 262 | |
| 263 setEditButtonEnabled_: function(enabled) { | |
| 264 $('profiles-manage').disabled = !enabled; | |
| 249 }, | 265 }, |
| 250 | 266 |
| 251 setStartStopButtonVisible_: function(visible) { | 267 setStartStopButtonVisible_: function(visible) { |
| 252 $('start-stop-sync').hidden = !visible; | 268 $('start-stop-sync').hidden = !visible; |
| 253 }, | 269 }, |
| 254 | 270 |
| 255 setStartStopButtonEnabled_: function(enabled) { | 271 setStartStopButtonEnabled_: function(enabled) { |
| 256 $('start-stop-sync').disabled = !enabled; | 272 $('start-stop-sync').disabled = !enabled; |
| 257 }, | 273 }, |
| 258 | 274 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 334 PersonalOptions.getInstance()[name + '_'](value); | 350 PersonalOptions.getInstance()[name + '_'](value); |
| 335 }; | 351 }; |
| 336 }); | 352 }); |
| 337 | 353 |
| 338 // Export | 354 // Export |
| 339 return { | 355 return { |
| 340 PersonalOptions: PersonalOptions | 356 PersonalOptions: PersonalOptions |
| 341 }; | 357 }; |
| 342 | 358 |
| 343 }); | 359 }); |
| OLD | NEW |