OLD | NEW |
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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 this.addEventListener('change', | 125 this.addEventListener('change', |
126 function(e) { | 126 function(e) { |
127 Preferences.setStringPref(self.pref, | 127 Preferences.setStringPref(self.pref, |
128 self.options[self.selectedIndex].value); | 128 self.options[self.selectedIndex].value); |
129 }); | 129 }); |
130 }, | 130 }, |
131 | 131 |
132 /** | 132 /** |
133 * Sets up options in select element. | 133 * Sets up options in select element. |
134 * @param {Array} options List of option and their display text. | 134 * @param {Array} options List of option and their display text. |
135 * Each string in the array contains options value and display text split | 135 * Each element in the array is an array of length 2 which contains options |
136 * with '|' character. | 136 * value in the first element and display text in the second element. |
137 * | 137 * |
138 * TODO(zelidrag): move this to that i18n template classes. | 138 * TODO(zelidrag): move this to that i18n template classes. |
139 */ | 139 */ |
140 initializeValues: function(options) { | 140 initializeValues: function(options) { |
141 var self = this; | 141 var self = this; |
142 options.forEach(function (option) { | 142 options.forEach(function (values) { |
143 var values = option.split('|'); | 143 self.appendChild(new Option(values[1], values[0])); |
144 self.appendChild(new Option(values[1], values[0], false, false)); | |
145 }); | 144 }); |
146 }, | 145 }, |
147 /** | 146 /** |
148 * Getter for preference name attribute. | 147 * Getter for preference name attribute. |
149 */ | 148 */ |
150 get pref() { | 149 get pref() { |
151 return this.getAttribute('pref'); | 150 return this.getAttribute('pref'); |
152 }, | 151 }, |
153 | 152 |
154 /** | 153 /** |
155 * Setter for preference name attribute. | 154 * Setter for preference name attribute. |
156 */ | 155 */ |
157 set pref(name) { | 156 set pref(name) { |
158 this.setAttribute('pref', name); | 157 this.setAttribute('pref', name); |
159 } | 158 } |
160 }; | 159 }; |
OLD | NEW |