wickes-css2 2.107.0-tech-debt-issues.1 → 2.107.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Readme.md +1 -2
- package/build/css/category-main.css +1 -1
- package/build/css/components/card-product-banner.css +1 -1
- package/build/css/components/checkout-chip.css +1 -1
- package/build/css/components/checkout-payment-details-v2.css +1 -1
- package/build/css/homepage-main.css +1 -1
- package/build/css/kitchen-plp-main.css +1 -1
- package/build/css/main.css +1 -1
- package/build/css/my-account-main-v2.css +1 -1
- package/build/css/my-account-main.css +1 -1
- package/build/css/pages/checkout-new.css +1 -1
- package/build/css/pages/checkout.css +1 -1
- package/build/css/pages/my-account-v2.css +1 -1
- package/build/css/pages/page_product_search.css +1 -1
- package/build/css/pages/page_products-list-combined.css +1 -1
- package/build/css/pages/page_products-list_v2.css +1 -1
- package/build/css/pdp-main-before-combine.css +1 -1
- package/build/css/pdp-main-critical.css +1 -1
- package/build/css/pdp-main-non-critical.css +1 -1
- package/build/css/pdp-main.css +1 -1
- package/build/css/plp-main.css +1 -1
- package/build/css/store-locator-main.css +1 -1
- package/build/js/emulation.min.js +1 -21
- package/build/js/gift-cards.min.js +1 -1
- package/build/js/page/checkout-payment-details.js +87 -248
- package/build/js/page/checkout.js +1 -1
- package/build/js/page/components/gift-cards.js +357 -701
- package/build/js/page/kitchen/card-carousel.js +22 -22
- package/package.json +1 -1
- package/src/components/cart-voucher.hbs +10 -1
- package/src/components/checkout-payment-details-v2.hbs +4 -4
- package/src/components/checkout-payment-info-block.hbs +1 -1
- package/src/components/checkout_order-summary-new.hbs +1 -1
- package/src/components/gift-cards.hbs +14 -7
- package/src/components/order-item.hbs +18 -5
- package/src/components/order-summary.hbs +1 -1
- package/src/components/payments.hbs +5 -6
- package/src/components/potential-promotion.hbs +12 -3
- package/src/components/price-block-v2.hbs +1 -0
- package/src/data/data_delivery-address-v2.json +0 -4
- package/src/data/data_payments-checkout.json +0 -4
- package/src/data/data_quick-filter.json +3 -3
- package/src/data/data_shopping-cart-v2.json +23 -5
- package/src/data/footer_menu.json +0 -4
- package/src/js/emulation/checkout-payment-details.js +1 -26
- package/src/js/page/checkout-payment-details.js +87 -248
- package/src/js/page/checkout.js +1 -1
- package/src/js/page/components/gift-cards.js +357 -701
- package/src/js/page/kitchen/card-carousel.js +22 -22
- package/src/page_my-account-installer-carousel.html +131 -0
- package/src/page_payment-details-with-gift-card.html +1 -1
- package/src/page_product-details-billie.html +0 -2
- package/src/page_product-details-clearpay.html +0 -1
- package/src/page_shopping-cart-v2-vat.html +2 -1
- package/src/scss/components/_gift-cards.scss +3 -32
- package/src/scss/components/_payments-checkout.scss +2 -2
- package/src/scss/components/_payments-v2.scss +1 -1
- package/src/scss/components/_plp-filters.scss +9 -0
- package/src/scss/components/_price-block-critical.scss +8 -1
- package/src/scss/components/_quick-filter.scss +43 -11
- package/src/scss/components/_search-filter.scss +6 -0
- package/src/scss/components/card-product-banner.scss +1 -10
- package/src/scss/components/checkout-chip.scss +1 -0
- package/src/scss/components/checkout-payment-details-v2.scss +12 -0
- package/src/scss/components/my-account/_clipboard-code.scss +4 -0
- package/src/scss/helpers/_variables.scss +0 -2
- package/src/scss/pages/page_product_search.scss +3 -13
- package/src/scss/pages/page_products-list-combined.scss +1 -28
- package/src/scss/pages/page_products-list_v2.scss +2 -19
- package/src/sitemap.html +1 -0
- package/build/img/payment/checkout/giftcard.svg +0 -28
- package/build/img/payment/footer/giftcard.svg +0 -28
- package/src/img/payment/checkout/giftcard.svg +0 -28
- package/src/img/payment/footer/giftcard.svg +0 -28
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {initializeInputToggle} from
|
|
2
|
-
import {updateOrderSummary} from './order-summary';
|
|
3
|
-
import {hideLoader, showLoader} from
|
|
1
|
+
import { initializeInputToggle } from '../utils/show-hide-input';
|
|
2
|
+
import { updateOrderSummary } from './order-summary';
|
|
3
|
+
import { hideLoader, showLoader, appendLoader } from '../utils/loader';
|
|
4
4
|
import {
|
|
5
5
|
ADD_GIFT_CARD,
|
|
6
6
|
buildHintContext,
|
|
@@ -43,101 +43,85 @@ const notificationTpl = require('../../../elements/notifications.hbs');
|
|
|
43
43
|
var Wick = window.Wick || {};
|
|
44
44
|
|
|
45
45
|
Wick.GiftCard = {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
paypageIframeSel: '#hopIframe',
|
|
126
|
-
paypageCardDetailsSel: '.checkout-payment-details__card-details',
|
|
127
|
-
wrapper: '.giftcard__wrapper',
|
|
128
|
-
},
|
|
129
|
-
|
|
130
|
-
messages: {
|
|
131
|
-
numberMessage: 'Gift Card should consist of 16 digits',
|
|
132
|
-
pinMessage: 'Gift Card PIN should consist of 8 digits',
|
|
133
|
-
ctaDefaultText: 'Enter card details',
|
|
134
|
-
ctaGiftcardText: 'Pay with Gift Card',
|
|
135
|
-
},
|
|
136
|
-
|
|
137
|
-
collapseTargets: [
|
|
138
|
-
'.billing-address input, .billing-address select, .billing-address textarea',
|
|
139
|
-
'.billing-address [data-finder], .billing-address [data-manually]',
|
|
140
|
-
].join(','),
|
|
46
|
+
ADD_GIFT_CARD,
|
|
47
|
+
REMOVE_GIFT_CARD,
|
|
48
|
+
PAY_WITH_GIFT_CARD,
|
|
49
|
+
el: {
|
|
50
|
+
$blocks: $('.giftcard'),
|
|
51
|
+
block: '.giftcard',
|
|
52
|
+
toggle: '#giftcard-toggle',
|
|
53
|
+
panel: '#giftcard-inline',
|
|
54
|
+
hint: '.giftcard-hint',
|
|
55
|
+
closeBtn: '.giftcard-inline__close',
|
|
56
|
+
form: '.giftcard-inline__form',
|
|
57
|
+
number: 'input[name="giftcard-number"]',
|
|
58
|
+
pin: 'input[name="giftcard-pin"]',
|
|
59
|
+
note: '.giftcard-note',
|
|
60
|
+
field: '.giftcard__field',
|
|
61
|
+
errorText: '.giftcard__error-text',
|
|
62
|
+
fieldError: 'giftcard-field--error',
|
|
63
|
+
showToggle: '.toggle-show',
|
|
64
|
+
loader: '.giftcard__container .loader-wrapper',
|
|
65
|
+
success: '#giftcard-applied',
|
|
66
|
+
container: '.giftcard__container',
|
|
67
|
+
paymentForm: '.checkout-payment-details__payment-method',
|
|
68
|
+
billieField: '.form-row__field.form-row__field-billie',
|
|
69
|
+
klarnaField: '.form-row__field.form-row__field-klarna',
|
|
70
|
+
clearpayField: '.form-row__field.form-row__field-clearpay',
|
|
71
|
+
appleField: '.form-row__field.form-row__field-apple',
|
|
72
|
+
googleField: '.form-row__field.form-row__field-google',
|
|
73
|
+
paypalField: '.form-row__field.form-row__field-paypal',
|
|
74
|
+
cardField: '.form-row__field.form-row__card-payment',
|
|
75
|
+
summaryHint: '.giftcard-summary__hint',
|
|
76
|
+
chipList: '.giftcard-chip-list',
|
|
77
|
+
summary: '.giftcard-summary',
|
|
78
|
+
chip: '.giftcard-chip',
|
|
79
|
+
giftcardRow: '.giftcard-row',
|
|
80
|
+
checkoutContainer: '.checkout-payment-details',
|
|
81
|
+
formRow: '.form-row',
|
|
82
|
+
iconInfo: '.icon-info-component',
|
|
83
|
+
toggleIcon: 'svg, i',
|
|
84
|
+
iconEye: 'fa-eye',
|
|
85
|
+
iconEyeSlash: 'fa-eye-slash',
|
|
86
|
+
iconSvgEyeSlash: 'eye-slash',
|
|
87
|
+
passwordToggleEvent: 'input.passwordToggle',
|
|
88
|
+
ariaInvalidAttr: 'aria-invalid',
|
|
89
|
+
typeAttr: 'type',
|
|
90
|
+
dataIconAttr: 'data-icon',
|
|
91
|
+
svg: 'svg',
|
|
92
|
+
expandedAttr: 'aria-expanded',
|
|
93
|
+
giftcardBtn: '.giftcard__btn',
|
|
94
|
+
jsGiftcardAdd: '.js-giftcard-add',
|
|
95
|
+
giftcardChipClose: '.giftcard-chip__close',
|
|
96
|
+
body: 'body',
|
|
97
|
+
loaderChip: '.loader-wrapper',
|
|
98
|
+
chipListLoader: '.giftcard-chip-list > .loader-wrapper',
|
|
99
|
+
notification: '.giftcard-inline .notification',
|
|
100
|
+
giftCardInline: '.giftcard-inline',
|
|
101
|
+
notificationRoot: '.notification',
|
|
102
|
+
inlineHeader: '.giftcard-inline__header',
|
|
103
|
+
ctaSelector: '.btn-enter-details',
|
|
104
|
+
btnDetails: 'button',
|
|
105
|
+
btnText: '.btn__text',
|
|
106
|
+
btnEnterDetails: '.btn-enter-details',
|
|
107
|
+
checkoutPaymentFields: '.billing-address .checkout-payment-details__descr',
|
|
108
|
+
pageLoader: '.loader-wrapper.page-loader',
|
|
109
|
+
cardRadio: '#checkout-payment-details-card, #_checkout-payment-details-card_card',
|
|
110
|
+
billieInfo: '.checkout-payment-details__billie',
|
|
111
|
+
klarnaInfo: '.checkout-payment-details__klarna',
|
|
112
|
+
billingAddress: '.billing-address',
|
|
113
|
+
altPaymentRowsAttr:
|
|
114
|
+
'[data-apple],[data-google],[data-paypal],[data-klarna],[data-billie],[data-clearpay],[data-existing-card]',
|
|
115
|
+
hiddenCard: 'checkout-payment-details__card-details_hidden',
|
|
116
|
+
cardDetails: '.checkout-payment-details__card-details',
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
messages: {
|
|
120
|
+
numberMessage: 'Gift Card should consist of 16 digits',
|
|
121
|
+
pinMessage: 'Gift Card PIN should consist of 8 digits',
|
|
122
|
+
ctaDefaultText: 'Enter card details',
|
|
123
|
+
ctaGiftcardText: 'Pay with Gift Card',
|
|
124
|
+
},
|
|
141
125
|
|
|
142
126
|
maxChips: 3,
|
|
143
127
|
successTimer: null,
|
|
@@ -179,93 +163,8 @@ Wick.GiftCard = {
|
|
|
179
163
|
const hasValue = ($pinInput.val() || '').length > 0;
|
|
180
164
|
$toggle.toggle(hasValue);
|
|
181
165
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
isPanelOpen($root) {
|
|
186
|
-
const $panel = $root.find(this.el.panel);
|
|
187
|
-
return $panel.length ? $panel.prop('hidden') === false : false;
|
|
188
|
-
},
|
|
189
|
-
|
|
190
|
-
openPaypage($container) {
|
|
191
|
-
const {
|
|
192
|
-
paypageFormSel,
|
|
193
|
-
paypageIframeSel,
|
|
194
|
-
paypageIframeWrapSel,
|
|
195
|
-
paypageCardDetailsSel,
|
|
196
|
-
hiddenCard,
|
|
197
|
-
} = this.el;
|
|
198
|
-
|
|
199
|
-
const $cardDetails = $container.find(paypageCardDetailsSel);
|
|
200
|
-
const $wrap = $container.find(paypageIframeWrapSel);
|
|
201
|
-
|
|
202
|
-
$cardDetails.removeClass(hiddenCard).show();
|
|
203
|
-
$wrap.show();
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
const $form = $container.find(paypageFormSel);
|
|
207
|
-
|
|
208
|
-
const form = $form.get(0);
|
|
209
|
-
if (!form) return;
|
|
210
|
-
|
|
211
|
-
const $oldIframe = $container.find(paypageIframeSel);
|
|
212
|
-
if ($oldIframe.length) {
|
|
213
|
-
const old = $oldIframe.get(0);
|
|
214
|
-
const newIframe = old.cloneNode(true);
|
|
215
|
-
|
|
216
|
-
newIframe.src = old.getAttribute('src') || newIframe.src || '';
|
|
217
|
-
old.parentNode.replaceChild(newIframe, old);
|
|
218
|
-
|
|
219
|
-
const iframeName = newIframe.getAttribute('name') || newIframe.name;
|
|
220
|
-
if (iframeName) form.setAttribute('target', iframeName);
|
|
221
|
-
}
|
|
222
|
-
},
|
|
223
|
-
|
|
224
|
-
getAppliedChipsCount($root) {
|
|
225
|
-
const { giftcardRow, chipList, chip } = this.el;
|
|
226
|
-
const $row = $root.closest(giftcardRow);
|
|
227
|
-
return $row.length ? $row.find(`${chipList} ${chip}`).length : 0;
|
|
228
|
-
},
|
|
229
|
-
|
|
230
|
-
collapseKeepValues($root) {
|
|
231
|
-
const { toggle, panel, hint, expandedAttr } = this.el;
|
|
232
|
-
|
|
233
|
-
$root.find(panel).prop('hidden', true);
|
|
234
|
-
$root.find(toggle).attr(expandedAttr, 'false').show();
|
|
235
|
-
|
|
236
|
-
const zeroTotal = this.summaryTotal != null ? isZeroAmount(this.summaryTotal) : false;
|
|
237
|
-
$root.find(hint)[zeroTotal ? 'hide' : 'show']();
|
|
238
|
-
},
|
|
239
|
-
|
|
240
|
-
handleCollapseTrigger(e) {
|
|
241
|
-
const $target = $(e.target);
|
|
242
|
-
|
|
243
|
-
const isCheckbox = $target.is('#chb-payment-details-card');
|
|
244
|
-
const isInBilling = $target.closest('.billing-address').length > 0;
|
|
245
|
-
|
|
246
|
-
if (!isCheckbox && !isInBilling) return;
|
|
247
|
-
|
|
248
|
-
const $container = $target.closest(this.el.checkoutContainer);
|
|
249
|
-
if (!$container.length) return;
|
|
250
|
-
|
|
251
|
-
const $giftcard = $container.find(this.el.block).first();
|
|
252
|
-
if (!$giftcard.length) return;
|
|
253
|
-
|
|
254
|
-
if (!this.isPanelOpen($giftcard)) return;
|
|
255
|
-
|
|
256
|
-
const chipsCount = this.getAppliedChipsCount($giftcard);
|
|
257
|
-
|
|
258
|
-
const { panel, toggle, expandedAttr } = this.el;
|
|
259
|
-
|
|
260
|
-
if (chipsCount > 0) {
|
|
261
|
-
this.updateHintVisibility($giftcard);
|
|
262
|
-
this.collapseGiftcardPanel($container, { hideIfHasChips: true });
|
|
263
|
-
$giftcard.find(panel).prop('hidden', true).hide();
|
|
264
|
-
$giftcard.find(toggle).attr(expandedAttr, 'false');
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
this.collapseKeepValues($giftcard);
|
|
268
|
-
},
|
|
166
|
+
$pinInput.trigger(passwordToggleEvent);
|
|
167
|
+
},
|
|
269
168
|
|
|
270
169
|
resetForm($root) {
|
|
271
170
|
const { number, pin, note } = this.el;
|
|
@@ -294,118 +193,77 @@ Wick.GiftCard = {
|
|
|
294
193
|
this.resetPinToggle($root);
|
|
295
194
|
},
|
|
296
195
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
$root.find(panel).prop('hidden', false).show();
|
|
302
|
-
$root.find(toggle).attr(expandedAttr, 'true').hide();
|
|
303
|
-
$root.find(hint).hide();
|
|
304
|
-
$root.find(pin).trigger(passwordToggleEvent);
|
|
305
|
-
},
|
|
306
|
-
|
|
307
|
-
close($root) {
|
|
308
|
-
const { toggle, panel, expandedAttr, giftcardRow, chipList, chip, hint } = this.el;
|
|
309
|
-
const $toggle = $root.find(toggle);
|
|
310
|
-
const $panel = $root.find(panel);
|
|
311
|
-
const $pageLoader = this.getPageLoader();
|
|
312
|
-
|
|
313
|
-
showLoader($pageLoader);
|
|
314
|
-
|
|
315
|
-
setTimeout(() => {
|
|
316
|
-
hideLoader($pageLoader);
|
|
317
|
-
|
|
318
|
-
$panel.prop('hidden', true);
|
|
319
|
-
$toggle.attr(expandedAttr, 'false').show().trigger('focus');
|
|
320
|
-
|
|
321
|
-
const $row = $root.closest(giftcardRow);
|
|
322
|
-
const count = $row.find(`${chipList} ${chip}`).length;
|
|
323
|
-
const zeroTotal = this.summaryTotal != null ? isZeroAmount(this.summaryTotal) : false;
|
|
324
|
-
|
|
325
|
-
if (count === 0) {
|
|
326
|
-
$root.find(hint)[zeroTotal ? 'hide' : 'show']();
|
|
327
|
-
return;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
this.updateHintVisibility($root);
|
|
331
|
-
}, 1000);
|
|
332
|
-
},
|
|
333
|
-
|
|
334
|
-
showSubmitSpinner($root) {
|
|
335
|
-
const { panel, toggle, hint, expandedAttr } = this.el;
|
|
336
|
-
|
|
337
|
-
$root.find(panel).prop('hidden', true);
|
|
338
|
-
$root.find(toggle).attr(expandedAttr, 'false').show().trigger('focus');
|
|
339
|
-
$root.find(hint).show();
|
|
340
|
-
|
|
341
|
-
this.lockPaymentsForSuccess($root);
|
|
342
|
-
|
|
343
|
-
this.showSuccess($root);
|
|
344
|
-
},
|
|
345
|
-
|
|
346
|
-
handleToggleClick(e) {
|
|
347
|
-
e.preventDefault();
|
|
348
|
-
|
|
349
|
-
const $root = $(e.currentTarget).closest(this.el.block);
|
|
350
|
-
const $container = $root.closest(this.el.checkoutContainer);
|
|
196
|
+
open($root) {
|
|
197
|
+
const { toggle, panel, hint, pin, expandedAttr, passwordToggleEvent } = this.el;
|
|
198
|
+
this.hideBanner($root);
|
|
199
|
+
$root.show();
|
|
351
200
|
|
|
352
|
-
|
|
353
|
-
$
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
this.clearPaypageAndCollapse($container);
|
|
358
|
-
}
|
|
201
|
+
$root.find(panel).prop('hidden', false);
|
|
202
|
+
$root.find(toggle).attr(expandedAttr, 'true').hide();
|
|
203
|
+
$root.find(hint).hide();
|
|
204
|
+
$root.find(pin).trigger(passwordToggleEvent);
|
|
205
|
+
},
|
|
359
206
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
207
|
+
close($root) {
|
|
208
|
+
const { toggle, panel, loader, expandedAttr } = this.el;
|
|
209
|
+
const $toggle = $root.find(toggle);
|
|
210
|
+
const $panel = $root.find(panel);
|
|
211
|
+
const $loader = $root.find(loader);
|
|
363
212
|
|
|
364
|
-
|
|
365
|
-
e.preventDefault();
|
|
366
|
-
const $root = $(e.currentTarget).closest(this.el.block);
|
|
367
|
-
this.resetForm($root);
|
|
368
|
-
this.close($root);
|
|
369
|
-
},
|
|
213
|
+
showLoader($loader);
|
|
370
214
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
$success.attr('hidden', 'hidden').removeClass('fade show').off('transitionend');
|
|
374
|
-
}
|
|
215
|
+
setTimeout(() => {
|
|
216
|
+
hideLoader($loader);
|
|
375
217
|
|
|
376
|
-
|
|
218
|
+
$panel.prop('hidden', true);
|
|
219
|
+
$toggle.attr(expandedAttr, 'false').show().trigger('focus');
|
|
220
|
+
this.updateHintVisibility($root);
|
|
221
|
+
}, 1000);
|
|
222
|
+
},
|
|
377
223
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
224
|
+
showSubmitSpinner($root) {
|
|
225
|
+
const { panel, toggle, hint, expandedAttr } = this.el;
|
|
226
|
+
$root.find(panel).prop('hidden', true);
|
|
227
|
+
$root.find(toggle).attr(expandedAttr, 'false').show().trigger('focus');
|
|
228
|
+
$root.find(hint).show();
|
|
229
|
+
this.showSuccess($root);
|
|
230
|
+
},
|
|
384
231
|
|
|
385
|
-
|
|
386
|
-
|
|
232
|
+
handleToggleClick(e) {
|
|
233
|
+
e.preventDefault();
|
|
234
|
+
this.open($(e.currentTarget).closest(this.el.$blocks));
|
|
235
|
+
},
|
|
387
236
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
237
|
+
handleCloseClick(e) {
|
|
238
|
+
e.preventDefault();
|
|
239
|
+
const $root = $(e.currentTarget).closest(this.el.$blocks);
|
|
240
|
+
this.resetForm($root);
|
|
241
|
+
this.close($root);
|
|
242
|
+
},
|
|
391
243
|
|
|
392
|
-
|
|
393
|
-
|
|
244
|
+
finalizeSuccess($root, $success) {
|
|
245
|
+
let { panel, toggle, hint, expandedAttr } = this.el;
|
|
394
246
|
|
|
395
|
-
|
|
247
|
+
if ($success && $success.length) {
|
|
248
|
+
$success.attr('hidden', 'hidden').removeClass('fade show').off('transitionend');
|
|
249
|
+
}
|
|
396
250
|
|
|
397
|
-
|
|
398
|
-
.find(
|
|
399
|
-
.
|
|
400
|
-
.
|
|
251
|
+
this.resetForm($root);
|
|
252
|
+
$root.find(panel).prop('hidden', true);
|
|
253
|
+
$root.find(toggle).attr(expandedAttr, 'false').show();
|
|
254
|
+
$root.find(hint).show();
|
|
401
255
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
256
|
+
if (this.pendingServerGiftCards) {
|
|
257
|
+
this.renderGiftCardsFromList($root, this.pendingServerGiftCards);
|
|
258
|
+
this.pendingServerGiftCards = null;
|
|
259
|
+
}
|
|
405
260
|
|
|
261
|
+
this.updateHintVisibility($root);
|
|
262
|
+
this.successTimer = null;
|
|
263
|
+
},
|
|
406
264
|
|
|
407
|
-
|
|
408
|
-
|
|
265
|
+
showSuccess($root) {
|
|
266
|
+
const { success } = this.el;
|
|
409
267
|
|
|
410
268
|
if (this.successTimer) {
|
|
411
269
|
clearTimeout(this.successTimer);
|
|
@@ -418,19 +276,18 @@ Wick.GiftCard = {
|
|
|
418
276
|
$success[0] && $success[0].offsetWidth;
|
|
419
277
|
$success.addClass('show');
|
|
420
278
|
|
|
421
|
-
|
|
422
|
-
|
|
279
|
+
this.successTimer = setTimeout(() => {
|
|
280
|
+
$success.removeClass('show');
|
|
281
|
+
const handler = () => this.finalizeSuccess($root, $success);
|
|
423
282
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
}, 3000);
|
|
429
|
-
},
|
|
283
|
+
$success.on('transitionend', handler);
|
|
284
|
+
setTimeout(handler, 200);
|
|
285
|
+
}, 3000);
|
|
286
|
+
},
|
|
430
287
|
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
288
|
+
handleFormSubmit(e) {
|
|
289
|
+
const { number, block, giftcardRow, loaderChip } = this.el;
|
|
290
|
+
e.preventDefault();
|
|
434
291
|
|
|
435
292
|
const $root = $(e.currentTarget).closest(block);
|
|
436
293
|
this.hideBanner($root);
|
|
@@ -441,46 +298,50 @@ Wick.GiftCard = {
|
|
|
441
298
|
const $numInput = $root.find(this.el.number);
|
|
442
299
|
const $pinInput = $root.find(this.el.pin);
|
|
443
300
|
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
.
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
301
|
+
const numberBlurOpts = {
|
|
302
|
+
fieldSelector: this.el.field,
|
|
303
|
+
errorTextSelector: this.el.errorText,
|
|
304
|
+
errorClass: this.el.fieldError,
|
|
305
|
+
ariaInvalidAttr: this.el.ariaInvalidAttr,
|
|
306
|
+
numberMessage: this.messages.numberMessage,
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
const pinBlurOpts = {
|
|
310
|
+
fieldSelector: this.el.field,
|
|
311
|
+
errorTextSelector: this.el.errorText,
|
|
312
|
+
errorClass: this.el.fieldError,
|
|
313
|
+
ariaInvalidAttr: this.el.ariaInvalidAttr,
|
|
314
|
+
pinMessage: this.messages.pinMessage,
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
const okNumber = validateExactDigits($numInput, 16, this.messages.numberMessage, this.el);
|
|
318
|
+
const okPin = validateExactDigits($pinInput, 8, this.messages.pinMessage, this.el);
|
|
319
|
+
|
|
320
|
+
if (!(okNumber && okPin)) {
|
|
321
|
+
handleGcNumberBlur({ currentTarget: $numInput[0] }, numberBlurOpts);
|
|
322
|
+
handleGcPinBlur({ currentTarget: $pinInput[0] }, pinBlurOpts);
|
|
323
|
+
(!okNumber ? $numInput : $pinInput).trigger('focus');
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
const giftCardNumber = this.getNumberValue($root);
|
|
328
|
+
const pin = this.getPinValue($root);
|
|
329
|
+
const $row = $root.closest(giftcardRow);
|
|
330
|
+
|
|
331
|
+
let $loader = $row.children(loaderChip);
|
|
332
|
+
|
|
333
|
+
if (!$loader.length) {
|
|
334
|
+
appendLoader({ wrapper: $row });
|
|
335
|
+
$loader = $row.children(loaderChip).last();
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
verifyGiftCard($loader, giftCardNumber, pin)
|
|
339
|
+
.then((res) => this.handleVerifyResponse($root, res))
|
|
340
|
+
.catch((err) => {
|
|
341
|
+
const msg = this.getErrorMessage(err);
|
|
342
|
+
this.showBannerError($root, msg);
|
|
343
|
+
});
|
|
344
|
+
},
|
|
484
345
|
|
|
485
346
|
handleVerifyResponse($root, res) {
|
|
486
347
|
if (res && res.code === OK_CODE) {
|
|
@@ -489,18 +350,15 @@ Wick.GiftCard = {
|
|
|
489
350
|
return;
|
|
490
351
|
}
|
|
491
352
|
|
|
492
|
-
|
|
493
|
-
if (res.orderTotal != null || res.giftCardTotal != null) {
|
|
494
|
-
summaryData = { total: res.orderTotal, giftCardApplied: res.giftCardTotal };
|
|
353
|
+
this.pendingServerGiftCards = res.giftCards.slice();
|
|
495
354
|
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
this.pendingServerGiftCards = res.giftCards.slice();
|
|
355
|
+
if (res.orderTotal != null || res.giftCardTotal != null) {
|
|
356
|
+
const data = { total: res.orderTotal, giftCardApplied: res.giftCardTotal };
|
|
357
|
+
updateOrderSummary(data, buildSummaryEqualMap(data), true);
|
|
358
|
+
this.summaryTotal = res.orderTotal;
|
|
359
|
+
this.toggleBillingDescrForZero($root);
|
|
360
|
+
this.updateCtaButton($root);
|
|
361
|
+
}
|
|
504
362
|
|
|
505
363
|
this.resetForm($root);
|
|
506
364
|
this.showSubmitSpinner($root);
|
|
@@ -511,70 +369,72 @@ Wick.GiftCard = {
|
|
|
511
369
|
this.showBannerError($root, msg);
|
|
512
370
|
},
|
|
513
371
|
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
} = this.el;
|
|
529
|
-
|
|
530
|
-
const { skipResetForm = false } = opts;
|
|
531
|
-
|
|
532
|
-
const $giftcard = $root.closest(block).length ? $root.closest(block) : $root;
|
|
533
|
-
const $summary = this.ensureSummaryContainer($giftcard);
|
|
534
|
-
const count = $summary.find(`${chipList} ${chip}`).length;
|
|
535
|
-
|
|
536
|
-
const limit = this.maxChips || 3;
|
|
537
|
-
const zeroTotal = this.summaryTotal != null ? isZeroAmount(this.summaryTotal) : false;
|
|
538
|
-
|
|
539
|
-
this.toggleAltPayments($giftcard, count === 0);
|
|
540
|
-
this.toggleAltPaymentInfos($giftcard, count === 0);
|
|
541
|
-
|
|
542
|
-
if (count === 0) {
|
|
543
|
-
$summary.hide();
|
|
544
|
-
|
|
545
|
-
$giftcard.show();
|
|
546
|
-
|
|
547
|
-
if (!skipResetForm) {
|
|
548
|
-
this.resetForm($giftcard);
|
|
549
|
-
}
|
|
372
|
+
updateHintVisibility($root) {
|
|
373
|
+
const {
|
|
374
|
+
chipList,
|
|
375
|
+
giftcardRow,
|
|
376
|
+
hint,
|
|
377
|
+
panel,
|
|
378
|
+
toggle,
|
|
379
|
+
iconInfo,
|
|
380
|
+
expandedAttr,
|
|
381
|
+
summaryHint,
|
|
382
|
+
chip,
|
|
383
|
+
block,
|
|
384
|
+
body,
|
|
385
|
+
} = this.el;
|
|
550
386
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
387
|
+
const $row = $root.closest(giftcardRow);
|
|
388
|
+
const $giftcard = $row.find(block).first();
|
|
389
|
+
const count = $row.find(`${chipList} ${chip}`).length;
|
|
390
|
+
const limit = this.maxChips || 3;
|
|
554
391
|
|
|
555
|
-
|
|
556
|
-
return;
|
|
557
|
-
}
|
|
392
|
+
const zeroTotal = this.summaryTotal != null ? isZeroAmount(this.summaryTotal) : false;
|
|
558
393
|
|
|
559
|
-
|
|
394
|
+
this.toggleAltPayments($giftcard, count === 0);
|
|
395
|
+
this.toggleAltPaymentInfos($giftcard, count === 0);
|
|
560
396
|
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
397
|
+
if (count > 0) {
|
|
398
|
+
if (!this.altPaymentPanelsLocked) {
|
|
399
|
+
this.showOnlyBillingAddress($giftcard);
|
|
400
|
+
this.altPaymentPanelsLocked = true;
|
|
401
|
+
} else {
|
|
402
|
+
this.showOnlyBillingAddress($giftcard);
|
|
403
|
+
}
|
|
404
|
+
} else {
|
|
405
|
+
if (!this.altPaymentPanelsLocked) {
|
|
406
|
+
this.toggleAltPayments($giftcard, true);
|
|
407
|
+
this.toggleAltPaymentInfos($giftcard, true);
|
|
408
|
+
} else {
|
|
409
|
+
this.showOnlyBillingAddress($giftcard);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
565
412
|
|
|
566
|
-
|
|
413
|
+
const $summary = this.ensureSummaryContainer($giftcard);
|
|
567
414
|
|
|
568
|
-
|
|
415
|
+
if (count === 0) {
|
|
416
|
+
$summary.hide();
|
|
417
|
+
$giftcard.show();
|
|
418
|
+
this.resetForm($giftcard);
|
|
419
|
+
$giftcard.find(panel).prop('hidden', true);
|
|
420
|
+
$giftcard.find(toggle).attr(expandedAttr, 'false').show();
|
|
421
|
+
$giftcard.find(hint)[zeroTotal ? 'hide' : 'show']();
|
|
422
|
+
this.updateCtaButton($giftcard);
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
569
425
|
|
|
570
|
-
|
|
571
|
-
|
|
426
|
+
this.setBillingLabelToCard($giftcard);
|
|
427
|
+
$summary.show();
|
|
428
|
+
$giftcard.hide();
|
|
429
|
+
$giftcard.find(hint).hide();
|
|
572
430
|
|
|
573
|
-
|
|
574
|
-
|
|
431
|
+
const ctx = buildHintContext(count, limit, zeroTotal);
|
|
432
|
+
const html = giftCardsHint(ctx);
|
|
433
|
+
const $old = $summary.find(summaryHint).first();
|
|
434
|
+
const $new = $(html);
|
|
575
435
|
|
|
576
|
-
|
|
577
|
-
|
|
436
|
+
if ($old.length) $old.replaceWith($new);
|
|
437
|
+
else $summary.append($new);
|
|
578
438
|
|
|
579
439
|
if (zeroTotal) {
|
|
580
440
|
$summary.find(summaryHint).hide();
|
|
@@ -591,27 +451,19 @@ Wick.GiftCard = {
|
|
|
591
451
|
return giftCardChip({ id, maskedNumber, currency, amount });
|
|
592
452
|
},
|
|
593
453
|
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
billieInfo,
|
|
598
|
-
klarnaInfo,
|
|
599
|
-
paymentMethodCheckedSel,
|
|
600
|
-
} = this.el;
|
|
601
|
-
|
|
602
|
-
const $container = $root.closest(checkoutContainer);
|
|
454
|
+
toggleAltPaymentInfos($root, show) {
|
|
455
|
+
const { checkoutContainer, billieInfo, klarnaInfo } = this.el;
|
|
456
|
+
const $container = $root.closest(checkoutContainer);
|
|
603
457
|
|
|
604
458
|
if (this.altPaymentInfosLocked) {
|
|
605
459
|
show = false;
|
|
606
460
|
}
|
|
607
461
|
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
$container.find(billieInfo)[showBillie ? 'show' : 'hide']();
|
|
614
|
-
$container.find(klarnaInfo)[showKlarna ? 'show' : 'hide']();
|
|
462
|
+
[$container.find(billieInfo), $container.find(klarnaInfo)].forEach(($panel) => {
|
|
463
|
+
if ($panel && $panel.length) {
|
|
464
|
+
$panel[show ? 'show' : 'hide']();
|
|
465
|
+
}
|
|
466
|
+
});
|
|
615
467
|
|
|
616
468
|
if (!show) this.altPaymentInfosLocked = true;
|
|
617
469
|
},
|
|
@@ -678,104 +530,24 @@ Wick.GiftCard = {
|
|
|
678
530
|
}
|
|
679
531
|
},
|
|
680
532
|
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
const $container = $row.closest(checkoutContainer);
|
|
700
|
-
if (
|
|
701
|
-
$container.length &&
|
|
702
|
-
this.isCardMethodSelected($container) &&
|
|
703
|
-
this.isPaypageOpen($container)
|
|
704
|
-
) {
|
|
705
|
-
this.clearPaypageAndCollapse($container);
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
const count = $row.find(`${chipList} ${chip}`).length;
|
|
709
|
-
if (count >= this.maxChips) return;
|
|
710
|
-
|
|
711
|
-
const $giftcard = $row.find(block).first();
|
|
712
|
-
|
|
713
|
-
const hasDraft =
|
|
714
|
-
String($giftcard.find(number).val() || '').trim().length > 0 ||
|
|
715
|
-
String($giftcard.find(pin).val() || '').trim().length > 0;
|
|
716
|
-
|
|
717
|
-
const hasFieldError = $giftcard.find(`.${fieldError}`).length > 0;
|
|
718
|
-
const hasBannerError = $giftcard.find(notificationRoot).length > 0;
|
|
719
|
-
|
|
720
|
-
if (!hasDraft && !hasFieldError && !hasBannerError) {
|
|
721
|
-
this.resetForm($giftcard);
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
this.open($giftcard);
|
|
725
|
-
$row.find(summaryHint).hide();
|
|
726
|
-
|
|
727
|
-
setTimeout(() => {
|
|
728
|
-
$giftcard.find(number).trigger('focus');
|
|
729
|
-
}, 0);
|
|
730
|
-
},
|
|
731
|
-
|
|
732
|
-
isCardMethodSelected($container) {
|
|
733
|
-
const { paymentMethodCheckedSel, paymentMethodCardValue } = this.el;
|
|
734
|
-
|
|
735
|
-
const $checked = $container.find(paymentMethodCheckedSel);
|
|
736
|
-
return $checked.length && $checked.val() === paymentMethodCardValue;
|
|
737
|
-
},
|
|
738
|
-
|
|
739
|
-
isPaypageOpen($container) {
|
|
740
|
-
const { paypageNewCardSel, paypageIframeWrapSel } = this.el;
|
|
741
|
-
|
|
742
|
-
const $newCard = $container.find(paypageNewCardSel);
|
|
743
|
-
if ($newCard.length) {
|
|
744
|
-
return $newCard.is(':visible');
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
const $wrap = $container.find(paypageIframeWrapSel);
|
|
748
|
-
return $wrap.length ? $wrap.is(':visible') : false;
|
|
749
|
-
},
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
clearPaypageAndCollapse($container) {
|
|
753
|
-
const {
|
|
754
|
-
cardDetails,
|
|
755
|
-
hiddenCard,
|
|
756
|
-
paypageNewCardSel,
|
|
757
|
-
paypageExistingCardSel,
|
|
758
|
-
paypageIframeWrapSel,
|
|
759
|
-
cardValidationErrorRowSel,
|
|
760
|
-
cardValidationErrorRowClass,
|
|
761
|
-
cardValidationErrorTextSel,
|
|
762
|
-
} = this.el;
|
|
763
|
-
|
|
764
|
-
const $cardDetails = $container.find(cardDetails);
|
|
765
|
-
if (!$cardDetails.length) return;
|
|
766
|
-
|
|
767
|
-
$container.find(paypageNewCardSel).hide();
|
|
768
|
-
$container.find(paypageExistingCardSel).show();
|
|
769
|
-
|
|
770
|
-
$cardDetails.addClass(hiddenCard).hide();
|
|
771
|
-
$cardDetails.find(paypageIframeWrapSel).hide();
|
|
772
|
-
|
|
773
|
-
$cardDetails
|
|
774
|
-
.find(cardValidationErrorRowSel)
|
|
775
|
-
.removeClass(cardValidationErrorRowClass)
|
|
776
|
-
.find(cardValidationErrorTextSel)
|
|
777
|
-
.remove();
|
|
778
|
-
},
|
|
533
|
+
handleAddAnotherClick(e) {
|
|
534
|
+
e.preventDefault();
|
|
535
|
+
const { giftcardRow, chipList, chip, block, number, summaryHint } = this.el;
|
|
536
|
+
|
|
537
|
+
const $row = $(e.currentTarget).closest(giftcardRow);
|
|
538
|
+
const count = $row.find(`${chipList} ${chip}`).length;
|
|
539
|
+
if (count >= this.maxChips) return;
|
|
540
|
+
|
|
541
|
+
const $giftcard = $row.find(block).first();
|
|
542
|
+
this.resetForm($giftcard);
|
|
543
|
+
this.open($giftcard);
|
|
544
|
+
|
|
545
|
+
$row.find(summaryHint).hide();
|
|
546
|
+
|
|
547
|
+
setTimeout(() => {
|
|
548
|
+
$giftcard.find(number).trigger('focus');
|
|
549
|
+
}, 0);
|
|
550
|
+
},
|
|
779
551
|
|
|
780
552
|
getErrorMessage(payload) {
|
|
781
553
|
const code =
|
|
@@ -786,42 +558,38 @@ Wick.GiftCard = {
|
|
|
786
558
|
return (code != null && MESSAGE_BY_CODE[code]) || DEFAULT_ERROR_MESSAGE;
|
|
787
559
|
},
|
|
788
560
|
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
const {
|
|
793
|
-
chip,
|
|
794
|
-
giftcardRow,
|
|
795
|
-
block,
|
|
796
|
-
giftcardChipClose,
|
|
797
|
-
chipList,
|
|
798
|
-
} = this.el;
|
|
561
|
+
handleChipCloseClick(e) {
|
|
562
|
+
e.preventDefault();
|
|
563
|
+
const { chip, giftcardRow, block, giftcardChipClose, chipList, loaderChip } = this.el;
|
|
799
564
|
|
|
800
565
|
const $clickedChip = $(e.currentTarget).closest(chip);
|
|
801
566
|
const $row = $clickedChip.closest(giftcardRow);
|
|
802
567
|
const $giftcard = $row.find(block).first();
|
|
803
568
|
const $summary = this.ensureSummaryContainer($giftcard);
|
|
804
569
|
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
570
|
+
const $chips = $summary.find(`${chipList} ${chip}`);
|
|
571
|
+
const index = $chips.index($clickedChip);
|
|
572
|
+
if (index < 0) return;
|
|
573
|
+
|
|
574
|
+
let $loader = $row.children(loaderChip);
|
|
575
|
+
if (!$loader.length) {
|
|
576
|
+
appendLoader({ wrapper: $row });
|
|
577
|
+
$loader = $row.children(loaderChip).last();
|
|
578
|
+
}
|
|
808
579
|
|
|
809
580
|
$row.find(giftcardChipClose).css('pointer-events', 'none').attr('aria-disabled', 'true');
|
|
810
581
|
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
$row.find(giftcardChipClose).css('pointer-events', '').removeAttr('aria-disabled');
|
|
823
|
-
});
|
|
824
|
-
},
|
|
582
|
+
removeGiftCard($loader, index)
|
|
583
|
+
.then((res) => this.handleRemoveResponse($giftcard, res))
|
|
584
|
+
.catch((err) => {
|
|
585
|
+
const msg = this.getErrorMessage(err);
|
|
586
|
+
this.showBannerError($giftcard, msg);
|
|
587
|
+
})
|
|
588
|
+
.finally(() => {
|
|
589
|
+
hideLoader($loader);
|
|
590
|
+
$row.find(giftcardChipClose).css('pointer-events', '').removeAttr('aria-disabled');
|
|
591
|
+
});
|
|
592
|
+
},
|
|
825
593
|
|
|
826
594
|
handleRemoveResponse($giftcard, res) {
|
|
827
595
|
if (res && res.code === OK_CODE) {
|
|
@@ -856,16 +624,16 @@ Wick.GiftCard = {
|
|
|
856
624
|
return $summary;
|
|
857
625
|
},
|
|
858
626
|
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
627
|
+
getPageLoader() {
|
|
628
|
+
const $pl = $(this.el.pageLoader);
|
|
629
|
+
if (!$pl.parent().is('body')) $pl.appendTo('body');
|
|
630
|
+
return $pl;
|
|
631
|
+
},
|
|
864
632
|
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
633
|
+
showPageLoader() {
|
|
634
|
+
const $pl = this.getPageLoader();
|
|
635
|
+
showLoader($pl);
|
|
636
|
+
},
|
|
869
637
|
|
|
870
638
|
updateCtaButton($scope) {
|
|
871
639
|
const { ctaSelector, btnDetails, btnText, checkoutContainer } = this.el;
|
|
@@ -942,20 +710,20 @@ Wick.GiftCard = {
|
|
|
942
710
|
(error.errorCode && PAY_MESSAGE_BY_CODE[error.errorCode]) ||
|
|
943
711
|
DEFAULT_PAY_ERROR_MESSAGE;
|
|
944
712
|
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
713
|
+
if (msg) {
|
|
714
|
+
Wick.Notification.show({
|
|
715
|
+
text: linkifyClickHere(msg),
|
|
716
|
+
container: '.globalMessages .container',
|
|
717
|
+
type: 'error',
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
})
|
|
721
|
+
.finally(() => {
|
|
722
|
+
const $pl = self.getPageLoader();
|
|
723
|
+
hideLoader($pl);
|
|
724
|
+
});
|
|
956
725
|
});
|
|
957
|
-
}
|
|
958
|
-
},
|
|
726
|
+
},
|
|
959
727
|
|
|
960
728
|
showBannerError($root, message, title = '') {
|
|
961
729
|
const { notificationRoot, giftCardInline, inlineHeader } = this.el;
|
|
@@ -971,34 +739,8 @@ Wick.GiftCard = {
|
|
|
971
739
|
text: linkifyClickHere(message),
|
|
972
740
|
});
|
|
973
741
|
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
clearErrorsOnly($root) {
|
|
978
|
-
const { number, pin, note, field, errorText, fieldError, ariaInvalidAttr } = this.el;
|
|
979
|
-
|
|
980
|
-
const $num = $root.find(number);
|
|
981
|
-
const $pin = $root.find(pin);
|
|
982
|
-
|
|
983
|
-
clearErrorText($num, field, errorText, fieldError, ariaInvalidAttr);
|
|
984
|
-
clearErrorText($pin, field, errorText, fieldError, ariaInvalidAttr);
|
|
985
|
-
|
|
986
|
-
$root.find(note).remove();
|
|
987
|
-
|
|
988
|
-
this.hideBanner($root);
|
|
989
|
-
},
|
|
990
|
-
|
|
991
|
-
clearErrorsIfEmptyOnInit($root) {
|
|
992
|
-
const rawNum = String($root.find(this.el.number).val() || '');
|
|
993
|
-
const rawPin = String($root.find(this.el.pin).val() || '');
|
|
994
|
-
|
|
995
|
-
const digitsNum = rawNum.replace(/\D/g, '');
|
|
996
|
-
const digitsPin = rawPin.replace(/\D/g, '');
|
|
997
|
-
|
|
998
|
-
if (digitsNum || digitsPin) return;
|
|
999
|
-
|
|
1000
|
-
this.clearErrorsOnly($root);
|
|
1001
|
-
},
|
|
742
|
+
$inline.find(inlineHeader).after(html);
|
|
743
|
+
},
|
|
1002
744
|
|
|
1003
745
|
hideBanner($root) {
|
|
1004
746
|
const { notification } = this.el;
|
|
@@ -1024,9 +766,9 @@ Wick.GiftCard = {
|
|
|
1024
766
|
const $list = $summary.find(chipList);
|
|
1025
767
|
$list.children(`${chip}:not(${loaderChip})`).remove();
|
|
1026
768
|
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
769
|
+
const html = (giftCards || [])
|
|
770
|
+
.map((g) => this.renderChipHTML(this.mapGiftToChipData($root, g)))
|
|
771
|
+
.join('');
|
|
1030
772
|
|
|
1031
773
|
if (html) {
|
|
1032
774
|
$list.append(html);
|
|
@@ -1061,31 +803,13 @@ Wick.GiftCard = {
|
|
|
1061
803
|
}
|
|
1062
804
|
},
|
|
1063
805
|
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
|
-
const $container = $root.closest(checkoutContainer);
|
|
1073
|
-
if (!$container.length) {
|
|
1074
|
-
return;
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1077
|
-
$container.find(billingAddress).removeClass(hiddenCard).show();
|
|
1078
|
-
|
|
1079
|
-
$container.find(altPaymentRowsAttr).addClass(hiddenCard);
|
|
1080
|
-
|
|
1081
|
-
if (this.isCardMethodSelected($container)) {
|
|
1082
|
-
this.clearPaypageAndCollapse($container);
|
|
1083
|
-
} else {
|
|
1084
|
-
$container.find(this.el.cardDetails).addClass(hiddenCard);
|
|
1085
|
-
}
|
|
1086
|
-
|
|
1087
|
-
this.toggleAltPaymentInfos($root, false);
|
|
1088
|
-
},
|
|
806
|
+
showOnlyBillingAddress($root) {
|
|
807
|
+
const { checkoutContainer, billingAddress, altPaymentRowsAttr, hiddenCard } = this.el;
|
|
808
|
+
const $container = $root.closest(checkoutContainer);
|
|
809
|
+
$container.find(billingAddress).removeClass(hiddenCard);
|
|
810
|
+
$container.find(altPaymentRowsAttr).addClass(hiddenCard);
|
|
811
|
+
this.toggleAltPaymentInfos($root, false);
|
|
812
|
+
},
|
|
1089
813
|
|
|
1090
814
|
useGlobalError($root, message) {
|
|
1091
815
|
if (window.Wick && Wick.Notification && typeof Wick.Notification.show === 'function') {
|
|
@@ -1112,80 +836,16 @@ Wick.GiftCard = {
|
|
|
1112
836
|
return;
|
|
1113
837
|
}
|
|
1114
838
|
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
collapseGiftcardPanel($container, opts = {}) {
|
|
1121
|
-
const { hideIfHasChips = false } = opts;
|
|
1122
|
-
const { panel, toggle, expandedAttr, checkoutContainer, block } = this.el;
|
|
1123
|
-
|
|
1124
|
-
const $ctx = $container && $container.length ? $container : $(checkoutContainer).first();
|
|
1125
|
-
const $giftcard = $ctx.find(block).first();
|
|
1126
|
-
if (!$giftcard.length) return;
|
|
1127
|
-
|
|
1128
|
-
$giftcard.find(panel).prop('hidden', true).hide();
|
|
1129
|
-
$giftcard.find(toggle).attr(expandedAttr, 'false');
|
|
1130
|
-
|
|
1131
|
-
this.updateHintVisibility($giftcard, { skipResetForm: true });
|
|
1132
|
-
|
|
1133
|
-
if (hideIfHasChips) {
|
|
1134
|
-
const hasChips = this.getAppliedChipsCount($giftcard) > 0;
|
|
1135
|
-
if (hasChips) {
|
|
1136
|
-
$giftcard.hide();
|
|
1137
|
-
$giftcard.find(toggle).hide();
|
|
1138
|
-
} else {
|
|
1139
|
-
$giftcard.show();
|
|
1140
|
-
$giftcard.find(toggle).show();
|
|
1141
|
-
}
|
|
1142
|
-
} else {
|
|
1143
|
-
$giftcard.find(toggle).show();
|
|
1144
|
-
}
|
|
1145
|
-
},
|
|
1146
|
-
|
|
1147
|
-
bindCtaCardCollapse() {
|
|
1148
|
-
const sel = this.el.btnEnterDetails;
|
|
1149
|
-
|
|
1150
|
-
$(document).off('click.giftcardCardCollapse', sel);
|
|
1151
|
-
|
|
1152
|
-
$(document).on('click.giftcardCardCollapse', sel, (e) => {
|
|
1153
|
-
const $btn = $(e.currentTarget);
|
|
1154
|
-
const mode = $btn.attr('data-mode');
|
|
1155
|
-
if (mode !== 'card') return;
|
|
1156
|
-
|
|
1157
|
-
const $container = $btn.closest(this.el.checkoutContainer);
|
|
1158
|
-
|
|
1159
|
-
console.log('[GC] CTA click', {
|
|
1160
|
-
mode,
|
|
1161
|
-
btnFound: $(e.currentTarget).length,
|
|
1162
|
-
container: $btn.closest(this.el.checkoutContainer).length,
|
|
1163
|
-
});
|
|
1164
|
-
|
|
1165
|
-
if (!$container.length) return;
|
|
1166
|
-
|
|
1167
|
-
e.preventDefault();
|
|
1168
|
-
|
|
1169
|
-
this.collapseGiftcardPanel($container, { hideIfHasChips: true });
|
|
1170
|
-
|
|
1171
|
-
this.openPaypage($container);
|
|
1172
|
-
});
|
|
1173
|
-
},
|
|
1174
|
-
|
|
839
|
+
const msg = PAY_MESSAGE_BY_CODE[code] || DEFAULT_PAY_ERROR_MESSAGE;
|
|
840
|
+
this.useGlobalError(this.el.$blocks.first(), msg);
|
|
841
|
+
});
|
|
842
|
+
},
|
|
1175
843
|
|
|
1176
844
|
bindEvents() {
|
|
1177
845
|
const { number, pin, toggle, closeBtn, giftcardBtn, jsGiftcardAdd, giftcardChipClose } =
|
|
1178
846
|
this.el;
|
|
1179
847
|
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
$(document).off('focusin.giftcard', this.collapseTargets);
|
|
1183
|
-
$(document).on('focusin.giftcard', this.collapseTargets, (e) => this.handleCollapseTrigger(e));
|
|
1184
|
-
|
|
1185
|
-
$(document).off('change.giftcard', '#chb-payment-details-card');
|
|
1186
|
-
$(document).on('change.giftcard', '#chb-payment-details-card', (e) => this.handleCollapseTrigger(e));
|
|
1187
|
-
|
|
1188
|
-
|
|
848
|
+
$(document).off('.giftcard');
|
|
1189
849
|
|
|
1190
850
|
const handleNumberInput = createGcNumberInputHandler({
|
|
1191
851
|
fieldSelector: this.el.field,
|
|
@@ -1237,9 +897,8 @@ Wick.GiftCard = {
|
|
|
1237
897
|
.on('click.giftcard', jsGiftcardAdd, this.handleAddAnotherClick.bind(this))
|
|
1238
898
|
.on('click.giftcard', giftcardChipClose, this.handleChipCloseClick.bind(this));
|
|
1239
899
|
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
},
|
|
900
|
+
this.bindGiftcardCtaHandler();
|
|
901
|
+
},
|
|
1243
902
|
|
|
1244
903
|
init(payload = {}) {
|
|
1245
904
|
const { field, pin, $blocks } = this.el;
|
|
@@ -1258,14 +917,11 @@ Wick.GiftCard = {
|
|
|
1258
917
|
}
|
|
1259
918
|
}
|
|
1260
919
|
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
}
|
|
1269
|
-
});
|
|
1270
|
-
}
|
|
920
|
+
$blocks.each((index, block) => {
|
|
921
|
+
const $pinField = $(block).find(pin).closest(field);
|
|
922
|
+
if ($pinField.length) {
|
|
923
|
+
initializeInputToggle($pinField);
|
|
924
|
+
}
|
|
925
|
+
});
|
|
926
|
+
},
|
|
1271
927
|
};
|