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

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

Issue 9296038: [uber] Redoing the homepage selection UI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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
614 /** 637 /**
615 * Initialization function for the cr.ui framework. 638 * Initialization function for the cr.ui framework.
616 */ 639 */
617 decorate: function() { 640 decorate: function() {
618 var self = this; 641 var self = this;
619 642
620 // Listen to pref changes. 643 // Listen to pref changes.
621 Preferences.getInstance().addEventListener(this.pref, 644 Preferences.getInstance().addEventListener(this.pref,
622 function(event) { 645 function(event) {
623 self.value = event.value && event.value['value'] != undefined ? 646 self.value = event.value && event.value['value'] != undefined ?
624 event.value['value'] : event.value; 647 event.value['value'] : event.value;
625 648
626 updateElementState_(self, event); 649 updateElementState_(self, event);
650
651 self.prefValue_ = self.value;
627 }); 652 });
628 653
629 // Listen to user events. 654 // Listen to user events.
630 this.addEventListener('change', 655 if (!self.dialogPref) {
631 function(e) { 656 this.addEventListener('change', function(e) {
632 switch(self.dataType) { 657 self.savePrefState.bind(self);
633 case 'number': 658 });
634 Preferences.setIntegerPref(self.pref, self.value, self.metric); 659 }
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 });
647 660
648 window.addEventListener('unload', 661 window.addEventListener('unload',
649 function() { 662 function() {
650 if (document.activeElement == self) 663 if (document.activeElement == self)
651 self.blur(); 664 self.blur();
652 }); 665 });
653 }, 666 },
654 667
655 /** 668 /**
656 * See |updateDisabledState_| above. 669 * See |updateDisabledState_| above.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 PrefNumber: PrefNumber, 758 PrefNumber: PrefNumber,
746 PrefNumeric: PrefNumeric, 759 PrefNumeric: PrefNumeric,
747 PrefRadio: PrefRadio, 760 PrefRadio: PrefRadio,
748 PrefRange: PrefRange, 761 PrefRange: PrefRange,
749 PrefSelect: PrefSelect, 762 PrefSelect: PrefSelect,
750 PrefTextField: PrefTextField, 763 PrefTextField: PrefTextField,
751 PrefButton: PrefButton 764 PrefButton: PrefButton
752 }; 765 };
753 766
754 }); 767 });
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