summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources/options/pref_ui.js
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/resources/options/pref_ui.js')
-rw-r--r--chrome/browser/resources/options/pref_ui.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/chrome/browser/resources/options/pref_ui.js b/chrome/browser/resources/options/pref_ui.js
index b618cc8..33379ef 100644
--- a/chrome/browser/resources/options/pref_ui.js
+++ b/chrome/browser/resources/options/pref_ui.js
@@ -41,8 +41,61 @@ PrefCheckbox.prototype = {
cr.defineProperty(PrefCheckbox, 'pref', cr.PropertyKind.ATTR);
///////////////////////////////////////////////////////////////////////////////
+// PrefRadio class:
+
+//Define a constructor that uses an input element as its underlying element.
+var PrefRadio = cr.ui.define('input');
+
+PrefRadio.prototype = {
+ // Set up the prototype chain
+ __proto__: HTMLInputElement.prototype,
+
+ /**
+ * Initialization function for the cr.ui framework.
+ */
+ decorate: function() {
+ this.type = 'radio';
+ var self = this;
+
+ // Listen to pref changes.
+ Preferences.getInstance().addEventListener(this.pref,
+ function(event) {
+ self.checked = String(event.value) == self.value;
+ });
+
+ // Listen to user events.
+ this.addEventListener('change',
+ function(e) {
+ if(self.value == 'true' || self.value == 'false') {
+ Preferences.setBooleanPref(self.pref,
+ self.value == 'true');
+ }else {
+ Preferences.setIntegerPref(self.pref,
+ parseInt(self.value, 10));
+ }
+ });
+ },
+
+ /**
+ * Getter for preference name attribute.
+ */
+ get pref() {
+ return this.getAttribute('pref');
+ },
+
+ /**
+ * Setter for preference name attribute.
+ */
+ set pref(name) {
+ this.setAttribute('pref', name);
+ }
+};
+
+
+///////////////////////////////////////////////////////////////////////////////
// PrefNumeric class:
+// Define a constructor that uses an input element as its underlying element.
var PrefNumeric = function() {};
PrefNumeric.prototype = {
// Set up the prototype chain