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

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

Issue 9353019: Revert 120803 - [uber] Redoing the homepage selection UI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 10 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) 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 // TODO(jhawkins): Add dialog-pref support to all preference controls. 5 // TODO(jhawkins): Add dialog-pref support to all preference controls.
6 6
7 cr.define('options', function() { 7 cr.define('options', function() {
8 8
9 var Preferences = options.Preferences; 9 var Preferences = options.Preferences;
10 10
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 ///////////////////////////////////////////////////////////////////////////// 604 /////////////////////////////////////////////////////////////////////////////
605 // PrefTextField class: 605 // PrefTextField class:
606 606
607 // Define a constructor that uses an input element as its underlying element. 607 // Define a constructor that uses an input element as its underlying element.
608 var PrefTextField = cr.ui.define('input'); 608 var PrefTextField = cr.ui.define('input');
609 609
610 PrefTextField.prototype = { 610 PrefTextField.prototype = {
611 // Set up the prototype chain 611 // Set up the prototype chain
612 __proto__: HTMLInputElement.prototype, 612 __proto__: HTMLInputElement.prototype,
613 613
614 prefValue_: null,
615
616 savePrefState: function() {
617 switch(this.dataType) {
618 case 'number':
619 Preferences.setIntegerPref(this.pref, this.value, this.metric);
620 break;
621 case 'double':
622 Preferences.setDoublePref(this.pref, this.value, this.metric);
623 break;
624 case 'url':
625 Preferences.setURLPref(this.pref, this.value, this.metric);
626 break;
627 default:
628 Preferences.setStringPref(this.pref, this.value, this.metric);
629 break;
630 }
631 },
632
633 resetPrefState: function() {
634 this.value = this.prefValue_;
635 },
636
637 /** 614 /**
638 * Initialization function for the cr.ui framework. 615 * Initialization function for the cr.ui framework.
639 */ 616 */
640 decorate: function() { 617 decorate: function() {
641 var self = this; 618 var self = this;
642 619
643 // Listen to pref changes. 620 // Listen to pref changes.
644 Preferences.getInstance().addEventListener(this.pref, 621 Preferences.getInstance().addEventListener(this.pref,
645 function(event) { 622 function(event) {
646 self.value = event.value && event.value['value'] != undefined ? 623 self.value = event.value && event.value['value'] != undefined ?
647 event.value['value'] : event.value; 624 event.value['value'] : event.value;
648 625
649 updateElementState_(self, event); 626 updateElementState_(self, event);
650
651 self.prefValue_ = self.value;
652 }); 627 });
653 628
654 // Listen to user events. 629 // Listen to user events.
655 if (!self.dialogPref) { 630 this.addEventListener('change',
656 this.addEventListener('change', function(e) { 631 function(e) {
657 self.savePrefState.bind(self); 632 switch(self.dataType) {
658 }); 633 case 'number':
659 } 634 Preferences.setIntegerPref(self.pref, self.value, self.metric);
635 break;
636 case 'double':
637 Preferences.setDoublePref(self.pref, self.value, self.metric);
638 break;
639 case 'url':
640 Preferences.setURLPref(self.pref, self.value, self.metric);
641 break;
642 default:
643 Preferences.setStringPref(self.pref, self.value, self.metric);
644 break;
645 }
646 });
660 647
661 window.addEventListener('unload', 648 window.addEventListener('unload',
662 function() { 649 function() {
663 if (document.activeElement == self) 650 if (document.activeElement == self)
664 self.blur(); 651 self.blur();
665 }); 652 });
666 }, 653 },
667 654
668 /** 655 /**
669 * See |updateDisabledState_| above. 656 * See |updateDisabledState_| above.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 PrefNumber: PrefNumber, 745 PrefNumber: PrefNumber,
759 PrefNumeric: PrefNumeric, 746 PrefNumeric: PrefNumeric,
760 PrefRadio: PrefRadio, 747 PrefRadio: PrefRadio,
761 PrefRange: PrefRange, 748 PrefRange: PrefRange,
762 PrefSelect: PrefSelect, 749 PrefSelect: PrefSelect,
763 PrefTextField: PrefTextField, 750 PrefTextField: PrefTextField,
764 PrefButton: PrefButton 751 PrefButton: PrefButton
765 }; 752 };
766 753
767 }); 754 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/options2/options_page.css ('k') | chrome/browser/resources/options2/settings_dialog.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698