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

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: Rename that method. Created 5 years, 6 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..40d9fde0632ede8fe6e5bf8171671c083dfc4bcf 100644
--- a/chrome/browser/resources/settings/checkbox/checkbox.js
+++ b/chrome/browser/resources/settings/checkbox/checkbox.js
@@ -23,7 +23,18 @@ Polymer({
*/
pref: {
type: Object,
- notify: true,
+ notify: true
+ },
+
+ inverted: {
+ type: Boolean,
+ value: false
+ },
+
+ checked: {
+ type: Boolean,
+ value: false,
+ observer: 'checkedChanged_'
},
label: {
@@ -37,8 +48,32 @@ Polymer({
},
},
+ observers: [
+ 'prefValueChanged_(pref.value)'
+ ],
+
/** @override */
ready: function() {
this.$.events.forward(this.$.checkbox, ['change']);
},
+
+ /** @private */
+ prefValueChanged_: function(prefValue) {
+ // prefValue is initially undefined when Polymer initializes pref.
+ if (prefValue !== undefined) {
+ this.checked = this.getNewValue_(prefValue);
+ }
+ },
+
+ /** @private */
+ checkedChanged_: function() {
+ if (this.pref) {
+ this.pref.value = this.getNewValue_(this.checked);
+ }
+ },
+
+ /** @private */
+ getNewValue_: function(val) {
+ 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