summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources
diff options
context:
space:
mode:
authorstuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-20 23:02:40 +0000
committerstuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-20 23:02:40 +0000
commitb1d49c72fdf780aedd9ed2b3d39799ed00d99da8 (patch)
treeb7c644e65168043bbf3af23603d6f37692b94f64 /chrome/browser/resources
parent1eeb5e08580730cb2a0a2751f578dbc4e6402369 (diff)
downloadchromium_src-b1d49c72fdf780aedd9ed2b3d39799ed00d99da8.zip
chromium_src-b1d49c72fdf780aedd9ed2b3d39799ed00d99da8.tar.gz
chromium_src-b1d49c72fdf780aedd9ed2b3d39799ed00d99da8.tar.bz2
Hook up the radio buttons and URL field on the DOMUI Basics prefs page
The URL field doesn't yet enable/disable based on the radio button selection; that will be a follow-up. BUG=48713 TEST=Radio buttons and URL field on the Basics page should work. Review URL: http://codereview.chromium.org/3025003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53114 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/resources')
-rw-r--r--chrome/browser/resources/options.html1
-rw-r--r--chrome/browser/resources/options/browser_options.html22
-rw-r--r--chrome/browser/resources/options/pref_ui.js42
3 files changed, 54 insertions, 11 deletions
diff --git a/chrome/browser/resources/options.html b/chrome/browser/resources/options.html
index e391b06..7dcac76 100644
--- a/chrome/browser/resources/options.html
+++ b/chrome/browser/resources/options.html
@@ -149,6 +149,7 @@ cr.ui.decorate('input[pref][type=checkbox]', PrefCheckbox);
cr.ui.decorate('input[pref][type=radio]', PrefRadio);
cr.ui.decorate('input[pref][type=range]', PrefRange);
cr.ui.decorate('select[pref]', PrefSelect);
+cr.ui.decorate('input[pref][type=url]', PrefTextField);
cr.ui.decorate('#contentSettingsPage input[type=radio]', ContentSettingsRadio);
// TODO(zelidrag) add other elements here when we implement them
</script>
diff --git a/chrome/browser/resources/options/browser_options.html b/chrome/browser/resources/options/browser_options.html
index 84b2897..6d115d2 100644
--- a/chrome/browser/resources/options/browser_options.html
+++ b/chrome/browser/resources/options/browser_options.html
@@ -3,14 +3,14 @@
<section>
<h3 i18n-content="startupGroupName"></h3>
<div>
- <label><input type="radio" name="startup" disabled
- value="ShowDefaultAndNewTab"><span
+ <label><input type="radio" name="startup"
+ pref="session.restore_on_startup" value="0"><span
i18n-content="startupShowDefaultAndNewTab"></span></label><br>
- <label><input type="radio" name="startup" disabled
- value="ShowLastSession"><span
+ <label><input type="radio" name="startup"
+ pref="session.restore_on_startup" value="1"><span
i18n-content="startupShowLastSession"></span></label><br>
- <label><input type="radio" name="startup" disabled
- value="ShowPages"><span
+ <label><input type="radio" name="startup"
+ pref="session.restore_on_startup" value="4"><span
i18n-content="startupShowPages"></span></label>
<div class="suboption">
<select id="startupPages" size="3">
@@ -27,14 +27,14 @@
<section>
<h3 i18n-content="homepageGroupName"></h3>
<div>
- <label><input type="radio" name="homepage" disabled
- value="UseNewTab"><span
+ <label><input type="radio" name="homepage" pref="homepage_is_newtabpage"
+ value="true"><span
i18n-content="homepageUseNewTab"></span></label><br>
- <label><input type="radio" name="homepage" disabled
- value="UseURL"><span
+ <label><input type="radio" name="homepage" pref="homepage_is_newtabpage"
+ value="false"><span
i18n-content="homepageUseURL"></span></label><br>
<div class="suboption">
- <input id="homepageURL" type="url" disabled>
+ <input id="homepageURL" type="url" pref="homepage">
</div>
<div class="option">
<label><input id="homepageShowButton"
diff --git a/chrome/browser/resources/options/pref_ui.js b/chrome/browser/resources/options/pref_ui.js
index 4522ab5..6cf15b4 100644
--- a/chrome/browser/resources/options/pref_ui.js
+++ b/chrome/browser/resources/options/pref_ui.js
@@ -184,3 +184,45 @@ PrefSelect.prototype = {
* @type {string}
*/
cr.defineProperty(PrefSelect, 'pref', cr.PropertyKind.ATTR);
+
+///////////////////////////////////////////////////////////////////////////////
+// PrefTextField class:
+
+// Define a constructor that uses an input element as its underlying element.
+var PrefTextField = cr.ui.define('input');
+
+PrefTextField.prototype = {
+ // Set up the prototype chain
+ __proto__: HTMLInputElement.prototype,
+
+ /**
+ * Initialization function for the cr.ui framework.
+ */
+ decorate: function() {
+ var self = this;
+
+ // Listen to pref changes.
+ Preferences.getInstance().addEventListener(this.pref,
+ function(event) {
+ self.value = event.value;
+ });
+
+ // Listen to user events.
+ this.addEventListener('change',
+ function(e) {
+ Preferences.setStringPref(self.pref, self.value);
+ });
+
+ window.addEventListener('unload',
+ function() {
+ if (document.activeElement == self)
+ self.blur();
+ });
+ }
+};
+
+/**
+ * The preference name.
+ * @type {string}
+ */
+cr.defineProperty(PrefTextField, 'pref', cr.PropertyKind.ATTR);