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

Unified Diff: chrome/browser/resources/settings/checkbox/checkbox.js

Issue 1156783004: cr-settings-checkbox: Add 'inverted' property. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 | « chrome/browser/resources/settings/checkbox/checkbox.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/settings/checkbox/checkbox.js
diff --git a/chrome/browser/resources/settings/checkbox/checkbox.js b/chrome/browser/resources/settings/checkbox/checkbox.js
index 6e0860cf00b7b85554b4f9d0faabd3654c8daf14..2bdb4130bd8f04acdc70ed050f4ac86b24fa176c 100644
--- a/chrome/browser/resources/settings/checkbox/checkbox.js
+++ b/chrome/browser/resources/settings/checkbox/checkbox.js
@@ -24,6 +24,18 @@ Polymer({
pref: {
type: Object,
notify: true,
+ value: function() { return {}; }
Jeremy Klein 2015/06/04 00:49:54 Why do we need this? Doesn't it break the pref-tra
Oren Blasberg 2015/06/04 16:10:04 Oddly, without the initial value, I get an error i
Jeremy Klein 2015/06/04 17:20:16 Sorry, by "breaking" I mean preventing real errors
Oren Blasberg 2015/06/04 18:26:11 Oh, I see. Yes, the validation would always succee
+ },
+
+ inverted: {
+ type: Boolean,
+ value: false
+ },
+
+ checked: {
+ type: Boolean,
+ value: false,
+ observer: 'checkedChanged'
},
label: {
@@ -37,8 +49,26 @@ Polymer({
},
},
+ observers: [
+ 'prefValueChanged(pref.value)'
+ ],
+
/** @override */
ready: function() {
this.$.events.forward(this.$.checkbox, ['change']);
},
+
+ prefValueChanged: function(prefValue) {
Jeremy Klein 2015/06/04 00:49:54 This and the other 2 new functions can be private.
Oren Blasberg 2015/06/04 16:10:04 Done.
+ if (this.pref) {
+ this.checked = this.computeValue(prefValue);
+ }
+ },
+
+ checkedChanged: function() {
+ this.pref.value = this.computeValue(this.checked);
+ },
+
+ computeValue: function(val) {
Jeremy Klein 2015/06/04 00:49:54 For some reason the name computeValue confuses me
Oren Blasberg 2015/06/04 16:10:04 Ah ok. It's not actually inverting though; it's ju
Jeremy Klein 2015/06/04 17:20:16 The this is that it doesn't only get the prefValue
Oren Blasberg 2015/06/04 18:26:11 Ok, how about "getUpdatedValue_"? "getValueBased
+ return this.inverted ? !val : val;
+ }
});
« no previous file with comments | « chrome/browser/resources/settings/checkbox/checkbox.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698