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

Unified 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: Corrected logic as per review comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/options/personal_options.js
diff --git a/chrome/browser/resources/options/personal_options.js b/chrome/browser/resources/options/personal_options.js
index 23483d01a22fd0f27e2d2e8adac4a2c5a06e742a..74032a5ff1c7f78b2a9cecdeeba0f2a7562e8c90 100644
--- a/chrome/browser/resources/options/personal_options.js
+++ b/chrome/browser/resources/options/personal_options.js
@@ -62,7 +62,7 @@ cr.define('options', function() {
var hasSelection = selectedProfile != null;
var hasSingleProfile = profilesList.dataModel.length == 1;
$('profiles-manage').disabled = !hasSelection;
- $('profiles-delete').disabled = !hasSingleProfile && !hasSelection;
+ $('profiles-delete').disabled = !hasSelection || hasSingleProfile;
};
$('profiles-create').onclick = function(event) {
chrome.send('createProfile');
@@ -242,10 +242,25 @@ cr.define('options', function() {
* };
*/
setProfilesInfo_: function(profiles) {
+ var profilesList = $('profiles-list');
this.setProfileViewSingle_(profiles.length);
// add it to the list, even if the list is hidden so we can access it
// later.
- $('profiles-list').dataModel = new ArrayDataModel(profiles);
+ profilesList.dataModel = new ArrayDataModel(profiles);
+ // Enable/Disable delete and edit buttons based on the number of profiles
+ // and the selection status.
+ var hasSelection = profilesList.selectedItem != null;
+ var hasSingleProfile = profilesList.dataModel.length == 1;
+ this.setDeleteButtonEnabled_(!hasSingleProfile && hasSelection);
+ 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.
+ },
+
+ 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.
+ $('profiles-delete').disabled = !enabled;
+ },
+
+ setEditButtonEnabled_: function(enabled) {
binji 2011/10/19 22:07:11 Please remove this helper function.
NaveenBobbili (Motorola) 2011/10/20 05:46:15 Done.
+ $('profiles-manage').disabled = !enabled;
},
setStartStopButtonVisible_: function(visible) {
« 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