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

Side by Side Diff: chrome/browser/resources/options/autofill_options.js

Issue 3125039: DOMUI: Several fixes for AutoFill page. (Closed)
Patch Set: Created 10 years, 4 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
« no previous file with comments | « chrome/browser/resources/options/autofill_options.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 var OptionsPage = options.OptionsPage; 6 var OptionsPage = options.OptionsPage;
7 7
8 // The offset of the first profile in either the address list or the credit 8 // The offset of the first profile in either the address list or the credit
9 // card list. Consists of the header and the horizontal rule. 9 // card list. Consists of the header and the horizontal rule.
10 const profileOffset = 2; 10 const profileOffset = 2;
(...skipping 19 matching lines...) Expand all
30 cr.addSingletonGetter(AutoFillOptions); 30 cr.addSingletonGetter(AutoFillOptions);
31 31
32 AutoFillOptions.prototype = { 32 AutoFillOptions.prototype = {
33 __proto__: OptionsPage.prototype, 33 __proto__: OptionsPage.prototype,
34 34
35 initializePage: function() { 35 initializePage: function() {
36 OptionsPage.prototype.initializePage.call(this); 36 OptionsPage.prototype.initializePage.call(this);
37 37
38 var self = this; 38 var self = this;
39 $('profileList').onchange = function(event) { 39 $('profileList').onchange = function(event) {
40 self.updateRemoveButtonState_(); 40 self.updateButtonState_();
41 }; 41 };
42 $('addAddressButton').onclick = function(event) { 42 $('addAddressButton').onclick = function(event) {
43 OptionsPage.showOverlay('autoFillEditAddressOverlay'); 43 self.showAddAddressOverlay_();
44 }; 44 };
45 $('addCreditCardButton').onclick = function(event) { 45 $('addCreditCardButton').onclick = function(event) {
46 OptionsPage.showOverlay('autoFillEditCreditCardOverlay'); 46 self.showAddCreditCardOverlay_();
47 }; 47 };
48 48
49 Preferences.getInstance().addEventListener('autofill.enabled', 49 Preferences.getInstance().addEventListener('autofill.enabled',
50 cr.bind(self.updateButtonState_, self)); 50 cr.bind(self.updateEnabledState_, self));
51 }, 51 },
52 52
53 /** 53 /**
54 * Sets the enabled state of the button controls based on the current state 54 * Sets the enabled state of the button controls based on the current state
55 * of the |autoFillEnabled| checkbox. 55 * of the |autoFillEnabled| checkbox.
56 * @private 56 * @private
57 */ 57 */
58 updateButtonState_: function() { 58 updateEnabledState_: function() {
59 var checkbox = $('autoFillEnabled'); 59 var checkbox = $('autoFillEnabled');
60 $('addAddressButton').disabled = $('addCreditCardButton').disabled = 60 $('addAddressButton').disabled = $('addCreditCardButton').disabled =
61 $('editButton').disabled = $('autoFillRemoveButton').disabled = 61 $('editButton').disabled = $('autoFillRemoveButton').disabled =
62 !checkbox.checked; 62 !checkbox.checked;
63 }, 63 },
64 64
65 /** 65 /**
66 * Shows the 'Add address' overlay, specifically by loading the
67 * 'Edit address' overlay, emptying the input fields and modifying the
68 * overlay title.
69 * @private
70 */
71 showAddAddressOverlay_: function() {
72 var title = localStrings.getString('addAddressTitle');
73 AutoFillEditAddressOverlay.setTitle(title);
74 AutoFillEditAddressOverlay.clearInputFields();
75 OptionsPage.showOverlay('autoFillEditAddressOverlay');
76 },
77
78 /**
79 * Shows the 'Add credit card' overlay, specifically by loading the
80 * 'Edit credit card' overlay, emptying the input fields and modifying the
81 * overlay title.
82 * @private
83 */
84 showAddCreditCardOverlay_: function() {
85 var title = localStrings.getString('addCreditCardTitle');
86 AutoFillEditCreditCardOverlay.setTitle(title);
87 AutoFillEditCreditCardOverlay.clearInputFields();
88 OptionsPage.showOverlay('autoFillEditCreditCardOverlay');
89 },
90
91 /**
66 * Resets the address list. This method leaves the header and horizontal 92 * Resets the address list. This method leaves the header and horizontal
67 * rule unchanged. 93 * rule unchanged.
68 * @private 94 * @private
69 */ 95 */
70 resetAddresses_: function() { 96 resetAddresses_: function() {
71 var profiles = $('profileList'); 97 var profiles = $('profileList');
72 for (var i = 0; i < this.numAddresses; ++i) 98 for (var i = 0; i < this.numAddresses; ++i)
73 profiles.remove(profileOffset); 99 profiles.remove(profileOffset);
74 }, 100 },
75 101
(...skipping 19 matching lines...) Expand all
95 profileList = $('profileList'); 121 profileList = $('profileList');
96 var blankAddress = 122 var blankAddress =
97 profileList.options[profileOffset + this.numAddresses]; 123 profileList.options[profileOffset + this.numAddresses];
98 this.numAddresses = addresses.length; 124 this.numAddresses = addresses.length;
99 for (var i = 0; i < this.numAddresses; i++) { 125 for (var i = 0; i < this.numAddresses; i++) {
100 var address = addresses[i]; 126 var address = addresses[i];
101 var option = new Option(address['label']); 127 var option = new Option(address['label']);
102 profileList.add(option, blankAddress); 128 profileList.add(option, blankAddress);
103 } 129 }
104 130
105 this.updateRemoveButtonState_(); 131 this.updateButtonState_();
106 }, 132 },
107 133
108 /** 134 /**
109 * Updates the credit card list with the given entries. 135 * Updates the credit card list with the given entries.
110 * @private 136 * @private
111 * @param {Array} creditCards List of credit cards. 137 * @param {Array} creditCards List of credit cards.
112 */ 138 */
113 updateCreditCards_: function(creditCards) { 139 updateCreditCards_: function(creditCards) {
114 this.resetCreditCards_(); 140 this.resetCreditCards_();
115 profileList = $('profileList'); 141 profileList = $('profileList');
116 this.numCreditCards = creditCards.length; 142 this.numCreditCards = creditCards.length;
117 for (var i = 0; i < this.numCreditCards; i++) { 143 for (var i = 0; i < this.numCreditCards; i++) {
118 var creditCard = creditCards[i]; 144 var creditCard = creditCards[i];
119 var option = new Option(creditCard['label']); 145 var option = new Option(creditCard['label']);
120 profileList.add(option, null); 146 profileList.add(option, null);
121 } 147 }
122 148
123 this.updateRemoveButtonState_(); 149 this.updateButtonState_();
124 }, 150 },
125 151
126 /** 152 /**
127 * Sets the enabled state of the AutoFill Remove button based on the current 153 * Sets the enabled state of the AutoFill Edit and Remove buttons based on
128 * selection in the profile list. 154 * the current selection in the profile list.
129 * @private 155 * @private
130 */ 156 */
131 updateRemoveButtonState_: function() { 157 updateButtonState_: function() {
132 $('autoFillRemoveButton').disabled = 158 $('autoFillRemoveButton').disabled = $('autoFillEditButton').disabled =
133 ($('profileList').selectedIndex == -1); 159 ($('profileList').selectedIndex == -1);
134 }, 160 },
135 }; 161 };
136 162
137 AutoFillOptions.updateAddresses = function(addresses) { 163 AutoFillOptions.updateAddresses = function(addresses) {
138 AutoFillOptions.getInstance().updateAddresses_(addresses); 164 AutoFillOptions.getInstance().updateAddresses_(addresses);
139 }; 165 };
140 166
141 AutoFillOptions.updateCreditCards = function(creditCards) { 167 AutoFillOptions.updateCreditCards = function(creditCards) {
142 AutoFillOptions.getInstance().updateCreditCards_(creditCards); 168 AutoFillOptions.getInstance().updateCreditCards_(creditCards);
143 }; 169 };
144 170
145 // Export 171 // Export
146 return { 172 return {
147 AutoFillOptions: AutoFillOptions 173 AutoFillOptions: AutoFillOptions
148 }; 174 };
149 175
150 }); 176 });
151 177
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/autofill_options.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698