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

Side by Side Diff: chrome/browser/resources/options/pref_ui.js

Issue 7396025: Refactor Instant web UI (chrome://settings page). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed estade's comments Created 9 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('options', function() { 5 cr.define('options', function() {
6 6
7 var Preferences = options.Preferences; 7 var Preferences = options.Preferences;
8 8
9 /** 9 /**
10 * Allows an element to be disabled for several reasons. 10 * Allows an element to be disabled for several reasons.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 else 91 else
92 self.checked = Boolean(value); 92 self.checked = Boolean(value);
93 93
94 updateElementState_(self, event); 94 updateElementState_(self, event);
95 }); 95 });
96 96
97 // Listen to user events. 97 // Listen to user events.
98 this.addEventListener( 98 this.addEventListener(
99 'change', 99 'change',
100 function(e) { 100 function(e) {
101 if (self.customChangeHandler(e))
102 return;
101 var value = self.inverted_pref ? !self.checked : self.checked; 103 var value = self.inverted_pref ? !self.checked : self.checked;
102 switch(self.valueType) { 104 switch(self.valueType) {
103 case 'number': 105 case 'number':
104 Preferences.setIntegerPref(self.pref, 106 Preferences.setIntegerPref(self.pref,
105 Number(value), self.metric); 107 Number(value), self.metric);
106 break; 108 break;
107 case 'boolean': 109 case 'boolean':
108 Preferences.setBooleanPref(self.pref, 110 Preferences.setBooleanPref(self.pref,
109 value, self.metric); 111 value, self.metric);
110 break; 112 break;
111 } 113 }
112 }); 114 });
113 }, 115 },
114 116
115 /** 117 /**
116 * Sets up options in checkbox element. 118 * Sets up options in checkbox element.
117 * @param {String} valueType The preference type for this checkbox. 119 * @param {String} valueType The preference type for this checkbox.
118 */ 120 */
119 initializeValueType: function(valueType) { 121 initializeValueType: function(valueType) {
120 this.valueType = valueType || 'boolean'; 122 this.valueType = valueType || 'boolean';
121 }, 123 },
122 124
123 /** 125 /**
124 * See |updateDisabledState_| above. 126 * See |updateDisabledState_| above.
125 */ 127 */
126 setDisabled: function(reason, disabled) { 128 setDisabled: function(reason, disabled) {
127 updateDisabledState_(this, reason, disabled); 129 updateDisabledState_(this, reason, disabled);
128 }, 130 },
131
132 /**
133 * This method is called first while processing an onchange event. If it
134 * returns false, regular onchange processing continues (setting the
135 * associated pref, etc). If it returns true, the rest of the onchange is
136 * not performed. I.e., this works like stopPropagation or cancelBubble.
137 * @param {Event} event Change event.
138 */
139 customChangeHandler: function(event) {
140 return false;
141 },
129 }; 142 };
130 143
131 /** 144 /**
132 * The preference name. 145 * The preference name.
133 * @type {string} 146 * @type {string}
134 */ 147 */
135 cr.defineProperty(PrefCheckbox, 'pref', cr.PropertyKind.ATTR); 148 cr.defineProperty(PrefCheckbox, 'pref', cr.PropertyKind.ATTR);
136 149
137 /** 150 /**
138 * Whether the preference is controlled by something else than the user's 151 * Whether the preference is controlled by something else than the user's
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 PrefNumber: PrefNumber, 711 PrefNumber: PrefNumber,
699 PrefNumeric: PrefNumeric, 712 PrefNumeric: PrefNumeric,
700 PrefRadio: PrefRadio, 713 PrefRadio: PrefRadio,
701 PrefRange: PrefRange, 714 PrefRange: PrefRange,
702 PrefSelect: PrefSelect, 715 PrefSelect: PrefSelect,
703 PrefTextField: PrefTextField, 716 PrefTextField: PrefTextField,
704 PrefButton: PrefButton 717 PrefButton: PrefButton
705 }; 718 };
706 719
707 }); 720 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/instant_confirm_overlay.js ('k') | chrome/browser/ui/webui/options/browser_options_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698