geico_design_kit 0.0.1-security.1 → 15.1.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of geico_design_kit might be problematic. Click here for more details.
- package/.babelrc +5 -0
- package/LICENSE +0 -0
- package/alt.json +33 -0
- package/dist/analytics.js +119 -0
- package/dist/appState.js +56 -0
- package/dist/baseComponent.js +110 -0
- package/dist/components/Accordion.js +312 -0
- package/dist/components/AddressAutoComplete.js +220 -0
- package/dist/components/Alert.js +145 -0
- package/dist/components/BackgroundPattern.js +99 -0
- package/dist/components/BackgroundPatternPortfolio.js +242 -0
- package/dist/components/ButtonSwitch.js +236 -0
- package/dist/components/CardSelections.js +230 -0
- package/dist/components/CommonQuestionsSquares.js +169 -0
- package/dist/components/Confirmation.js +156 -0
- package/dist/components/ConsolidatedSummary.js +489 -0
- package/dist/components/CoverageGraph.js +201 -0
- package/dist/components/CreditCard.js +591 -0
- package/dist/components/CurrencyInput.js +302 -0
- package/dist/components/DatePicker.js +468 -0
- package/dist/components/DockedMessage.js +146 -0
- package/dist/components/DotNavigation.js +200 -0
- package/dist/components/EditComponent.js +128 -0
- package/dist/components/EditableTable.js +113 -0
- package/dist/components/InPageNavigation.js +360 -0
- package/dist/components/Loader.js +232 -0
- package/dist/components/MakePayment.js +361 -0
- package/dist/components/Modal.js +254 -0
- package/dist/components/MoreInfoButton.js +227 -0
- package/dist/components/MultipleSelectBox.js +217 -0
- package/dist/components/NavigationalBox.js +161 -0
- package/dist/components/Navigator.js +294 -0
- package/dist/components/PasswordMeter.js +201 -0
- package/dist/components/PayPlans.js +534 -0
- package/dist/components/SegmentedControl.js +327 -0
- package/dist/components/SortableTable.js +166 -0
- package/dist/components/Tabs.js +1 -0
- package/dist/components/TextAreaCountdown.js +219 -0
- package/dist/components/Timeline.js +498 -0
- package/dist/components/TimelineFilter.js +492 -0
- package/dist/components/ToTopArrow.js +153 -0
- package/dist/components/Tooltip.js +329 -0
- package/dist/components/Upsell.js +168 -0
- package/dist/components/VIN.js +271 -0
- package/dist/components/ValidateForm.js +938 -0
- package/dist/components/ViewMoreLess.js +191 -0
- package/dist/components/ZipCode.js +191 -0
- package/dist/components/portfolio.js +99 -0
- package/dist/geico-design-kit.js +141 -0
- package/dist/global/components.js +98 -0
- package/dist/global/footer.js +26 -0
- package/dist/global/nav.js +1257 -0
- package/dist/services/CharacterTypeService.js +106 -0
- package/dist/services/UserAgentService.js +73 -0
- package/dist/utils.js +79 -0
- package/package.json +29 -3
- package/src/analytics.js +82 -0
- package/src/appState.js +56 -0
- package/src/baseComponent.js +156 -0
- package/src/components/Accordion.js +336 -0
- package/src/components/AddressAutoComplete.js +236 -0
- package/src/components/Alert.js +135 -0
- package/src/components/BackgroundPattern.js +96 -0
- package/src/components/BackgroundPatternPortfolio.js +284 -0
- package/src/components/ButtonSwitch.js +241 -0
- package/src/components/CardSelections.js +240 -0
- package/src/components/CommonQuestionsSquares.js +179 -0
- package/src/components/Confirmation.js +160 -0
- package/src/components/ConsolidatedSummary.js +505 -0
- package/src/components/CoverageGraph.js +203 -0
- package/src/components/CreditCard.js +595 -0
- package/src/components/CurrencyInput.js +321 -0
- package/src/components/DatePicker.js +487 -0
- package/src/components/DockedMessage.js +142 -0
- package/src/components/DotNavigation.js +206 -0
- package/src/components/EditComponent.js +130 -0
- package/src/components/EditableTable.js +106 -0
- package/src/components/InPageNavigation.js +391 -0
- package/src/components/Loader.js +272 -0
- package/src/components/MakePayment.js +397 -0
- package/src/components/Modal.js +279 -0
- package/src/components/MoreInfoButton.js +243 -0
- package/src/components/MultipleSelectBox.js +211 -0
- package/src/components/NavigationalBox.js +163 -0
- package/src/components/Navigator.js +338 -0
- package/src/components/PasswordMeter.js +209 -0
- package/src/components/PayPlans.js +604 -0
- package/src/components/SegmentedControl.js +365 -0
- package/src/components/SortableTable.js +176 -0
- package/src/components/Tabs.js +0 -0
- package/src/components/TextAreaCountdown.js +231 -0
- package/src/components/Timeline.js +532 -0
- package/src/components/TimelineFilter.js +533 -0
- package/src/components/ToTopArrow.js +153 -0
- package/src/components/Tooltip.js +344 -0
- package/src/components/Upsell.js +196 -0
- package/src/components/VIN.js +289 -0
- package/src/components/ValidateForm.js +1030 -0
- package/src/components/ViewMoreLess.js +193 -0
- package/src/components/ZipCode.js +193 -0
- package/src/components/portfolio.js +106 -0
- package/src/geico-design-kit.js +144 -0
- package/src/global/components.js +92 -0
- package/src/global/footer.js +25 -0
- package/src/global/nav.js +1457 -0
- package/src/services/CharacterTypeService.js +107 -0
- package/src/services/UserAgentService.js +59 -0
- package/src/utils.js +82 -0
- package/README.md +0 -5
@@ -0,0 +1,361 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports["default"] = void 0;
|
7
|
+
var _baseComponent = _interopRequireDefault(require("../../src/baseComponent"));
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
9
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
10
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
11
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
12
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
14
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
15
|
+
var validateSettings = [{
|
16
|
+
setting: "content",
|
17
|
+
isRequired: true,
|
18
|
+
validate: "type",
|
19
|
+
possibleValues: ["string", "object"],
|
20
|
+
errorMessage: ["GDK Make a Payment : Content must be defined and set to a DOM selector or Node"]
|
21
|
+
}];
|
22
|
+
|
23
|
+
/**
|
24
|
+
* MakePayment Class
|
25
|
+
*/
|
26
|
+
var MakePayment = /*#__PURE__*/function () {
|
27
|
+
/**
|
28
|
+
* These are settings for the instantiation. Refer to the design kit section of this component for JS setting examples.
|
29
|
+
* @param {string|Object} content
|
30
|
+
* A reference to the div form field containing the make payment input node
|
31
|
+
*
|
32
|
+
*/
|
33
|
+
|
34
|
+
function MakePayment(options) {
|
35
|
+
_classCallCheck(this, MakePayment);
|
36
|
+
this._internalVars = {};
|
37
|
+
|
38
|
+
//options with defaults set
|
39
|
+
this._defaults = {};
|
40
|
+
|
41
|
+
// Create options by extending defaults with the passed in arugments
|
42
|
+
if (options && _typeof(options) === "object") {
|
43
|
+
this._options = _baseComponent["default"].extendDefaults(this._defaults, options);
|
44
|
+
}
|
45
|
+
|
46
|
+
//if the required options are valid set up the environment
|
47
|
+
if (_baseComponent["default"].validateSettings(this._options, validateSettings)) {
|
48
|
+
this._internalVars.contentType = _baseComponent["default"].getContentType(this);
|
49
|
+
setLocalVars.call(this);
|
50
|
+
setEvents.call(this);
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
//Public Methods
|
55
|
+
|
56
|
+
/**
|
57
|
+
* destroy()
|
58
|
+
* removes the node from the dom and any events attached
|
59
|
+
*/
|
60
|
+
return _createClass(MakePayment, [{
|
61
|
+
key: "destroy",
|
62
|
+
value: function destroy() {
|
63
|
+
removeEvents.call(this);
|
64
|
+
this._internalVars.node.parentNode.removeChild(this._internalVars.node);
|
65
|
+
|
66
|
+
//a little garbage collection
|
67
|
+
for (var variableKey in this) {
|
68
|
+
if (this.hasOwnProperty(variableKey)) {
|
69
|
+
delete this[variableKey];
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|
73
|
+
}]);
|
74
|
+
}(); // Private Methods
|
75
|
+
/**
|
76
|
+
* setEvents()
|
77
|
+
* Sets all the events needed for the component
|
78
|
+
*/
|
79
|
+
function setEvents() {
|
80
|
+
var _this = this;
|
81
|
+
Array.prototype.forEach.call(this._internalVars.radios, function (radio) {
|
82
|
+
radio.addEventListener('change', paymentTypeFieldsDisplay.bind(_this));
|
83
|
+
});
|
84
|
+
Array.prototype.forEach.call(this._internalVars.paymentAmountRadios, function (radio) {
|
85
|
+
radio.addEventListener('change', enableDisableOtherAmount.bind(_this));
|
86
|
+
});
|
87
|
+
this._internalVars.creditCardcarddholderSelect.addEventListener('change', mailingAddressDisplay.bind(this));
|
88
|
+
this._internalVars.checkAccountholderSelect.addEventListener('change', mailingAddressDisplay.bind(this));
|
89
|
+
this._internalVars.creditCardcarddholderSelect.addEventListener('change', prefillName.bind(this));
|
90
|
+
this._internalVars.checkAccountholderSelect.addEventListener('change', prefillName.bind(this));
|
91
|
+
Array.prototype.forEach.call(this._internalVars.newAddressRadios, function (radio) {
|
92
|
+
radio.addEventListener('change', newAddressFieldsDisplay.bind(_this));
|
93
|
+
});
|
94
|
+
if (this._internalVars.nameOnCheckInput) {
|
95
|
+
this._internalVars.nameOnCheckInput.addEventListener('blur', parseFirstName.bind(this));
|
96
|
+
}
|
97
|
+
if (this._internalVars.nameOnCardInput) {
|
98
|
+
this._internalVars.nameOnCardInput.addEventListener('blur', parseFirstName.bind(this));
|
99
|
+
}
|
100
|
+
this._internalVars.saveMethodRadio.addEventListener('change', saveMethodFieldDisplay.bind(this));
|
101
|
+
}
|
102
|
+
|
103
|
+
/**
|
104
|
+
* removeEvents()
|
105
|
+
* removes all events from the component
|
106
|
+
*/
|
107
|
+
function removeEvents() {
|
108
|
+
var _this2 = this;
|
109
|
+
Array.prototype.forEach.call(this._internalVars.radios, function (radio) {
|
110
|
+
radio.removeEventListener('change', paymentTypeFieldsDisplay.bind(_this2));
|
111
|
+
});
|
112
|
+
Array.prototype.forEach.call(this._internalVars.paymentAmountRadios, function (radio) {
|
113
|
+
radio.removeEventListener('change', enableDisableOtherAmount.bind(_this2));
|
114
|
+
});
|
115
|
+
this._internalVars.creditCardcarddholderSelect.removeEventListener('change', mailingAddressDisplay.bind(this));
|
116
|
+
this._internalVars.checkAccountholderSelect.removeEventListener('change', mailingAddressDisplay.bind(this));
|
117
|
+
Array.prototype.forEach.call(this._internalVars.newAddressRadios, function (radio) {
|
118
|
+
radio.removeEventListener('change', newAddressFieldsDisplay.bind(_this2));
|
119
|
+
});
|
120
|
+
if (this._internalVars.nameOnCheckInput) {
|
121
|
+
this._internalVars.nameOnCheckInput.removeEventListener('blur', parseFirstName.bind(this));
|
122
|
+
}
|
123
|
+
if (this._internalVars.nameOnCardInput) {
|
124
|
+
this._internalVars.nameOnCardInput.removeEventListener('blur', parseFirstName.bind(this));
|
125
|
+
}
|
126
|
+
this._internalVars.saveMethodRadio.removeEventListener('change', saveMethodFieldDisplay.bind(this));
|
127
|
+
}
|
128
|
+
function enableDisableOtherAmount(event) {
|
129
|
+
if (event.target.value === 'other') {
|
130
|
+
this._internalVars.currencyInput.removeAttribute('disabled');
|
131
|
+
} else if (event.target.value !== 'other') {
|
132
|
+
this._internalVars.currencyInput.setAttribute('disabled', 'disabled');
|
133
|
+
}
|
134
|
+
}
|
135
|
+
function paymentTypeFieldsDisplay(event) {
|
136
|
+
//Set variable values for which fields should be displayed
|
137
|
+
var creditCardFieldsDisplay = false,
|
138
|
+
checkFieldsDisplay = false,
|
139
|
+
generalFieldsDisplay = false,
|
140
|
+
saveMethodFieldsDisplay = false;
|
141
|
+
this._internalVars.creditCardSelected = false;
|
142
|
+
this._internalVars.checkSelected = false;
|
143
|
+
if (event.target.value === 'card') {
|
144
|
+
generalFieldsDisplay = true;
|
145
|
+
creditCardFieldsDisplay = true;
|
146
|
+
checkFieldsDisplay = false;
|
147
|
+
this._internalVars.creditCardSelected = true;
|
148
|
+
this._internalVars.addressFieldLabel.innerHTML = "Cardholder's";
|
149
|
+
}
|
150
|
+
if (event.target.value === 'check') {
|
151
|
+
generalFieldsDisplay = true;
|
152
|
+
checkFieldsDisplay = true;
|
153
|
+
creditCardFieldsDisplay = false;
|
154
|
+
this._internalVars.checkSelected = true;
|
155
|
+
this._internalVars.addressFieldLabel.innerHTML = "Account holder's";
|
156
|
+
}
|
157
|
+
|
158
|
+
//Reset values if payment method is changed
|
159
|
+
this._internalVars.creditCardcarddholderSelect.options[0].selected = true;
|
160
|
+
this._internalVars.checkAccountholderSelect.options[0].selected = true;
|
161
|
+
Array.prototype.forEach.call(this._internalVars.newAddressRadios, function (radio) {
|
162
|
+
radio.checked = false;
|
163
|
+
});
|
164
|
+
this._internalVars.saveMethodRadio.checked = false;
|
165
|
+
toggleFieldDisplay.call(this, creditCardFieldsDisplay, checkFieldsDisplay, generalFieldsDisplay, saveMethodFieldsDisplay);
|
166
|
+
}
|
167
|
+
function toggleFieldDisplay(creditCardFieldsDisplay, checkFieldsDisplay, generalFieldsDisplay, saveMethodFieldsDisplay) {
|
168
|
+
if ($(this._internalVars.dynamicAddressField).is(':visible')) {
|
169
|
+
$(this._internalVars.dynamicAddressField).slideUp();
|
170
|
+
}
|
171
|
+
if ($(this._internalVars.dynamicNewAddressFields).is(':visible')) {
|
172
|
+
$(this._internalVars.dynamicNewAddressFields).slideUp();
|
173
|
+
}
|
174
|
+
if (generalFieldsDisplay === true) {
|
175
|
+
if ($(this._internalVars.dynamicFieldGeneral).is(':hidden')) {
|
176
|
+
$(this._internalVars.dynamicFieldGeneral).slideDown();
|
177
|
+
}
|
178
|
+
} else {
|
179
|
+
if ($(this._internalVars.dynamicFieldGeneral).is(':visible')) {
|
180
|
+
$(this._internalVars.dynamicFieldGeneral).slideUp();
|
181
|
+
}
|
182
|
+
}
|
183
|
+
if (creditCardFieldsDisplay === true) {
|
184
|
+
if ($(this._internalVars.dynamicCardFields).is(':hidden')) {
|
185
|
+
$(this._internalVars.dynamicCardFields).slideDown();
|
186
|
+
}
|
187
|
+
} else {
|
188
|
+
if ($(this._internalVars.dynamicCardFields).is(':visible')) {
|
189
|
+
$(this._internalVars.dynamicCardFields).slideUp();
|
190
|
+
}
|
191
|
+
}
|
192
|
+
if (checkFieldsDisplay === true) {
|
193
|
+
if ($(this._internalVars.dynamicCheckFields).is(':hidden')) {
|
194
|
+
$(this._internalVars.dynamicCheckFields).slideDown();
|
195
|
+
}
|
196
|
+
} else {
|
197
|
+
if ($(this._internalVars.dynamicCheckFields).is(':visible')) {
|
198
|
+
$(this._internalVars.dynamicCheckFields).slideUp();
|
199
|
+
}
|
200
|
+
}
|
201
|
+
if (saveMethodFieldsDisplay === true) {
|
202
|
+
if ($(this._internalVars.dynamicFieldSaveFields).is(':hidden')) {
|
203
|
+
$(this._internalVars.dynamicFieldSaveFields).slideDown();
|
204
|
+
}
|
205
|
+
} else {
|
206
|
+
if ($(this._internalVars.dynamicFieldSaveFields).is(':visible')) {
|
207
|
+
$(this._internalVars.dynamicFieldSaveFields).slideUp();
|
208
|
+
}
|
209
|
+
}
|
210
|
+
}
|
211
|
+
function mailingAddressDisplay(event) {
|
212
|
+
var mailingAddressFields = false;
|
213
|
+
if (event.target.value === 'Other Payee') {
|
214
|
+
mailingAddressFields = true;
|
215
|
+
}
|
216
|
+
toggleMailingAddressFieldDisplay.call(this, mailingAddressFields);
|
217
|
+
}
|
218
|
+
function prefillName(event) {
|
219
|
+
var addressLabel;
|
220
|
+
if (this._internalVars.checkSelected === true) {
|
221
|
+
addressLabel = "Account holder's";
|
222
|
+
} else if (this._internalVars.creditCardSelected === true) {
|
223
|
+
addressLabel = "Cardholder's";
|
224
|
+
}
|
225
|
+
if (event.target.value !== 'Other Payee' && event.target.value !== 'Please Select') {
|
226
|
+
var value;
|
227
|
+
for (var i = 0; i < event.target.length; i++) {
|
228
|
+
if (event.target.options[i].value === event.target.value) {
|
229
|
+
value = event.target.options[i].text;
|
230
|
+
}
|
231
|
+
}
|
232
|
+
if (this._internalVars.creditCardSelected === true) {
|
233
|
+
this._internalVars.nameOnCardInput.value = value;
|
234
|
+
} else if (this._internalVars.checkSelected === true) {
|
235
|
+
this._internalVars.nameOnCheckInput.value = value;
|
236
|
+
}
|
237
|
+
} else {
|
238
|
+
this._internalVars.nameOnCardInput.value = '';
|
239
|
+
this._internalVars.nameOnCheckInput.value = '';
|
240
|
+
this._internalVars.addressFieldLabel.innerHTML = addressLabel;
|
241
|
+
}
|
242
|
+
}
|
243
|
+
function toggleMailingAddressFieldDisplay(mailingAddressFields) {
|
244
|
+
if (mailingAddressFields === true) {
|
245
|
+
if ($(this._internalVars.dynamicAddressField).is(':hidden')) {
|
246
|
+
$(this._internalVars.dynamicAddressField).slideDown();
|
247
|
+
}
|
248
|
+
} else {
|
249
|
+
if ($(this._internalVars.dynamicAddressField).is(':visible')) {
|
250
|
+
$(this._internalVars.dynamicAddressField).slideUp();
|
251
|
+
}
|
252
|
+
}
|
253
|
+
}
|
254
|
+
function newAddressFieldsDisplay(event) {
|
255
|
+
var newAddressFields = false;
|
256
|
+
if (event.target.value === 'new') {
|
257
|
+
newAddressFields = true;
|
258
|
+
}
|
259
|
+
toggleNewAddressFieldsDisplay.call(this, newAddressFields);
|
260
|
+
}
|
261
|
+
function toggleNewAddressFieldsDisplay(newAddressFields) {
|
262
|
+
if (newAddressFields === true) {
|
263
|
+
if ($(this._internalVars.dynamicNewAddressFields).is(':hidden')) {
|
264
|
+
$(this._internalVars.dynamicNewAddressFields).slideDown();
|
265
|
+
}
|
266
|
+
} else {
|
267
|
+
if ($(this._internalVars.dynamicNewAddressFields).is(':visible')) {
|
268
|
+
$(this._internalVars.dynamicNewAddressFields).slideUp();
|
269
|
+
}
|
270
|
+
}
|
271
|
+
}
|
272
|
+
function parseFirstName(event) {
|
273
|
+
var nameField, addressLabel;
|
274
|
+
if (this._internalVars.checkSelected === true) {
|
275
|
+
nameField = this._internalVars.nameOnCheckInput;
|
276
|
+
addressLabel = "Account holder's";
|
277
|
+
} else if (this._internalVars.creditCardSelected === true) {
|
278
|
+
nameField = this._internalVars.nameOnCardInput;
|
279
|
+
addressLabel = "Cardholder's";
|
280
|
+
}
|
281
|
+
if (nameField.value.length > 0) {
|
282
|
+
var firstName = event.target.value.split(" ")[0];
|
283
|
+
if (firstName.slice(-1) === 's' || firstName.slice(-1) === 'S') {
|
284
|
+
this._internalVars.addressFieldLabel.innerHTML = firstName + "'";
|
285
|
+
} else {
|
286
|
+
this._internalVars.addressFieldLabel.innerHTML = firstName + "'s";
|
287
|
+
}
|
288
|
+
} else {
|
289
|
+
this._internalVars.addressFieldLabel.innerHTML = addressLabel;
|
290
|
+
}
|
291
|
+
}
|
292
|
+
function saveMethodFieldDisplay(event) {
|
293
|
+
if (event.target.checked === true) {
|
294
|
+
if ($(this._internalVars.dynamicFieldSaveFields).is(':hidden')) {
|
295
|
+
$(this._internalVars.dynamicFieldSaveFields).slideDown();
|
296
|
+
}
|
297
|
+
} else {
|
298
|
+
if ($(this._internalVars.dynamicFieldSaveFields).is(':visible')) {
|
299
|
+
$(this._internalVars.dynamicFieldSaveFields).slideUp();
|
300
|
+
}
|
301
|
+
}
|
302
|
+
}
|
303
|
+
|
304
|
+
/**
|
305
|
+
* setLocalVars()
|
306
|
+
* set all the local vars to passed in options
|
307
|
+
*/
|
308
|
+
function setLocalVars() {
|
309
|
+
//determine the type of content passed in
|
310
|
+
if (this._internalVars.contentType === 'string') {
|
311
|
+
this._internalVars.node = document.querySelector(this._options.content);
|
312
|
+
} else if (this._internalVars.contentType === 'domNode') {
|
313
|
+
this._internalVars.node = this._options.content;
|
314
|
+
}
|
315
|
+
this._internalVars.makePaymentFields = this._internalVars.node;
|
316
|
+
this._internalVars.paymentAmountID = 'payment-amount';
|
317
|
+
this._internalVars.paymentAmountFields = this._internalVars.makePaymentFields.querySelector('#' + this._internalVars.paymentAmountID);
|
318
|
+
this._internalVars.paymentAmountRadios = this._internalVars.paymentAmountFields.querySelectorAll("input[type='radio']");
|
319
|
+
this._internalVars.currencyInputClass = 'currency-input';
|
320
|
+
this._internalVars.currencyInput = this._internalVars.makePaymentFields.querySelector('.' + this._internalVars.currencyInputClass);
|
321
|
+
this._internalVars.paymentMethodID = 'payment-method-selection';
|
322
|
+
this._internalVars.paymentMethodFields = this._internalVars.makePaymentFields.querySelector('#' + this._internalVars.paymentMethodID);
|
323
|
+
this._internalVars.radios = this._internalVars.paymentMethodFields.querySelectorAll('input');
|
324
|
+
this._internalVars.dynamicFieldCheckClass = 'dynamic-fields-check';
|
325
|
+
this._internalVars.dynamicCheckFields = this._internalVars.makePaymentFields.querySelector('.' + this._internalVars.dynamicFieldCheckClass);
|
326
|
+
this._internalVars.dynamicFieldCardClass = 'dynamic-fields-card';
|
327
|
+
this._internalVars.dynamicCardFields = this._internalVars.makePaymentFields.querySelector('.' + this._internalVars.dynamicFieldCardClass);
|
328
|
+
this._internalVars.dynamicFieldGeneralClass = 'dynamic-fields-general';
|
329
|
+
this._internalVars.dynamicFieldGeneral = this._internalVars.makePaymentFields.querySelector('.' + this._internalVars.dynamicFieldGeneralClass);
|
330
|
+
this._internalVars.creditCardCardholderID = 'cardholder-credit-card';
|
331
|
+
this._internalVars.creditCardCardholderField = this._internalVars.makePaymentFields.querySelector('#' + this._internalVars.creditCardCardholderID);
|
332
|
+
this._internalVars.creditCardcarddholderSelect = this._internalVars.creditCardCardholderField.querySelector('select');
|
333
|
+
this._internalVars.checkAccountholderID = 'accountholder-check';
|
334
|
+
this._internalVars.checkAccountholderField = this._internalVars.makePaymentFields.querySelector('#' + this._internalVars.checkAccountholderID);
|
335
|
+
this._internalVars.checkAccountholderSelect = this._internalVars.checkAccountholderField.querySelector('select');
|
336
|
+
this._internalVars.nameOnCheckID = 'name-on-check';
|
337
|
+
if (this._internalVars.makePaymentFields.querySelector('#' + this._internalVars.nameOnCheckID)) {
|
338
|
+
this._internalVars.nameOnCheckFields = this._internalVars.makePaymentFields.querySelector('#' + this._internalVars.nameOnCheckID);
|
339
|
+
this._internalVars.nameOnCheckInput = this._internalVars.nameOnCheckFields.querySelector('input');
|
340
|
+
}
|
341
|
+
this._internalVars.nameOnCardID = 'name-credit-card';
|
342
|
+
if (this._internalVars.makePaymentFields.querySelector('#' + this._internalVars.nameOnCardID)) {
|
343
|
+
this._internalVars.nameOnCardFields = this._internalVars.makePaymentFields.querySelector('#' + this._internalVars.nameOnCardID);
|
344
|
+
this._internalVars.nameOnCardInput = this._internalVars.nameOnCardFields.querySelector('input');
|
345
|
+
}
|
346
|
+
this._internalVars.dynamicFieldAddressClass = 'dynamic-fields-address';
|
347
|
+
this._internalVars.dynamicAddressField = this._internalVars.makePaymentFields.querySelector('.' + this._internalVars.dynamicFieldAddressClass);
|
348
|
+
this._internalVars.addressFieldNameLabelID = 'address-name';
|
349
|
+
this._internalVars.addressFieldLabel = this._internalVars.makePaymentFields.querySelector('#' + this._internalVars.addressFieldNameLabelID);
|
350
|
+
this._internalVars.newAddressID = 'address';
|
351
|
+
this._internalVars.newAddressFields = this._internalVars.makePaymentFields.querySelector('#' + this._internalVars.newAddressID);
|
352
|
+
this._internalVars.newAddressRadios = this._internalVars.newAddressFields.querySelectorAll('input');
|
353
|
+
this._internalVars.dynamicFieldNewAddressClass = 'dynamic-fields-new-address';
|
354
|
+
this._internalVars.dynamicNewAddressFields = this._internalVars.makePaymentFields.querySelector('.' + this._internalVars.dynamicFieldNewAddressClass);
|
355
|
+
this._internalVars.saveMethodId = 'save-method';
|
356
|
+
this._internalVars.saveMethodField = this._internalVars.makePaymentFields.querySelector('#' + this._internalVars.saveMethodId);
|
357
|
+
this._internalVars.saveMethodRadio = this._internalVars.saveMethodField.querySelector('input');
|
358
|
+
this._internalVars.dynamicFieldSaveClass = 'dynamic-fields-save-method';
|
359
|
+
this._internalVars.dynamicFieldSaveFields = this._internalVars.makePaymentFields.querySelector('.' + this._internalVars.dynamicFieldSaveClass);
|
360
|
+
}
|
361
|
+
var _default = exports["default"] = MakePayment;
|
@@ -0,0 +1,254 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports["default"] = void 0;
|
7
|
+
var utils = _interopRequireWildcard(require("../../src/utils"));
|
8
|
+
var _baseComponent = _interopRequireDefault(require("../../src/baseComponent"));
|
9
|
+
var _UserAgentService = _interopRequireDefault(require("../../src/services/UserAgentService"));
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
11
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
12
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
13
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
14
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
15
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
16
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
17
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
18
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
19
|
+
var PromiseIE = require('es6-promise-polyfill').Promise;
|
20
|
+
var validateSettings = [{
|
21
|
+
setting: "content",
|
22
|
+
isRequired: true,
|
23
|
+
validate: "type",
|
24
|
+
possibleValues: ["string", "object"],
|
25
|
+
errorMessage: ["GDK Modal : Content must be defined and set to a DOM selector or Node"]
|
26
|
+
}, {
|
27
|
+
setting: "autoShow",
|
28
|
+
isRequired: false,
|
29
|
+
validate: "type",
|
30
|
+
possibleValues: ["boolean"],
|
31
|
+
errorMessage: ["GDK Modal : autoShow must be a boolean"]
|
32
|
+
}, {
|
33
|
+
setting: "overlayShouldCloseModal",
|
34
|
+
isRequired: false,
|
35
|
+
validate: "type",
|
36
|
+
possibleValues: ["boolean"],
|
37
|
+
errorMessage: ["GDK Modal : overlayShouldCloseModal must be a boolean"]
|
38
|
+
}, {
|
39
|
+
setting: "hideCloseButton",
|
40
|
+
isRequired: false,
|
41
|
+
validate: "type",
|
42
|
+
possibleValues: ["boolean"],
|
43
|
+
errorMessage: ["GDK Modal : hideCloseButton must be a boolean"]
|
44
|
+
}, {
|
45
|
+
setting: "onOpened",
|
46
|
+
isRequired: false,
|
47
|
+
validate: "type",
|
48
|
+
possibleValues: ["function"],
|
49
|
+
errorMessage: ["GDK Modal : onOpened must be a function"]
|
50
|
+
}, {
|
51
|
+
setting: "onClosed",
|
52
|
+
isRequired: false,
|
53
|
+
validate: "type",
|
54
|
+
possibleValues: ["function"],
|
55
|
+
errorMessage: ["GDK Modal : onClosed must be a function"]
|
56
|
+
}];
|
57
|
+
var modalCloseBtn = '<button class="btn-close icon-close" type="button" aria-label="Close modal"></button>';
|
58
|
+
var Modal = /*#__PURE__*/function () {
|
59
|
+
/**
|
60
|
+
* These are settings for the instantiation. Refer to the design kit section of this component for JS setting examples.
|
61
|
+
* @param {string|Object} content
|
62
|
+
* A reference to the modal node
|
63
|
+
*
|
64
|
+
* @param {boolean} [autoShow=false]
|
65
|
+
* Use if you want to model to auto show when instantiated
|
66
|
+
*
|
67
|
+
* @param {boolean} [overlayShouldCloseModal=true]
|
68
|
+
* Set to false if you do not want the overlay to have click to close functionality
|
69
|
+
*
|
70
|
+
* @param {boolean} [hideCloseButton=false]
|
71
|
+
* Set to true if you want to hide the close button in the upper right corner of the modal
|
72
|
+
*
|
73
|
+
* @param {function} [onOpened]
|
74
|
+
* A callback function that gets fired when the modal has been opened
|
75
|
+
*
|
76
|
+
* @param {function} [onClosed]
|
77
|
+
* A callback function that gets fired when the modal has been closed
|
78
|
+
*
|
79
|
+
*/
|
80
|
+
function Modal(options) {
|
81
|
+
_classCallCheck(this, Modal);
|
82
|
+
this._internalVars = {
|
83
|
+
node: null,
|
84
|
+
//used for current node
|
85
|
+
closeBtn: null
|
86
|
+
};
|
87
|
+
|
88
|
+
//options with defaults set
|
89
|
+
this._defaults = {
|
90
|
+
autoShow: false,
|
91
|
+
overlayShouldCloseModal: true,
|
92
|
+
hideCloseButton: false
|
93
|
+
};
|
94
|
+
|
95
|
+
// Create options by extending defaults with the passed in arugments
|
96
|
+
if (options && _typeof(options) === "object") {
|
97
|
+
this._options = _baseComponent["default"].extendDefaults(this._defaults, options);
|
98
|
+
}
|
99
|
+
|
100
|
+
//if the required options are valid set up the environment
|
101
|
+
if (_baseComponent["default"].validateSettings(this._options, validateSettings)) {
|
102
|
+
this._internalVars.contentType = _baseComponent["default"].getContentType(this);
|
103
|
+
setLocalVars.call(this);
|
104
|
+
buildModal.call(this);
|
105
|
+
setEvents.call(this);
|
106
|
+
if (this._options.autoShow) {
|
107
|
+
this.show();
|
108
|
+
}
|
109
|
+
}
|
110
|
+
}
|
111
|
+
|
112
|
+
//Public Methods
|
113
|
+
|
114
|
+
/**
|
115
|
+
* show()
|
116
|
+
* shows the modal
|
117
|
+
*/
|
118
|
+
return _createClass(Modal, [{
|
119
|
+
key: "show",
|
120
|
+
value: function show() {
|
121
|
+
var _this = this;
|
122
|
+
this._internalVars.node.style.display = "block";
|
123
|
+
setTimeout(function () {
|
124
|
+
_this._internalVars.node.classList.add("modal--show");
|
125
|
+
if (_this._options.onOpened) _this._options.onOpened();
|
126
|
+
}, 10);
|
127
|
+
this._internalVars.inModalArray = [];
|
128
|
+
document.addEventListener('keyup', this._internalVars.modalTabHandler);
|
129
|
+
}
|
130
|
+
|
131
|
+
/**
|
132
|
+
* hide()
|
133
|
+
* hides the modal
|
134
|
+
*/
|
135
|
+
}, {
|
136
|
+
key: "hide",
|
137
|
+
value: function hide() {
|
138
|
+
var _this2 = this;
|
139
|
+
var duration = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 500;
|
140
|
+
this._internalVars.inModalArray = [];
|
141
|
+
document.removeEventListener('keyup', this._internalVars.modalTabHandler);
|
142
|
+
return new PromiseIE(function (resolve, reject) {
|
143
|
+
setTimeout(function () {
|
144
|
+
_this2._internalVars.node.classList.remove("modal--show");
|
145
|
+
_this2._internalVars.node.style.display = "none";
|
146
|
+
if (_this2._options.onClosed) _this2._options.onClosed();
|
147
|
+
resolve();
|
148
|
+
}, duration);
|
149
|
+
});
|
150
|
+
}
|
151
|
+
|
152
|
+
/**
|
153
|
+
* destroy()
|
154
|
+
* removes the node from the dom and any events attached
|
155
|
+
*/
|
156
|
+
}, {
|
157
|
+
key: "destroy",
|
158
|
+
value: function destroy() {
|
159
|
+
removeEvents.call(this);
|
160
|
+
this._internalVars.node.parentNode.removeChild(this._internalVars.node);
|
161
|
+
|
162
|
+
//a little garbage collection
|
163
|
+
for (var variableKey in this) {
|
164
|
+
if (this.hasOwnProperty(variableKey)) {
|
165
|
+
delete this[variableKey];
|
166
|
+
}
|
167
|
+
}
|
168
|
+
}
|
169
|
+
}]);
|
170
|
+
}();
|
171
|
+
/**
|
172
|
+
* setLocalVars()
|
173
|
+
* set all the local vars to passed in options
|
174
|
+
*/
|
175
|
+
function setLocalVars() {
|
176
|
+
//determine the type of content passed in
|
177
|
+
if (this._internalVars.contentType === 'string') {
|
178
|
+
this._internalVars.node = document.querySelector(this._options.content);
|
179
|
+
} else if (this._internalVars.contentType === 'domNode') {
|
180
|
+
this._internalVars.node = this._options.content;
|
181
|
+
}
|
182
|
+
this._internalVars.modalTabHandler = isolateTab.bind(this);
|
183
|
+
}
|
184
|
+
|
185
|
+
/**
|
186
|
+
* modalClicked()
|
187
|
+
* Gets fired when you click anywhere on a model
|
188
|
+
*/
|
189
|
+
function modalClicked(e) {
|
190
|
+
//NodeList of items that the mouse is currently over in document order.
|
191
|
+
//The last element in the NodeList is the most specific, each preceding
|
192
|
+
//one should be a parent, grandparent, and so on.
|
193
|
+
var nodes = document.querySelectorAll(":hover");
|
194
|
+
if (this._internalVars.node == nodes[nodes.length - 1]) {
|
195
|
+
this.hide();
|
196
|
+
}
|
197
|
+
}
|
198
|
+
|
199
|
+
/**
|
200
|
+
* setEvents()
|
201
|
+
* Sets all the events needed for this component
|
202
|
+
*/
|
203
|
+
function setEvents() {
|
204
|
+
var eventName = _UserAgentService["default"]._clickEventName();
|
205
|
+
if (this._options.overlayShouldCloseModal) {
|
206
|
+
this._internalVars.node.addEventListener(eventName, modalClicked.bind(this));
|
207
|
+
}
|
208
|
+
if (this._options.hideCloseButton) {
|
209
|
+
this._internalVars.closeBtn.classList.add("hidden");
|
210
|
+
} else {
|
211
|
+
this._internalVars.closeBtn.addEventListener(eventName, this.hide.bind(this));
|
212
|
+
}
|
213
|
+
}
|
214
|
+
|
215
|
+
/**
|
216
|
+
* removeEvents()
|
217
|
+
* removes all events from this component
|
218
|
+
*/
|
219
|
+
function removeEvents() {
|
220
|
+
var eventName = _UserAgentService["default"]._clickEventName();
|
221
|
+
if (this._options.overlayShouldCloseModal) {
|
222
|
+
this._internalVars.node.removeEventListener(eventName, modalClicked.bind(this));
|
223
|
+
}
|
224
|
+
this._internalVars.closeBtn.removeEventListener(eventName, this.hide.bind(this));
|
225
|
+
}
|
226
|
+
|
227
|
+
/**
|
228
|
+
* buildModal()
|
229
|
+
* Adds needed markup this component
|
230
|
+
*/
|
231
|
+
function buildModal() {
|
232
|
+
var modalContentDom = this._internalVars.node.querySelector(".modal-container");
|
233
|
+
modalContentDom.insertAdjacentHTML('afterBegin', modalCloseBtn);
|
234
|
+
this._internalVars.closeBtn = this._internalVars.node.querySelector(".btn-close");
|
235
|
+
var spanTab = document.createElement('span');
|
236
|
+
spanTab.setAttribute('tabindex', '0');
|
237
|
+
spanTab.setAttribute('class', 'tab-filler');
|
238
|
+
var cloneSpanTab = spanTab.cloneNode(true);
|
239
|
+
modalContentDom.appendChild(spanTab);
|
240
|
+
modalContentDom.insertBefore(cloneSpanTab, modalContentDom.children[0]);
|
241
|
+
}
|
242
|
+
function isolateTab(e) {
|
243
|
+
if (e.keyCode == 9 || e.keyCode == 9 && e.shiftKey) {
|
244
|
+
if (utils.isChild("modal", document.activeElement) && !document.activeElement.classList.contains('tab-filler') && !this._internalVars.inModalArray.includes(document.activeElement)) {
|
245
|
+
this._internalVars.inModalArray.push(document.activeElement);
|
246
|
+
}
|
247
|
+
if (document.activeElement.classList.contains('tab-filler')) {
|
248
|
+
if (this._internalVars.inModalArray.length > 0) {
|
249
|
+
this._internalVars.inModalArray[0].focus();
|
250
|
+
}
|
251
|
+
}
|
252
|
+
}
|
253
|
+
}
|
254
|
+
var _default = exports["default"] = Modal;
|