OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 var Preferences = options.Preferences; | 6 var Preferences = options.Preferences; |
7 | 7 |
8 /** | 8 /** |
9 * Allows an element to be disabled for several reasons. | 9 * Allows an element to be disabled for several reasons. |
10 * The element is disabled if at least one reason is true, and the reasons | 10 * The element is disabled if at least one reason is true, and the reasons |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 }; | 383 }; |
384 | 384 |
385 ///////////////////////////////////////////////////////////////////////////// | 385 ///////////////////////////////////////////////////////////////////////////// |
386 // PrefSelect class: | 386 // PrefSelect class: |
387 | 387 |
388 // Define a constructor that uses a select element as its underlying element. | 388 // Define a constructor that uses a select element as its underlying element. |
389 var PrefSelect = cr.ui.define('select'); | 389 var PrefSelect = cr.ui.define('select'); |
390 | 390 |
391 PrefSelect.prototype = { | 391 PrefSelect.prototype = { |
392 // Set up the prototype chain | 392 // Set up the prototype chain |
393 __proto__: PrefInputElement.prototype, | 393 __proto__: HTMLSelectElement.prototype, |
| 394 |
| 395 /** @override */ |
| 396 decorate: PrefInputElement.prototype.decorate, |
| 397 |
| 398 /** @override */ |
| 399 handleChange: PrefInputElement.prototype.handleChange, |
394 | 400 |
395 /** | 401 /** |
396 * Update the associated pref when when the user selects an item. | 402 * Update the associated pref when when the user selects an item. |
397 * @override | 403 * @override |
398 */ | 404 */ |
399 updatePrefFromState: function() { | 405 updatePrefFromState: function() { |
400 var value = this.options[this.selectedIndex].value; | 406 var value = this.options[this.selectedIndex].value; |
401 switch (this.dataType) { | 407 switch (this.dataType) { |
402 case 'number': | 408 case 'number': |
403 Preferences.setIntegerPref(this.pref, value, | 409 Preferences.setIntegerPref(this.pref, value, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 if (!found) | 448 if (!found) |
443 this.selectedIndex = 0; | 449 this.selectedIndex = 0; |
444 | 450 |
445 // The "onchange" event automatically fires when the user makes a manual | 451 // The "onchange" event automatically fires when the user makes a manual |
446 // change. It should never be fired for a programmatic change. However, | 452 // change. It should never be fired for a programmatic change. However, |
447 // these two lines were here already and it is hard to tell who may be | 453 // these two lines were here already and it is hard to tell who may be |
448 // relying on them. | 454 // relying on them. |
449 if (this.onchange) | 455 if (this.onchange) |
450 this.onchange(event); | 456 this.onchange(event); |
451 }, | 457 }, |
| 458 |
| 459 /** @override */ |
| 460 setDisabled: PrefInputElement.prototype.setDisabled, |
| 461 |
| 462 /** @override */ |
| 463 customChangeHandler: PrefInputElement.prototype.customChangeHandler, |
| 464 |
| 465 /** @override */ |
| 466 customPrefChangeHandler: PrefInputElement.prototype.customPrefChangeHandler, |
452 }; | 467 }; |
453 | 468 |
| 469 /** |
| 470 * The name of the associated preference. |
| 471 */ |
| 472 cr.defineProperty(PrefSelect, 'pref', cr.PropertyKind.ATTR); |
| 473 |
| 474 /** |
| 475 * The data type of the associated preference, only relevant for derived |
| 476 * classes that support different data types. |
| 477 */ |
| 478 cr.defineProperty(PrefSelect, 'dataType', cr.PropertyKind.ATTR); |
| 479 |
| 480 /** |
| 481 * Whether this input element is part of a dialog. If so, changes take effect |
| 482 * in the settings UI immediately but are only actually committed when the |
| 483 * user confirms the dialog. If the user cancels the dialog instead, the |
| 484 * changes are rolled back in the settings UI and never committed. |
| 485 */ |
| 486 cr.defineProperty(PrefSelect, 'dialogPref', cr.PropertyKind.BOOL_ATTR); |
| 487 |
| 488 /** |
| 489 * Whether the associated preference is controlled by a source other than the |
| 490 * user's setting (can be 'policy', 'extension', 'recommended' or unset). |
| 491 */ |
| 492 cr.defineProperty(PrefSelect, 'controlledBy', cr.PropertyKind.ATTR); |
| 493 |
| 494 /** |
| 495 * The user metric string. |
| 496 */ |
| 497 cr.defineProperty(PrefSelect, 'metric', cr.PropertyKind.ATTR); |
| 498 |
454 ///////////////////////////////////////////////////////////////////////////// | 499 ///////////////////////////////////////////////////////////////////////////// |
455 // PrefTextField class: | 500 // PrefTextField class: |
456 | 501 |
457 // Define a constructor that uses an input element as its underlying element. | 502 // Define a constructor that uses an input element as its underlying element. |
458 var PrefTextField = cr.ui.define('input'); | 503 var PrefTextField = cr.ui.define('input'); |
459 | 504 |
460 PrefTextField.prototype = { | 505 PrefTextField.prototype = { |
461 // Set up the prototype chain | 506 // Set up the prototype chain |
462 __proto__: PrefInputElement.prototype, | 507 __proto__: PrefInputElement.prototype, |
463 | 508 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 PrefInputElement: PrefInputElement, | 630 PrefInputElement: PrefInputElement, |
586 PrefNumber: PrefNumber, | 631 PrefNumber: PrefNumber, |
587 PrefRadio: PrefRadio, | 632 PrefRadio: PrefRadio, |
588 PrefRange: PrefRange, | 633 PrefRange: PrefRange, |
589 PrefSelect: PrefSelect, | 634 PrefSelect: PrefSelect, |
590 PrefTextField: PrefTextField, | 635 PrefTextField: PrefTextField, |
591 PrefPortNumber: PrefPortNumber, | 636 PrefPortNumber: PrefPortNumber, |
592 PrefButton: PrefButton | 637 PrefButton: PrefButton |
593 }; | 638 }; |
594 }); | 639 }); |
OLD | NEW |