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

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

Issue 553573003: Compile chrome://settings, part 3: 167 proper errors left (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@G_options_errors_1
Patch Set: fixed crash on assertInstanceof Created 6 years, 3 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
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 cr.define('options', function() { 5 cr.define('options', function() {
6 /** @const */ var Page = cr.ui.pageManager.Page; 6 /** @const */ var Page = cr.ui.pageManager.Page;
7 /** @const */ var PageManager = cr.ui.pageManager.PageManager; 7 /** @const */ var PageManager = cr.ui.pageManager.PageManager;
8 8
9 /** 9 /**
10 * AutofillEditCreditCardOverlay class 10 * AutofillEditCreditCardOverlay class
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 /** 103 /**
104 * Sets the default values of the options in the 'Expiration date' select 104 * Sets the default values of the options in the 'Expiration date' select
105 * controls. 105 * controls.
106 * @private 106 * @private
107 */ 107 */
108 setDefaultSelectOptions_: function() { 108 setDefaultSelectOptions_: function() {
109 // Set the 'Expiration month' default options. 109 // Set the 'Expiration month' default options.
110 var expirationMonth = $('expiration-month'); 110 var expirationMonth = $('expiration-month');
111 expirationMonth.options.length = 0; 111 expirationMonth.options.length = 0;
112 for (var i = 1; i <= 12; ++i) { 112 for (var i = 1; i <= 12; ++i) {
113 var text; 113 var text;
Dan Beam 2014/09/11 02:53:08 var text = (i < 10 ? '0' : '') + i;
Vitaly Pavlenko 2014/09/11 04:16:25 Done.
114 if (i < 10) 114 if (i < 10)
115 text = '0' + i; 115 text = '0' + i;
116 else 116 else
117 text = i; 117 text = i;
118 118
119 var option = document.createElement('option'); 119 var option = document.createElement('option');
120 option.text = text; 120 option.text = String(text);
121 option.value = text; 121 option.value = text;
Dan Beam 2014/09/11 02:53:08 option.text = options.value = text;
Vitaly Pavlenko 2014/09/11 04:16:24 Done.
122 expirationMonth.add(option, null); 122 expirationMonth.add(option, null);
123 } 123 }
124 124
125 // Set the 'Expiration year' default options. 125 // Set the 'Expiration year' default options.
126 var expirationYear = $('expiration-year'); 126 var expirationYear = $('expiration-year');
127 expirationYear.options.length = 0; 127 expirationYear.options.length = 0;
128 128
129 var date = new Date(); 129 var date = new Date();
130 var year = parseInt(date.getFullYear(), 10); 130 var year = parseInt(date.getFullYear(), 10);
131 for (var i = 0; i < 10; ++i) { 131 for (var i = 0; i < 10; ++i) {
132 var text = year + i; 132 var text = year + i;
133 var option = document.createElement('option'); 133 var option = document.createElement('option');
134 option.text = text; 134 option.text = String(text);
135 option.value = text; 135 option.value = text;
136 expirationYear.add(option, null); 136 expirationYear.add(option, null);
137 } 137 }
138 }, 138 },
139 139
140 /** 140 /**
141 * Clears the value of each input field. 141 * Clears the value of each input field.
142 * @private 142 * @private
143 */ 143 */
144 clearInputFields_: function() { 144 clearInputFields_: function() {
145 $('name-on-card').value = ''; 145 $('name-on-card').value = '';
146 $('credit-card-number').value = ''; 146 $('credit-card-number').value = '';
147 $('expiration-month').selectedIndex = 0; 147 $('expiration-month').selectedIndex = 0;
148 $('expiration-year').selectedIndex = 0; 148 $('expiration-year').selectedIndex = 0;
149 149
150 // Reset the enabled status of the 'Ok' button. 150 // Reset the enabled status of the 'Ok' button.
151 this.inputFieldChanged_(); 151 this.inputFieldChanged_();
152 }, 152 },
153 153
154 /** 154 /**
155 * Sets the value of each input field according to |creditCard| 155 * Sets the value of each input field according to |creditCard|
156 * @param {CreditCardData} creditCard
156 * @private 157 * @private
157 */ 158 */
158 setInputFields_: function(creditCard) { 159 setInputFields_: function(creditCard) {
159 $('name-on-card').value = creditCard.nameOnCard; 160 $('name-on-card').value = creditCard.nameOnCard;
160 $('credit-card-number').value = creditCard.creditCardNumber; 161 $('credit-card-number').value = creditCard.creditCardNumber;
161 162
162 // The options for the year select control may be out-dated at this point, 163 // The options for the year select control may be out-dated at this point,
163 // e.g. the user opened the options page before midnight on New Year's Eve 164 // e.g. the user opened the options page before midnight on New Year's Eve
164 // and then loaded a credit card profile to edit in the new year, so 165 // and then loaded a credit card profile to edit in the new year, so
165 // reload the select options just to be safe. 166 // reload the select options just to be safe.
166 this.setDefaultSelectOptions_(); 167 this.setDefaultSelectOptions_();
167 168
168 var idx = parseInt(creditCard.expirationMonth, 10); 169 var idx = parseInt(creditCard.expirationMonth, 10);
169 $('expiration-month').selectedIndex = idx - 1; 170 $('expiration-month').selectedIndex = idx - 1;
170 171
171 expYear = creditCard.expirationYear; 172 var expYear = creditCard.expirationYear;
172 var date = new Date(); 173 var date = new Date();
173 var year = parseInt(date.getFullYear(), 10); 174 var year = parseInt(date.getFullYear(), 10);
174 for (var i = 0; i < 10; ++i) { 175 for (var i = 0; i < 10; ++i) {
175 var text = year + i; 176 var text = year + i;
176 if (expYear == String(text)) 177 if (expYear == String(text))
177 $('expiration-year').selectedIndex = i; 178 $('expiration-year').selectedIndex = i;
178 } 179 }
179 }, 180 },
180 181
181 /** 182 /**
182 * Called to prepare the overlay when a new card is being added. 183 * Called to prepare the overlay when a new card is being added.
183 * @private 184 * @private
184 */ 185 */
185 prepForNewCard_: function() { 186 prepForNewCard_: function() {
186 // Focus the first element. 187 // Focus the first element.
187 this.pageDiv.querySelector('input').focus(); 188 this.pageDiv.querySelector('input').focus();
188 }, 189 },
189 190
190 /** 191 /**
191 * Loads the credit card data from |creditCard|, sets the input fields based 192 * Loads the credit card data from |creditCard|, sets the input fields based
192 * on this data and stores the GUID of the credit card. 193 * on this data and stores the GUID of the credit card.
194 * @param {CreditCardData} creditCard
193 * @private 195 * @private
194 */ 196 */
195 loadCreditCard_: function(creditCard) { 197 loadCreditCard_: function(creditCard) {
196 this.setInputFields_(creditCard); 198 this.setInputFields_(creditCard);
197 this.inputFieldChanged_(); 199 this.inputFieldChanged_();
198 this.guid_ = creditCard.guid; 200 this.guid_ = creditCard.guid;
199 }, 201 },
200 }; 202 };
201 203
202 AutofillEditCreditCardOverlay.prepForNewCard = function() { 204 AutofillEditCreditCardOverlay.prepForNewCard = function() {
203 AutofillEditCreditCardOverlay.getInstance().prepForNewCard_(); 205 AutofillEditCreditCardOverlay.getInstance().prepForNewCard_();
204 }; 206 };
205 207
206 AutofillEditCreditCardOverlay.loadCreditCard = function(creditCard) { 208 AutofillEditCreditCardOverlay.loadCreditCard = function(creditCard) {
207 AutofillEditCreditCardOverlay.getInstance().loadCreditCard_(creditCard); 209 AutofillEditCreditCardOverlay.getInstance().loadCreditCard_(creditCard);
208 }; 210 };
209 211
210 AutofillEditCreditCardOverlay.setTitle = function(title) { 212 AutofillEditCreditCardOverlay.setTitle = function(title) {
211 $('autofill-credit-card-title').textContent = title; 213 $('autofill-credit-card-title').textContent = title;
212 }; 214 };
213 215
214 // Export 216 // Export
215 return { 217 return {
216 AutofillEditCreditCardOverlay: AutofillEditCreditCardOverlay 218 AutofillEditCreditCardOverlay: AutofillEditCreditCardOverlay
217 }; 219 };
218 }); 220 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698