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 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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 updateIndicator: function() { | 273 updateIndicator: function() { |
274 if ($(this.id + '-value')) { | 274 if ($(this.id + '-value')) { |
275 $(this.id + '-value').textContent = this.value; | 275 $(this.id + '-value').textContent = this.value; |
276 } | 276 } |
277 } | 277 } |
278 }; | 278 }; |
279 | 279 |
280 ///////////////////////////////////////////////////////////////////////////// | 280 ///////////////////////////////////////////////////////////////////////////// |
281 // PrefSelect class: | 281 // PrefSelect class: |
282 | 282 |
283 // Define a constructor that uses an select element as its underlying element. | 283 // Define a constructor that uses a select element as its underlying element. |
284 var PrefSelect = cr.ui.define('select'); | 284 var PrefSelect = cr.ui.define('select'); |
285 | 285 |
286 PrefSelect.prototype = { | 286 PrefSelect.prototype = { |
287 // Set up the prototype chain | 287 // Set up the prototype chain |
288 __proto__: HTMLSelectElement.prototype, | 288 __proto__: HTMLSelectElement.prototype, |
289 | 289 |
290 /** | 290 /** |
291 * Initialization function for the cr.ui framework. | 291 * Initialization function for the cr.ui framework. |
292 */ | 292 */ |
293 decorate: function() { | 293 decorate: function() { |
(...skipping 30 matching lines...) Expand all Loading... |
324 if (!found) | 324 if (!found) |
325 self.selectedIndex = 0; | 325 self.selectedIndex = 0; |
326 | 326 |
327 if (self.onchange != undefined) | 327 if (self.onchange != undefined) |
328 self.onchange(event); | 328 self.onchange(event); |
329 }); | 329 }); |
330 | 330 |
331 // Listen to user events. | 331 // Listen to user events. |
332 this.addEventListener('change', | 332 this.addEventListener('change', |
333 function(e) { | 333 function(e) { |
| 334 if (!self.dataType) |
| 335 console.error('unknown data type for <select> pref'); |
| 336 |
334 switch(self.dataType) { | 337 switch(self.dataType) { |
335 case 'number': | 338 case 'number': |
336 Preferences.setIntegerPref(self.pref, | 339 Preferences.setIntegerPref(self.pref, |
337 self.options[self.selectedIndex].value, self.metric); | 340 self.options[self.selectedIndex].value, self.metric); |
338 break; | 341 break; |
339 case 'boolean': | 342 case 'boolean': |
340 var option = self.options[self.selectedIndex]; | 343 var option = self.options[self.selectedIndex]; |
341 var value = (option.value == 'true') ? true : false; | 344 var value = (option.value == 'true') ? true : false; |
342 Preferences.setBooleanPref(self.pref, value, self.metric); | 345 Preferences.setBooleanPref(self.pref, value, self.metric); |
343 break; | 346 break; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 PrefCheckbox: PrefCheckbox, | 427 PrefCheckbox: PrefCheckbox, |
425 PrefNumber: PrefNumber, | 428 PrefNumber: PrefNumber, |
426 PrefNumeric: PrefNumeric, | 429 PrefNumeric: PrefNumeric, |
427 PrefRadio: PrefRadio, | 430 PrefRadio: PrefRadio, |
428 PrefRange: PrefRange, | 431 PrefRange: PrefRange, |
429 PrefSelect: PrefSelect, | 432 PrefSelect: PrefSelect, |
430 PrefTextField: PrefTextField | 433 PrefTextField: PrefTextField |
431 }; | 434 }; |
432 | 435 |
433 }); | 436 }); |
OLD | NEW |