var expirationMonth = $('expiration-month');
expirationMonth.options.length = 0;
for (var i = 1; i <= 12; ++i) {
- var text;
- if (i < 10)
- text = '0' + i;
- else
- text = i;
+ var text = (i < 10 ? '0' : '') + i;
var option = document.createElement('option');
- option.text = text;
- option.value = text;
+ option.text = option.value = text;
expirationMonth.add(option, null);
}
expirationYear.options.length = 0;
var date = new Date();
- var year = parseInt(date.getFullYear());
+ var year = parseInt(date.getFullYear(), 10);
for (var i = 0; i < 10; ++i) {
var text = year + i;
var option = document.createElement('option');
- option.text = text;
+ option.text = String(text);
option.value = text;
expirationYear.add(option, null);
}
/**
* Sets the value of each input field according to |creditCard|
+ * @param {CreditCardData} creditCard
* @private
*/
setInputFields_: function(creditCard) {
var idx = parseInt(creditCard.expirationMonth, 10);
$('expiration-month').selectedIndex = idx - 1;
- expYear = creditCard.expirationYear;
+ var expYear = creditCard.expirationYear;
var date = new Date();
- var year = parseInt(date.getFullYear());
+ var year = parseInt(date.getFullYear(), 10);
for (var i = 0; i < 10; ++i) {
var text = year + i;
if (expYear == String(text))
},
/**
+ * Called to prepare the overlay when a new card is being added.
+ * @private
+ */
+ prepForNewCard_: function() {
+ // Focus the first element.
+ this.pageDiv.querySelector('input').focus();
+ },
+
+ /**
* Loads the credit card data from |creditCard|, sets the input fields based
* on this data and stores the GUID of the credit card.
+ * @param {CreditCardData} creditCard
* @private
*/
loadCreditCard_: function(creditCard) {
},
};
+ AutofillEditCreditCardOverlay.prepForNewCard = function() {
+ AutofillEditCreditCardOverlay.getInstance().prepForNewCard_();
+ };
+
AutofillEditCreditCardOverlay.loadCreditCard = function(creditCard) {
AutofillEditCreditCardOverlay.getInstance().loadCreditCard_(creditCard);
};