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

Unified Diff: chrome/browser/resources/settings/passwords_and_forms_page/credit_card_edit_dialog.js

Issue 2617663002: WIP: run clang-format-js on lots of things (Closed)
Patch Set: merge Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/settings/passwords_and_forms_page/credit_card_edit_dialog.js
diff --git a/chrome/browser/resources/settings/passwords_and_forms_page/credit_card_edit_dialog.js b/chrome/browser/resources/settings/passwords_and_forms_page/credit_card_edit_dialog.js
index 32a7dd3fe91c241ac72294a689a149ff1f1fcf10..0bcad6b0becde6d8a7144846a1c6d61f711eec53 100644
--- a/chrome/browser/resources/settings/passwords_and_forms_page/credit_card_edit_dialog.js
+++ b/chrome/browser/resources/settings/passwords_and_forms_page/credit_card_edit_dialog.js
@@ -8,136 +8,148 @@
*/
(function() {
-'use strict';
+ 'use strict';
+
+ Polymer({
+ is: 'settings-credit-card-edit-dialog',
+
+ properties: {
+ /**
+ * The credit card being edited.
+ * @type {!chrome.autofillPrivate.CreditCardEntry}
+ */
+ creditCard: Object,
+
+ /**
+ * The actual title that's used for this dialog. Will be context sensitive
+ * based on if |creditCard| is being created or edited.
+ * @private
+ */
+ title_: String,
+
+ /**
+ * The list of months to show in the dropdown.
+ * @private {!Array<string>}
+ */
+ monthList_: {
+ type: Array,
+ value: [
+ '01',
+ '02',
+ '03',
+ '04',
+ '05',
+ '06',
+ '07',
+ '08',
+ '09',
+ '10',
+ '11',
+ '12',
+ ],
+ },
+
+ /**
+ * The list of years to show in the dropdown.
+ * @private {!Array<string>}
+ */
+ yearList_: Array,
+
+ /** @private */
+ expirationYear_: String,
+
+ /** @private {string|undefined} */
+ expirationMonth_: String,
+ },
-Polymer({
- is: 'settings-credit-card-edit-dialog',
+ behaviors: [
+ I18nBehavior,
+ ],
- properties: {
/**
- * The credit card being edited.
- * @type {!chrome.autofillPrivate.CreditCardEntry}
- */
- creditCard: Object,
+ * @return {boolean} True iff the provided expiration date is passed.
+ * @private
+ */
+ checkIfCardExpired_: function(expirationMonth_, expirationYear_) {
+ var now = new Date();
+ return (
+ expirationYear_ < now.getFullYear() ||
+ (expirationYear_ == now.getFullYear() &&
+ expirationMonth_ <= now.getMonth()));
+ },
- /**
- * The actual title that's used for this dialog. Will be context sensitive
- * based on if |creditCard| is being created or edited.
- * @private
- */
- title_: String,
+ /** @override */
+ attached: function() {
+ this.title_ = this.i18n(
+ this.creditCard.guid ? 'editCreditCardTitle' : 'addCreditCardTitle');
+
+ // Add a leading '0' if a month is 1 char.
+ if (this.creditCard.expirationMonth.length == 1)
+ this.creditCard.expirationMonth = '0' + this.creditCard.expirationMonth;
+
+ var date = new Date();
+ var firstYear = date.getFullYear();
+ var lastYear = firstYear + 9; // Show next 9 years (10 total).
+ var selectedYear = parseInt(this.creditCard.expirationYear, 10);
+
+ // |selectedYear| must be valid and between first and last years.
+ if (!selectedYear)
+ selectedYear = firstYear;
+ else if (selectedYear < firstYear)
+ firstYear = selectedYear;
+ else if (selectedYear > lastYear)
+ lastYear = selectedYear;
+
+ var yearList = [];
+ for (var i = firstYear; i <= lastYear; ++i) {
+ yearList.push(i.toString());
+ }
+ this.yearList_ = yearList;
+
+ this.async(function() {
+ this.expirationYear_ = selectedYear.toString();
+ this.expirationMonth_ = this.creditCard.expirationMonth;
+ this.$.dialog.showModal();
+ }.bind(this));
+ },
+
+ /** Closes the dialog. */
+ close: function() {
+ this.$.dialog.close();
+ },
/**
- * The list of months to show in the dropdown.
- * @private {!Array<string>}
+ * Handler for tapping the 'cancel' button. Should just dismiss the dialog.
+ * @private
*/
- monthList_: {
- type: Array,
- value: [
- '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12',
- ],
+ onCancelButtonTap_: function() {
+ this.$.dialog.cancel();
},
/**
- * The list of years to show in the dropdown.
- * @private {!Array<string>}
+ * Handler for tapping the save button.
+ * @private
*/
- yearList_: Array,
+ onSaveButtonTap_: function() {
+ // If the card is expired, reflect the error to the user.
+ // Otherwise, update the card, save and close the dialog.
+ if (!this.checkIfCardExpired_(
+ this.expirationMonth_, this.expirationYear_)) {
+ this.creditCard.expirationYear = this.expirationYear_;
+ this.creditCard.expirationMonth = this.expirationMonth_;
+ this.fire('save-credit-card', this.creditCard);
+ this.close();
+ }
+ },
/** @private */
- expirationYear_: String,
-
- /** @private {string|undefined} */
- expirationMonth_: String,
- },
-
- behaviors: [
- I18nBehavior,
- ],
-
- /**
- * @return {boolean} True iff the provided expiration date is passed.
- * @private
- */
- checkIfCardExpired_: function(expirationMonth_, expirationYear_) {
- var now = new Date();
- return (expirationYear_ < now.getFullYear() ||
- (expirationYear_ == now.getFullYear() &&
- expirationMonth_ <= now.getMonth()));
- },
-
- /** @override */
- attached: function() {
- this.title_ = this.i18n(
- this.creditCard.guid ? 'editCreditCardTitle' : 'addCreditCardTitle');
-
- // Add a leading '0' if a month is 1 char.
- if (this.creditCard.expirationMonth.length == 1)
- this.creditCard.expirationMonth = '0' + this.creditCard.expirationMonth;
-
- var date = new Date();
- var firstYear = date.getFullYear();
- var lastYear = firstYear + 9; // Show next 9 years (10 total).
- var selectedYear = parseInt(this.creditCard.expirationYear, 10);
-
- // |selectedYear| must be valid and between first and last years.
- if (!selectedYear)
- selectedYear = firstYear;
- else if (selectedYear < firstYear)
- firstYear = selectedYear;
- else if (selectedYear > lastYear)
- lastYear = selectedYear;
-
- var yearList = [];
- for (var i = firstYear; i <= lastYear; ++i) {
- yearList.push(i.toString());
- }
- this.yearList_ = yearList;
-
- this.async(function() {
- this.expirationYear_ = selectedYear.toString();
- this.expirationMonth_ = this.creditCard.expirationMonth;
- this.$.dialog.showModal();
- }.bind(this));
- },
-
- /** Closes the dialog. */
- close: function() {
- this.$.dialog.close();
- },
-
- /**
- * Handler for tapping the 'cancel' button. Should just dismiss the dialog.
- * @private
- */
- onCancelButtonTap_: function() {
- this.$.dialog.cancel();
- },
+ onMonthChange_: function() {
+ this.expirationMonth_ = this.monthList_[this.$.month.selectedIndex];
+ },
- /**
- * Handler for tapping the save button.
- * @private
- */
- onSaveButtonTap_: function() {
- // If the card is expired, reflect the error to the user.
- // Otherwise, update the card, save and close the dialog.
- if (!this.checkIfCardExpired_(this.expirationMonth_,
- this.expirationYear_)) {
- this.creditCard.expirationYear = this.expirationYear_;
- this.creditCard.expirationMonth = this.expirationMonth_;
- this.fire('save-credit-card', this.creditCard);
- this.close();
- }
- },
-
- /** @private */
- onMonthChange_: function() {
- this.expirationMonth_ = this.monthList_[this.$.month.selectedIndex];
- },
-
- /** @private */
- onYearChange_: function() {
- this.expirationYear_ = this.yearList_[this.$.year.selectedIndex];
- },
-});
+ /** @private */
+ onYearChange_: function() {
+ this.expirationYear_ = this.yearList_[this.$.year.selectedIndex];
+ },
+ });
})();

Powered by Google App Engine
This is Rietveld 408576698