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 /** @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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 var year = parseInt(date.getFullYear()); | 173 var year = parseInt(date.getFullYear()); |
174 for (var i = 0; i < 10; ++i) { | 174 for (var i = 0; i < 10; ++i) { |
175 var text = year + i; | 175 var text = year + i; |
176 if (expYear == String(text)) | 176 if (expYear == String(text)) |
177 $('expiration-year').selectedIndex = i; | 177 $('expiration-year').selectedIndex = i; |
178 } | 178 } |
179 }, | 179 }, |
180 | 180 |
181 /** | 181 /** |
182 * Loads the credit card data from |creditCard|, sets the input fields based | 182 * Loads the credit card data from |creditCard|, sets the input fields based |
183 * on this data and stores the GUID of the credit card. | 183 * on this data and stores the GUID of the credit card. If |creditCard| is |
| 184 * null, this is an "Add New" dialog. Focus the first field. |
184 * @private | 185 * @private |
185 */ | 186 */ |
186 loadCreditCard_: function(creditCard) { | 187 loadCreditCard_: function(creditCard) { |
| 188 if (!creditCard) { |
| 189 // Adding a new card --- focus the first element. |
| 190 this.pageDiv.querySelector('input').focus(); |
| 191 return; |
| 192 } |
| 193 |
187 this.setInputFields_(creditCard); | 194 this.setInputFields_(creditCard); |
188 this.inputFieldChanged_(); | 195 this.inputFieldChanged_(); |
189 this.guid_ = creditCard.guid; | 196 this.guid_ = creditCard.guid; |
190 }, | 197 }, |
191 }; | 198 }; |
192 | 199 |
193 AutofillEditCreditCardOverlay.loadCreditCard = function(creditCard) { | 200 AutofillEditCreditCardOverlay.loadCreditCard = function(creditCard) { |
194 AutofillEditCreditCardOverlay.getInstance().loadCreditCard_(creditCard); | 201 AutofillEditCreditCardOverlay.getInstance().loadCreditCard_(creditCard); |
195 }; | 202 }; |
196 | 203 |
197 AutofillEditCreditCardOverlay.setTitle = function(title) { | 204 AutofillEditCreditCardOverlay.setTitle = function(title) { |
198 $('autofill-credit-card-title').textContent = title; | 205 $('autofill-credit-card-title').textContent = title; |
199 }; | 206 }; |
200 | 207 |
201 // Export | 208 // Export |
202 return { | 209 return { |
203 AutofillEditCreditCardOverlay: AutofillEditCreditCardOverlay | 210 AutofillEditCreditCardOverlay: AutofillEditCreditCardOverlay |
204 }; | 211 }; |
205 }); | 212 }); |
OLD | NEW |