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

Side by Side Diff: chrome/browser/resources/settings/passwords_and_forms_page/credit_card_edit_dialog.js

Issue 2946563002: Run clang-format on .js files in c/b/r/settings (Closed)
Patch Set: Created 3 years, 6 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 /** 5 /**
6 * @fileoverview 'settings-credit-card-edit-dialog' is the dialog that allows 6 * @fileoverview 'settings-credit-card-edit-dialog' is the dialog that allows
7 * editing or creating a credit card entry. 7 * editing or creating a credit card entry.
8 */ 8 */
9 9
10 (function() { 10 (function() {
(...skipping 16 matching lines...) Expand all
27 */ 27 */
28 title_: String, 28 title_: String,
29 29
30 /** 30 /**
31 * The list of months to show in the dropdown. 31 * The list of months to show in the dropdown.
32 * @private {!Array<string>} 32 * @private {!Array<string>}
33 */ 33 */
34 monthList_: { 34 monthList_: {
35 type: Array, 35 type: Array,
36 value: [ 36 value: [
37 '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', 37 '01',
38 '02',
39 '03',
40 '04',
41 '05',
42 '06',
43 '07',
44 '08',
45 '09',
46 '10',
47 '11',
48 '12',
dschuyler 2017/06/16 23:09:07 Will removing the last comma bring this back to on
Dan Beam 2017/06/17 00:11:06 Done.
38 ], 49 ],
39 }, 50 },
40 51
41 /** 52 /**
42 * The list of years to show in the dropdown. 53 * The list of years to show in the dropdown.
43 * @private {!Array<string>} 54 * @private {!Array<string>}
44 */ 55 */
45 yearList_: Array, 56 yearList_: Array,
46 57
47 /** @private */ 58 /** @private */
48 expirationYear_: String, 59 expirationYear_: String,
49 60
50 /** @private {string|undefined} */ 61 /** @private {string|undefined} */
51 expirationMonth_: String, 62 expirationMonth_: String,
52 }, 63 },
53 64
54 behaviors: [ 65 behaviors: [
55 I18nBehavior, 66 I18nBehavior,
56 ], 67 ],
57 68
58 /** 69 /**
59 * @return {boolean} True iff the provided expiration date is passed. 70 * @return {boolean} True iff the provided expiration date is passed.
60 * @private 71 * @private
61 */ 72 */
62 checkIfCardExpired_: function(expirationMonth_, expirationYear_) { 73 checkIfCardExpired_: function(expirationMonth_, expirationYear_) {
63 var now = new Date(); 74 var now = new Date();
64 return (expirationYear_ < now.getFullYear() || 75 return (
65 (expirationYear_ == now.getFullYear() && 76 expirationYear_ < now.getFullYear() ||
66 expirationMonth_ <= now.getMonth())); 77 (expirationYear_ == now.getFullYear() &&
78 expirationMonth_ <= now.getMonth()));
67 }, 79 },
68 80
69 /** @override */ 81 /** @override */
70 attached: function() { 82 attached: function() {
71 this.title_ = this.i18n( 83 this.title_ = this.i18n(
72 this.creditCard.guid ? 'editCreditCardTitle' : 'addCreditCardTitle'); 84 this.creditCard.guid ? 'editCreditCardTitle' : 'addCreditCardTitle');
73 85
74 // Needed to initialize the disabled state of the Save button. 86 // Needed to initialize the disabled state of the Save button.
75 this.onCreditCardNameOrNumberChanged_(); 87 this.onCreditCardNameOrNumberChanged_();
76 88
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 /** 132 /**
121 * Handler for tapping the save button. 133 * Handler for tapping the save button.
122 * @private 134 * @private
123 */ 135 */
124 onSaveButtonTap_: function() { 136 onSaveButtonTap_: function() {
125 if (!this.saveEnabled_()) 137 if (!this.saveEnabled_())
126 return; 138 return;
127 139
128 // If the card is expired, reflect the error to the user. 140 // If the card is expired, reflect the error to the user.
129 // Otherwise, update the card, save and close the dialog. 141 // Otherwise, update the card, save and close the dialog.
130 if (!this.checkIfCardExpired_(this.expirationMonth_, 142 if (!this.checkIfCardExpired_(
131 this.expirationYear_)) { 143 this.expirationMonth_, this.expirationYear_)) {
132 this.creditCard.expirationYear = this.expirationYear_; 144 this.creditCard.expirationYear = this.expirationYear_;
133 this.creditCard.expirationMonth = this.expirationMonth_; 145 this.creditCard.expirationMonth = this.expirationMonth_;
134 this.fire('save-credit-card', this.creditCard); 146 this.fire('save-credit-card', this.creditCard);
135 this.close(); 147 this.close();
136 } 148 }
137 }, 149 },
138 150
139 /** @private */ 151 /** @private */
140 onMonthChange_: function() { 152 onMonthChange_: function() {
141 this.expirationMonth_ = this.monthList_[this.$.month.selectedIndex]; 153 this.expirationMonth_ = this.monthList_[this.$.month.selectedIndex];
142 }, 154 },
143 155
144 /** @private */ 156 /** @private */
145 onYearChange_: function() { 157 onYearChange_: function() {
146 this.expirationYear_ = this.yearList_[this.$.year.selectedIndex]; 158 this.expirationYear_ = this.yearList_[this.$.year.selectedIndex];
147 }, 159 },
148 160
149 /** @private */ 161 /** @private */
150 onCreditCardNameOrNumberChanged_: function() { 162 onCreditCardNameOrNumberChanged_: function() {
151 this.$.saveButton.disabled = !this.saveEnabled_(); 163 this.$.saveButton.disabled = !this.saveEnabled_();
152 }, 164 },
153 165
154 /** @private */ 166 /** @private */
155 saveEnabled_: function() { 167 saveEnabled_: function() {
156 return (this.creditCard.name && this.creditCard.name.trim()) || 168 return (this.creditCard.name && this.creditCard.name.trim()) ||
157 (this.creditCard.cardNumber && this.creditCard.cardNumber.trim()); 169 (this.creditCard.cardNumber && this.creditCard.cardNumber.trim());
158 }, 170 },
159 }); 171 });
160 })(); 172 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698