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

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

Issue 2856053: Implement the 'Clear Browser Data' dom-ui overlay.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 /////////////////////////////////////////////////////////////////////////////// 5 ///////////////////////////////////////////////////////////////////////////////
6 // PrefCheckbox class: 6 // PrefCheckbox class:
7 7
8 // Define a constructor that uses an input element as its underlying element. 8 // Define a constructor that uses an input element as its underlying element.
9 var PrefCheckbox = cr.ui.define('input'); 9 var PrefCheckbox = cr.ui.define('input');
10 10
(...skipping 10 matching lines...) Expand all
21 21
22 // Listen to pref changes. 22 // Listen to pref changes.
23 Preferences.getInstance().addEventListener(this.pref, 23 Preferences.getInstance().addEventListener(this.pref,
24 function(event) { 24 function(event) {
25 self.checked = event.value; 25 self.checked = event.value;
26 }); 26 });
27 27
28 // Listen to user events. 28 // Listen to user events.
29 this.addEventListener('click', 29 this.addEventListener('click',
30 function(e) { 30 function(e) {
31 Preferences.setBooleanPref(self.pref, 31 Preferences.setBooleanPref(self.pref, self.checked);
32 self.checked);
33 }); 32 });
34 } 33 }
35 }; 34 };
36 35
37 /** 36 /**
38 * The preference name. 37 * The preference name.
39 * @type {string} 38 * @type {string}
40 */ 39 */
41 cr.defineProperty(PrefCheckbox, 'pref', cr.PropertyKind.ATTR); 40 cr.defineProperty(PrefCheckbox, 'pref', cr.PropertyKind.ATTR);
42 41
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 self.selectedIndex = i; 99 self.selectedIndex = i;
101 return; 100 return;
102 } 101 }
103 } 102 }
104 self.selectedIndex = -1; 103 self.selectedIndex = -1;
105 }); 104 });
106 105
107 // Listen to user events. 106 // Listen to user events.
108 this.addEventListener('change', 107 this.addEventListener('change',
109 function(e) { 108 function(e) {
110 Preferences.setStringPref(self.pref, 109 switch(self.dataType) {
111 self.options[self.selectedIndex].value); 110 case 'number':
111 Preferences.setIntegerPref(self.pref,
112 self.options[self.selectedIndex].value);
113 break;
114 case 'boolean':
115 Preferences.setBooleanValue(self.pref,
116 self.options[self.selectedIndex].value);
117 break;
118 case 'string':
119 Preferences.setStringPref(self.pref,
120 self.options[self.selectedIndex].value);
121 break;
122 }
112 }); 123 });
113 }, 124 },
114 125
115 /** 126 /**
116 * Sets up options in select element. 127 * Sets up options in select element.
117 * @param {Array} options List of option and their display text. 128 * @param {Array} options List of option and their display text.
118 * Each element in the array is an array of length 2 which contains options 129 * Each element in the array is an array of length 2 which contains options
119 * value in the first element and display text in the second element. 130 * value in the first element and display text in the second element.
120 * 131 *
121 * TODO(zelidrag): move this to that i18n template classes. 132 * TODO(zelidrag): move this to that i18n template classes.
122 */ 133 */
123 initializeValues: function(options) { 134 initializeValues: function(options) {
124 options.forEach(function (values) { 135 options.forEach(function (values) {
136 if (this.dataType == undefined)
137 this.dataType = typeof values[0];
125 this.appendChild(new Option(values[1], values[0])); 138 this.appendChild(new Option(values[1], values[0]));
126 }, this); 139 }, this);
127 } 140 }
128 }; 141 };
129 142
130 /** 143 /**
131 * The preference name. 144 * The preference name.
132 * @type {string} 145 * @type {string}
133 */ 146 */
134 cr.defineProperty(PrefSelect, 'pref', cr.PropertyKind.ATTR); 147 cr.defineProperty(PrefSelect, 'pref', cr.PropertyKind.ATTR);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 self.blur(); 180 self.blur();
168 }); 181 });
169 } 182 }
170 }; 183 };
171 184
172 /** 185 /**
173 * The preference name. 186 * The preference name.
174 * @type {string} 187 * @type {string}
175 */ 188 */
176 cr.defineProperty(PrefTextField, 'pref', cr.PropertyKind.ATTR); 189 cr.defineProperty(PrefTextField, 'pref', cr.PropertyKind.ATTR);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698