OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 cr.define('options', function() { |
| 6 const OptionsPage = options.OptionsPage; |
| 7 |
| 8 /** |
| 9 * AutoFillEditCreditCardOverlay class |
| 10 * Encapsulated handling of the 'Add Page' overlay page. |
| 11 * @class |
| 12 */ |
| 13 function AutoFillEditCreditCardOverlay() { |
| 14 OptionsPage.call(this, 'autoFillEditCreditCardOverlay', |
| 15 templateData.autoFillEditCreditCardTitle, |
| 16 'autoFillEditCreditCardOverlay'); |
| 17 } |
| 18 |
| 19 cr.addSingletonGetter(AutoFillEditCreditCardOverlay); |
| 20 |
| 21 AutoFillEditCreditCardOverlay.prototype = { |
| 22 __proto__: OptionsPage.prototype, |
| 23 |
| 24 /** |
| 25 * Initializes the page. |
| 26 */ |
| 27 initializePage: function() { |
| 28 OptionsPage.prototype.initializePage.call(this); |
| 29 |
| 30 var self = this; |
| 31 $('autoFillEditCreditCardCancelButton').onclick = function(event) { |
| 32 self.dismissOverlay_(); |
| 33 } |
| 34 |
| 35 self.setDefaultSelectOptions_(); |
| 36 }, |
| 37 |
| 38 /** |
| 39 * Clears any uncommited input, and dismisses the overlay. |
| 40 * @private |
| 41 */ |
| 42 dismissOverlay_: function() { |
| 43 $('fullName').value = ''; |
| 44 $('companyName').value = ''; |
| 45 $('addrLine1').value = ''; |
| 46 $('addrLine2').value = ''; |
| 47 $('city').value = ''; |
| 48 $('state').value = ''; |
| 49 $('zipCode').value = ''; |
| 50 $('phone').value = ''; |
| 51 $('fax').value = ''; |
| 52 $('email').value = ''; |
| 53 OptionsPage.clearOverlays(); |
| 54 }, |
| 55 |
| 56 /** |
| 57 * Sets the default values of the options in the 'Billing address' and |
| 58 * 'Expiration date' select controls. |
| 59 * @private |
| 60 */ |
| 61 setDefaultSelectOptions_: function() { |
| 62 // Set the 'Billing address' default option. |
| 63 var existingAddress = document.createElement('option'); |
| 64 existingAddress.text = localStrings.getString('chooseExistingAddress'); |
| 65 existingAddress.value = 'existingAddress'; |
| 66 |
| 67 var billingAddress = $('billingAddress'); |
| 68 billingAddress.add(existingAddress, null); |
| 69 |
| 70 // Set the 'Expiration month' default options. |
| 71 var expirationMonth = $('expirationMonth'); |
| 72 for (var i = 1; i <= 12; ++i) { |
| 73 var text; |
| 74 if (i < 10) |
| 75 text = '0' + i; |
| 76 else |
| 77 text = i; |
| 78 |
| 79 var option = document.createElement('option'); |
| 80 option.text = text; |
| 81 option.value = text; |
| 82 expirationMonth.add(option, null); |
| 83 } |
| 84 |
| 85 // Set the 'Expiration year' default options. |
| 86 var expirationYear = $('expirationYear'); |
| 87 var date = new Date(); |
| 88 var year = date.getFullYear(); |
| 89 for (var i = 0; i < 10; ++i) { |
| 90 var text = parseInt(year) + i; |
| 91 var option = document.createElement('option'); |
| 92 option.text = text; |
| 93 option.value = text; |
| 94 expirationYear.add(option, null); |
| 95 } |
| 96 } |
| 97 }; |
| 98 |
| 99 // Export |
| 100 return { |
| 101 AutoFillEditCreditCardOverlay: AutoFillEditCreditCardOverlay |
| 102 }; |
| 103 |
| 104 }); |
OLD | NEW |