Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Side by Side Diff: chrome/browser/resources/options/personal_options.js

Issue 8339014: Options: Disable the delete button when no profile is selected in personal settings. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Uploaded patch based on review comments. Used helper function to enable/disable buttons. Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698