OLD | NEW |
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 // PrefCheckbox class: | 9 // PrefCheckbox class: |
10 // TODO(jhawkins): Refactor all this copy-pasted code! | 10 // TODO(jhawkins): Refactor all this copy-pasted code! |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 // Managed UI elements can only be disabled as a result of being | 44 // Managed UI elements can only be disabled as a result of being |
45 // managed. They cannot be enabled as a result of a pref being | 45 // managed. They cannot be enabled as a result of a pref being |
46 // unmanaged. | 46 // unmanaged. |
47 if (self.managed) | 47 if (self.managed) |
48 self.disabled = true; | 48 self.disabled = true; |
49 }); | 49 }); |
50 | 50 |
51 // Listen to user events. | 51 // Listen to user events. |
52 this.addEventListener( | 52 this.addEventListener( |
53 'click', | 53 'change', |
54 function(e) { | 54 function(e) { |
55 var value = self.inverted_pref ? !self.checked : self.checked; | 55 var value = self.inverted_pref ? !self.checked : self.checked; |
56 switch(self.valueType) { | 56 switch(self.valueType) { |
57 case 'number': | 57 case 'number': |
58 Preferences.setIntegerPref(self.pref, | 58 Preferences.setIntegerPref(self.pref, |
59 Number(value), self.metric); | 59 Number(value), self.metric); |
60 break; | 60 break; |
61 case 'boolean': | 61 case 'boolean': |
62 Preferences.setBooleanPref(self.pref, | 62 Preferences.setBooleanPref(self.pref, |
63 value, self.metric); | 63 value, self.metric); |
64 break; | 64 break; |
65 } | 65 } |
66 }); | 66 }); |
67 }, | 67 }, |
68 | 68 |
69 /** | 69 /** |
70 * Sets up options in checkbox element. | 70 * Sets up options in checkbox element. |
71 * @param {String} valueType The preference type for this checkbox. | 71 * @param {String} valueType The preference type for this checkbox. |
72 */ | 72 */ |
73 initializeValueType: function(valueType) { | 73 initializeValueType: function(valueType) { |
74 this.valueType = valueType || 'boolean'; | 74 this.valueType = valueType || 'boolean'; |
75 } | 75 }, |
76 }; | 76 }; |
77 | 77 |
78 /** | 78 /** |
79 * The preference name. | 79 * The preference name. |
80 * @type {string} | 80 * @type {string} |
81 */ | 81 */ |
82 cr.defineProperty(PrefCheckbox, 'pref', cr.PropertyKind.ATTR); | 82 cr.defineProperty(PrefCheckbox, 'pref', cr.PropertyKind.ATTR); |
83 | 83 |
84 /** | 84 /** |
85 * The user metric string. | 85 * The user metric string. |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 PrefCheckbox: PrefCheckbox, | 511 PrefCheckbox: PrefCheckbox, |
512 PrefNumber: PrefNumber, | 512 PrefNumber: PrefNumber, |
513 PrefNumeric: PrefNumeric, | 513 PrefNumeric: PrefNumeric, |
514 PrefRadio: PrefRadio, | 514 PrefRadio: PrefRadio, |
515 PrefRange: PrefRange, | 515 PrefRange: PrefRange, |
516 PrefSelect: PrefSelect, | 516 PrefSelect: PrefSelect, |
517 PrefTextField: PrefTextField | 517 PrefTextField: PrefTextField |
518 }; | 518 }; |
519 | 519 |
520 }); | 520 }); |
OLD | NEW |