wickes-css2 2.106.0-develop.4 → 2.106.0-gift-cards.2
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 +2 -2
- package/build/css/category-main.css +1 -1
- package/build/css/components/checkout-payment-details-v2.css +1 -1
- package/build/css/components/global-search.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/page_checkout_delivery-new.css +1 -1
- package/build/css/pages/page_products-list-combined.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/img/billie-pay-later.svg +13 -0
- package/build/img/giftcard.svg +28 -0
- package/build/js/account-members.min.js +1 -1
- package/build/js/add-project-list-id.min.js +1 -1
- package/build/js/address-book.min.js +1 -1
- package/build/js/basket.min.js +2 -2
- package/build/js/bundle.min.js +1 -1
- package/build/js/change-password.min.js +1 -1
- package/build/js/checkout.min.js +2 -2
- package/build/js/emulation.min.js +2126 -1898
- package/build/js/general.bundle.min.js +1 -1
- package/build/js/gift-cards.min.js +1 -0
- package/build/js/merged-checkout.min.js +2 -2
- package/build/js/mini-basket-slider.min.js +1 -1
- package/build/js/page/basket/basket-update-cart-action.js +4 -1
- package/build/js/page/basket/klarna.js +13 -3
- package/build/js/page/basket-v2.js +6 -2
- package/build/js/page/components/billie-modal.js +20 -20
- package/build/js/page/components/gift-cards.js +915 -0
- package/build/js/page/components/order-summary.js +42 -25
- package/build/js/page/components/toggle-password-visibility.js +22 -0
- package/build/js/page/components/voucher.js +52 -47
- package/build/js/page/filters/plp-filters.js +2 -2
- package/build/js/page/kitchen/colour-swatches.js +152 -152
- package/build/js/page/plp-img-v2.js +25 -0
- package/build/js/page/quick-filter.js +103 -106
- package/build/js/page/utils/gift-cards-utils.js +188 -0
- package/build/js/page/utils/input-handling.js +92 -0
- package/build/js/page/utils/show-hide-input.js +28 -0
- package/build/js/page/utils/validation.js +46 -1
- package/build/js/pdp.bundle.min.js +1 -1
- package/build/js/personal-details.min.js +1 -1
- package/build/js/plp-filters.min.js +1 -1
- package/build/js/plp.bundle.min.js +1 -1
- package/build/js/project-list.min.js +44 -1
- package/build/js/quiz.min.js +1 -1
- package/build/js/track-my-order.min.js +1 -1
- package/package.json +2 -2
- package/src/components/checkout-payment-details-v2.hbs +4 -3
- package/src/components/gift-cards-hint.hbs +9 -0
- package/src/components/gift-cards.hbs +90 -0
- package/src/components/giftcard-chip.hbs +23 -0
- package/src/components/giftcard-summary.hbs +6 -0
- package/src/components/home-movers/form.hbs +1 -1
- package/src/components/price-block-v2.hbs +1 -1
- package/src/elements/form-row.hbs +1 -1
- package/src/elements/input.hbs +31 -2
- package/src/img/billie-pay-later.svg +13 -0
- package/src/img/giftcard.svg +28 -0
- package/src/js/components/general/notification.js +2 -1
- package/src/js/components/pdp-billie-modal-scroll-reset.js +42 -46
- package/src/js/emulation/basket-data.js +2126 -2038
- package/src/js/emulation/billie-modal.js +6 -6
- package/src/js/emulation/checkLocalEnv.js +6 -5
- package/src/js/emulation/checkout-data.js +35 -0
- package/src/js/emulation/checkout-payment-details.js +28 -26
- package/src/js/emulation/forms.js +16 -10
- package/src/js/emulation/gift-cards.js +205 -0
- package/src/js/emulation/mock.js +21 -88
- package/src/js/page/basket/basket-update-cart-action.js +4 -1
- package/src/js/page/basket/klarna.js +13 -3
- package/src/js/page/basket-v2.js +6 -2
- package/src/js/page/components/billie-modal.js +20 -20
- package/src/js/page/components/gift-cards.js +915 -0
- package/src/js/page/components/order-summary.js +42 -25
- package/src/js/page/components/toggle-password-visibility.js +22 -0
- package/src/js/page/components/voucher.js +52 -47
- package/src/js/page/filters/plp-filters.js +2 -2
- package/src/js/page/kitchen/colour-swatches.js +152 -152
- package/src/js/page/plp-img-v2.js +25 -0
- package/src/js/page/quick-filter.js +103 -106
- package/src/js/page/utils/gift-cards-utils.js +188 -0
- package/src/js/page/utils/input-handling.js +92 -0
- package/src/js/page/utils/show-hide-input.js +28 -0
- package/src/js/page/utils/validation.js +46 -1
- package/src/layouts/checkout.hbs +1 -5
- package/src/page_my-account_change-password.html +1 -0
- package/src/page_payment-details-with-gift-card.html +8 -5
- package/src/page_plp-with-paint.html +1 -1
- package/src/page_plp_v2-energy-efficiency.html +1 -1
- package/src/page_plp_v2-favourite-products.html +1 -1
- package/src/page_plp_v2-vat.html +1 -1
- package/src/page_plp_v2.html +1 -1
- package/src/page_product_search-vat.html +1 -1
- package/src/page_product_search.html +1 -1
- package/src/page_search-results.html +1 -1
- package/src/partials/scripts.hbs +0 -1
- package/src/scss/components/_custom-slider.scss +6 -7
- package/src/scss/components/_gift-cards.scss +360 -0
- package/src/scss/components/_quick-filter.scss +10 -32
- package/src/scss/components/checkout-payment-details-v2.scss +6 -2
- package/src/scss/components/kitchen/_price-tooltip.scss +2 -3
- package/src/scss/components/kitchen/_price.scss +2 -2
- package/src/scss/helpers/_variables.scss +16 -7
- package/src/scss/pages/page_checkout_delivery-new.scss +26 -0
- package/src/scss/pages/page_products-list-combined.scss +2 -34
- package/src/scss/pdp-main.scss +0 -1
- package/build/js/page/count-stepper/pdp-count-stepper.js +0 -29
- package/build/js/page/utils/create-count-stepper.js +0 -141
- package/build/js/pdp-count-stepper.min.js +0 -1
- package/src/elements/count-button.hbs +0 -10
- package/src/js/components/toggle-password-visibility.js +0 -58
- package/src/js/emulation/validity-emulation.js +0 -33
- package/src/js/page/count-stepper/pdp-count-stepper.js +0 -29
- package/src/js/page/utils/create-count-stepper.js +0 -141
- package/src/scss/components/_input-counter.scss +0 -65
|
@@ -13,31 +13,46 @@ const osEl = {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export function updateOrderSummary(data, equalMap, isVoucher) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
$(obj.item).show();
|
|
19
|
-
} else {
|
|
20
|
-
if ($(osEl.checkoutWidgetDetailsDiscount).length) {
|
|
21
|
-
$(osEl.checkoutWidgetDetailsDiscount).before(createCheckoutWidgetItem(obj))
|
|
22
|
-
} else {
|
|
23
|
-
$(osEl.checkoutWidgetDetails).append(createCheckoutWidgetItem(obj))
|
|
24
|
-
}
|
|
25
|
-
}
|
|
16
|
+
equalMap.forEach((obj) => {
|
|
17
|
+
if (typeof obj.dataValue === 'undefined') return;
|
|
26
18
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
19
|
+
if ($(obj.item).length) {
|
|
20
|
+
$(obj.item).show();
|
|
21
|
+
} else {
|
|
22
|
+
if ($(osEl.checkoutWidgetDetailsDiscount).length) {
|
|
23
|
+
$(osEl.checkoutWidgetDetailsDiscount).before(createCheckoutWidgetItem(obj));
|
|
24
|
+
} else {
|
|
25
|
+
$(osEl.checkoutWidgetDetails).append(createCheckoutWidgetItem(obj));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
34
28
|
|
|
35
|
-
|
|
29
|
+
$(obj.item).find(obj.itemValue).text(obj.dataValue);
|
|
30
|
+
if (isVoucher ? obj.dataValue : obj.value && obj.dataValue) {
|
|
31
|
+
$(obj.item).find(obj.itemValue).show();
|
|
32
|
+
} else {
|
|
33
|
+
$(obj.item).hide();
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
36
|
|
|
37
|
+
const keys = new Set(Object.keys(data || {}));
|
|
38
|
+
const hasAny = (...arr) => arr.some(k => keys.has(k));
|
|
39
|
+
|
|
40
|
+
const value = data.totalPrice?.formattedValue || data.total;
|
|
41
|
+
if (typeof value !== 'undefined' && hasAny('total', 'totalPrice')) {
|
|
42
|
+
updateSummaryMobileBarTotal(value);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (hasAny('promotionsInfo')) {
|
|
37
46
|
updateDiscount(data, isVoucher);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (hasAny('deliveryOrder', 'clickAndCollectOrder', 'clickAndCollectOnly', 'deliveryItemsQuantity', 'pickupItemsQuantity')) {
|
|
38
50
|
hideUnusedDeliveryTypeCost(data, isVoucher);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (hasAny('freeDelivery', 'messageForFreeDelivery', 'clickAndCollectOnly')) {
|
|
39
54
|
calculateFreeDelivery(data);
|
|
40
|
-
|
|
55
|
+
}
|
|
41
56
|
}
|
|
42
57
|
|
|
43
58
|
function createCheckoutWidgetItem(obj) {
|
|
@@ -53,12 +68,14 @@ function hideUnusedDeliveryTypeCost(data, isVoucher) {
|
|
|
53
68
|
$(osEl.delivery).show()
|
|
54
69
|
$(osEl.cc).show()
|
|
55
70
|
if (isVoucher) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
71
|
+
if ('deliveryOrder' in data && data.deliveryOrder === false) {
|
|
72
|
+
$(osEl.delivery).hide();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if ('clickAndCollectOrder' in data && data.clickAndCollectOrder === false) {
|
|
76
|
+
$(osEl.cc).hide();
|
|
77
|
+
}
|
|
78
|
+
} else {
|
|
62
79
|
if (data.clickAndCollectOnly) {
|
|
63
80
|
$(osEl.delivery).hide()
|
|
64
81
|
} else if (data.deliveryItemsQuantity > 0 && data.pickupItemsQuantity === 0) {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { initializeInputToggle } from "../utils/show-hide-input";
|
|
2
|
+
|
|
3
|
+
var Wick = window.Wick || {};
|
|
4
|
+
|
|
5
|
+
Wick.TogglePasswordVisibility = {
|
|
6
|
+
el: {
|
|
7
|
+
$containers: $('.form-row[data-show-content] .input-wrap'),
|
|
8
|
+
},
|
|
9
|
+
|
|
10
|
+
init() {
|
|
11
|
+
if (!this.el.$containers.length) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
this.el.$containers.each(function () {
|
|
15
|
+
initializeInputToggle($(this));
|
|
16
|
+
});
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
$(document).ready(function () {
|
|
21
|
+
Wick.TogglePasswordVisibility.init();
|
|
22
|
+
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {updateOrderSummary} from './order-summary';
|
|
2
|
-
import {callAction} from '../utils/http-action';
|
|
3
|
-
import {retryAction, retryHelpers} from
|
|
4
|
-
import {showValidationErrors} from '../utils/validation'
|
|
5
|
-
import {updateKlarnaPlacements} from '../basket/klarna';
|
|
6
|
-
import {getCSRFToken, CSRF} from
|
|
7
|
-
import {ROUTES} from '../utils/routes';
|
|
8
|
-
import {updateClearpayPlacements, updateClearpayVisibility} from '../basket/clearpay';
|
|
1
|
+
import { updateOrderSummary } from './order-summary';
|
|
2
|
+
import { callAction } from '../utils/http-action';
|
|
3
|
+
import { retryAction, retryHelpers } from './retry-action';
|
|
4
|
+
import { showValidationErrors } from '../utils/validation';
|
|
5
|
+
import { updateKlarnaPlacements } from '../basket/klarna';
|
|
6
|
+
import { getCSRFToken, CSRF } from './csrf';
|
|
7
|
+
import { ROUTES } from '../utils/routes';
|
|
8
|
+
import { updateClearpayPlacements, updateClearpayVisibility } from '../basket/clearpay';
|
|
9
9
|
|
|
10
10
|
const voucherEl = {
|
|
11
11
|
$basketVoucher: $('.checkout-voucher'),
|
|
@@ -30,8 +30,10 @@ const voucherEl = {
|
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
export function checkVoucherCode(e, current) {
|
|
33
|
-
e && e.preventDefault()
|
|
34
|
-
const context = current
|
|
33
|
+
e && e.preventDefault();
|
|
34
|
+
const context = current
|
|
35
|
+
? $(current).closest(voucherEl.voucher)
|
|
36
|
+
: $(this).closest(voucherEl.voucher),
|
|
35
37
|
value = context.find('input').val().trim(),
|
|
36
38
|
encodedValue = encodeURIComponent(value),
|
|
37
39
|
errorMsg = {
|
|
@@ -39,8 +41,8 @@ export function checkVoucherCode(e, current) {
|
|
|
39
41
|
responseJSON: {
|
|
40
42
|
globalMessage: {
|
|
41
43
|
message: 'Please enter a voucher code',
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
+
},
|
|
45
|
+
},
|
|
44
46
|
};
|
|
45
47
|
|
|
46
48
|
if (value && value.length) {
|
|
@@ -59,7 +61,7 @@ function executionVoucherApplying(value, context) {
|
|
|
59
61
|
url: `${ROUTES.VOUCHER_UPDATE}/${value}`,
|
|
60
62
|
type: 'POST',
|
|
61
63
|
headers: {
|
|
62
|
-
|
|
64
|
+
CSRFToken: CSRF.getToken(),
|
|
63
65
|
},
|
|
64
66
|
retryLimit: retryHelpers.retryLimit,
|
|
65
67
|
error: notApplyVoucher,
|
|
@@ -79,7 +81,7 @@ export function voucherRemove() {
|
|
|
79
81
|
let voucher = $(this).parent(),
|
|
80
82
|
voucherCode = voucher.attr('data-coupon-code');
|
|
81
83
|
voucher.addClass('checkout-widget__voucher-removed').text('Voucher removed');
|
|
82
|
-
voucherRemoveAction(voucherCode, voucher)
|
|
84
|
+
voucherRemoveAction(voucherCode, voucher);
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
function voucherRemoveAction(code) {
|
|
@@ -90,7 +92,7 @@ function voucherRemoveAction(code) {
|
|
|
90
92
|
type: 'DELETE',
|
|
91
93
|
headers: {
|
|
92
94
|
'Content-Type': 'application/json',
|
|
93
|
-
|
|
95
|
+
CSRFToken: CSRF.getToken(),
|
|
94
96
|
},
|
|
95
97
|
error: handleVoucherRemovingError,
|
|
96
98
|
};
|
|
@@ -106,12 +108,11 @@ function formattedTotalPriceWithoutSymbol(val) {
|
|
|
106
108
|
}
|
|
107
109
|
|
|
108
110
|
function executionVoucherRemoving(data) {
|
|
109
|
-
updateOrderSummary(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
updateOrderSummary(data, getEqualMapForVoucherUpdate(data), true);
|
|
112
|
+
updateKlarnaPlacements(
|
|
113
|
+
formattedTotalPriceWithoutSymbol(data.total),
|
|
114
|
+
data.paymentInfos.klarnaPaymentInfo.customPaymentMethodIds
|
|
113
115
|
);
|
|
114
|
-
updateKlarnaPlacements(formattedTotalPriceWithoutSymbol(data.total));
|
|
115
116
|
updateClearpayPlacements(data.total);
|
|
116
117
|
updateClearpayVisibility(data.total);
|
|
117
118
|
}
|
|
@@ -123,19 +124,18 @@ function applyVoucher(data, context) {
|
|
|
123
124
|
|
|
124
125
|
clearValidationErrors($voucherForm);
|
|
125
126
|
voucherEl.$basketVoucher.toggle(voucherEl.voucherHide);
|
|
126
|
-
updateOrderSummary(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
updateOrderSummary(data, getEqualMapForVoucherUpdate(data), true);
|
|
128
|
+
updateKlarnaPlacements(
|
|
129
|
+
formattedTotalPriceWithoutSymbol(data.total),
|
|
130
|
+
data.paymentInfos.klarnaPaymentInfo.customPaymentMethodIds
|
|
130
131
|
);
|
|
131
|
-
updateKlarnaPlacements(formattedTotalPriceWithoutSymbol(data.total));
|
|
132
132
|
updateClearpayPlacements(data.total);
|
|
133
133
|
updateClearpayVisibility(data.total);
|
|
134
134
|
setTimeout(function () {
|
|
135
135
|
voucherButton.attr('disabled', false);
|
|
136
136
|
$voucherFormInput.val('');
|
|
137
137
|
voucherEl.$basketVoucher.toggle(voucherEl.voucherHide);
|
|
138
|
-
}, 5000)
|
|
138
|
+
}, 5000);
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
function notApplyVoucher(xhr, context) {
|
|
@@ -158,21 +158,25 @@ function notApplyVoucher(xhr, context) {
|
|
|
158
158
|
function retryVoucherAction(voucherForm) {
|
|
159
159
|
return new Promise((resolve) => {
|
|
160
160
|
getCSRFToken(resolve);
|
|
161
|
-
}).then(() => {
|
|
162
|
-
retryAction(checkVoucherCode, retryHelpers.retryLimit, ...Array(1), voucherForm)
|
|
163
|
-
}).catch(() => {
|
|
164
|
-
showDefaultError();
|
|
165
161
|
})
|
|
162
|
+
.then(() => {
|
|
163
|
+
retryAction(checkVoucherCode, retryHelpers.retryLimit, ...Array(1), voucherForm);
|
|
164
|
+
})
|
|
165
|
+
.catch(() => {
|
|
166
|
+
showDefaultError();
|
|
167
|
+
});
|
|
166
168
|
}
|
|
167
169
|
|
|
168
170
|
function retryVoucherRemoving(code) {
|
|
169
171
|
return new Promise((resolve) => {
|
|
170
172
|
getCSRFToken(resolve);
|
|
171
|
-
}).then(() => {
|
|
172
|
-
retryAction(voucherRemoveAction, retryHelpers.retryLimit, code);
|
|
173
|
-
}).catch(() => {
|
|
174
|
-
console.log('remove failed');
|
|
175
173
|
})
|
|
174
|
+
.then(() => {
|
|
175
|
+
retryAction(voucherRemoveAction, retryHelpers.retryLimit, code);
|
|
176
|
+
})
|
|
177
|
+
.catch(() => {
|
|
178
|
+
console.log('remove failed');
|
|
179
|
+
});
|
|
176
180
|
}
|
|
177
181
|
|
|
178
182
|
function handleVoucherRemovingError(xhr, code) {
|
|
@@ -182,7 +186,7 @@ function handleVoucherRemovingError(xhr, code) {
|
|
|
182
186
|
}
|
|
183
187
|
|
|
184
188
|
function showDefaultError(error = retryHelpers.errorMsg) {
|
|
185
|
-
const voucher = getNotAppliedVoucher()
|
|
189
|
+
const voucher = getNotAppliedVoucher();
|
|
186
190
|
showValidationErrors(voucher.find('form'), error);
|
|
187
191
|
}
|
|
188
192
|
|
|
@@ -195,9 +199,12 @@ function getNotAppliedVoucher() {
|
|
|
195
199
|
function clearValidationErrors(form) {
|
|
196
200
|
var $form = $(form);
|
|
197
201
|
if ($form.hasClass(voucherEl.formInvalid)) {
|
|
198
|
-
$form
|
|
199
|
-
.
|
|
200
|
-
.find(voucherEl.
|
|
202
|
+
$form
|
|
203
|
+
.removeClass(voucherEl.formInvalid)
|
|
204
|
+
.find(voucherEl.fieldRow)
|
|
205
|
+
.removeClass(voucherEl.rowValidationError)
|
|
206
|
+
.find(voucherEl.fieldError)
|
|
207
|
+
.remove();
|
|
201
208
|
}
|
|
202
209
|
}
|
|
203
210
|
|
|
@@ -207,48 +214,46 @@ function getEqualMapForVoucherUpdate(data) {
|
|
|
207
214
|
item: voucherEl.subtotal,
|
|
208
215
|
itemValue: voucherEl.value,
|
|
209
216
|
dataValue: data.subTotal,
|
|
210
|
-
title: 'Items subtotal:'
|
|
211
|
-
|
|
217
|
+
title: 'Items subtotal:',
|
|
212
218
|
},
|
|
213
219
|
{
|
|
214
220
|
item: voucherEl.vat,
|
|
215
221
|
itemValue: voucherEl.value,
|
|
216
222
|
dataValue: data.vat,
|
|
217
|
-
title: 'VAT:'
|
|
223
|
+
title: 'VAT:',
|
|
218
224
|
},
|
|
219
225
|
{
|
|
220
226
|
item: voucherEl.cc,
|
|
221
227
|
itemValue: voucherEl.value,
|
|
222
228
|
dataValue: data.clickAndCollectCost,
|
|
223
|
-
title: 'Click & Collect:'
|
|
229
|
+
title: 'Click & Collect:',
|
|
224
230
|
},
|
|
225
231
|
{
|
|
226
232
|
item: voucherEl.delivery,
|
|
227
233
|
itemValue: voucherEl.value,
|
|
228
234
|
dataValue: data.deliveryCost,
|
|
229
|
-
title: 'Delivery:'
|
|
235
|
+
title: 'Delivery:',
|
|
230
236
|
},
|
|
231
237
|
{
|
|
232
238
|
item: voucherEl.charity,
|
|
233
239
|
itemValue: voucherEl.value,
|
|
234
240
|
dataValue: data.charityPrice,
|
|
235
|
-
title: 'Charity donation:'
|
|
241
|
+
title: 'Charity donation:',
|
|
236
242
|
},
|
|
237
243
|
{
|
|
238
244
|
item: voucherEl.discountItem,
|
|
239
245
|
itemValue: voucherEl.discountValue,
|
|
240
|
-
dataValue: data.discountTotal
|
|
246
|
+
dataValue: data.discountTotal,
|
|
241
247
|
},
|
|
242
248
|
{
|
|
243
249
|
item: voucherEl.orderTotal,
|
|
244
250
|
itemValue: voucherEl.orderTotalValue,
|
|
245
|
-
dataValue: data.total
|
|
251
|
+
dataValue: data.total,
|
|
246
252
|
},
|
|
247
253
|
];
|
|
248
254
|
}
|
|
249
255
|
|
|
250
256
|
$(document).ready(function () {
|
|
251
|
-
|
|
252
257
|
function init() {
|
|
253
258
|
if (!$('.checkout-voucher').length) {
|
|
254
259
|
return;
|
|
@@ -34,14 +34,14 @@ Wick.PLPFilters = {
|
|
|
34
34
|
|
|
35
35
|
// 5) primary render
|
|
36
36
|
Wick.PLPFilters.updateSelectedUI(rootWrapper);
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
// 6) handle browser back/forward navigation
|
|
39
39
|
Wick.PLPFilters.handlePageShow();
|
|
40
40
|
},
|
|
41
41
|
|
|
42
42
|
// Handle bfcache (back/forward cache)
|
|
43
43
|
handlePageShow() {
|
|
44
|
-
window.addEventListener('pageshow', function
|
|
44
|
+
window.addEventListener('pageshow', function(event) {
|
|
45
45
|
const rootWrapper = $(Wick.PLPFilters.ROOT_WRAPPER);
|
|
46
46
|
Wick.PLPFilters.appliedState = Wick.PLPFilters.readStateFromURL(rootWrapper);
|
|
47
47
|
Wick.PLPFilters.setDOMFromState(rootWrapper, Wick.PLPFilters.appliedState);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const Handlebars = require(
|
|
1
|
+
const Handlebars = require("hbsfy/runtime");
|
|
2
2
|
const markdown = require('helper-markdown');
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
import { arrayToObjectByIndex } from '../utils/array-utils';
|
|
5
5
|
|
|
6
6
|
import price from '../../../components/kitchen/price.hbs';
|
|
@@ -8,156 +8,156 @@ import stripStickers from '../../../components/kitchen/strip-stickers.hbs';
|
|
|
8
8
|
import slide from '../../../components/kitchen/slide.hbs';
|
|
9
9
|
import infoIcon from '../../../components/info-icon.hbs';
|
|
10
10
|
|
|
11
|
-
(function
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
Handlebars.registerHelper('optimizeImageUrl', function (url, width) {
|
|
44
|
-
const queryParameters = `format=pjpg&auto=webp&quality=90&width=${width}`;
|
|
45
|
-
const connectSymbol = url.includes('?') ? '&' : '?';
|
|
46
|
-
|
|
47
|
-
return `${url}${connectSymbol}${queryParameters}`;
|
|
48
|
-
});
|
|
49
|
-
Handlebars.registerHelper('formatPrice', function (value) {
|
|
50
|
-
if (typeof value === 'number') {
|
|
51
|
-
return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return value;
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
function normalizeKitchenData(kitchens) {
|
|
58
|
-
const transformedKitchens = kitchens.map((kitchen) => ({
|
|
59
|
-
...kitchen,
|
|
60
|
-
colourDatas: arrayToObjectByIndex(kitchen.colourDatas),
|
|
61
|
-
}));
|
|
62
|
-
|
|
63
|
-
return arrayToObjectByIndex(transformedKitchens);
|
|
11
|
+
(function() {
|
|
12
|
+
const CLASSES = {
|
|
13
|
+
activeSwatch: 'colour-swatch--active',
|
|
14
|
+
hiddenSwatch: 'colour-swatch--hidden',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const SELECTORS = {
|
|
18
|
+
kitchenCardsContainer: '.kitchen-cards',
|
|
19
|
+
cardContainer: '.kitchen-card',
|
|
20
|
+
colourSwatch: '.colour-swatch',
|
|
21
|
+
moreSwatchesButton: '.swatch-more',
|
|
22
|
+
hiddenSwatch: '.colour-swatch--hidden',
|
|
23
|
+
activeSwatch: '.colour-swatch--active',
|
|
24
|
+
swatchesText: '.colour-swatches__text',
|
|
25
|
+
designText: '.kitchen-card__design',
|
|
26
|
+
finishesText: '.kitchen-card__finishes',
|
|
27
|
+
ctaLink: '.kitchen-card__cta a',
|
|
28
|
+
stripsContainer: '.kitchen-card__strips',
|
|
29
|
+
priceContainer: '.kitchen-card__price',
|
|
30
|
+
tooltip: '[data-toggle="tooltip"]',
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
let kitchenData = [];
|
|
34
|
+
|
|
35
|
+
Handlebars.registerPartial('info-icon', infoIcon);
|
|
36
|
+
|
|
37
|
+
Handlebars.registerHelper('markdown', markdown());
|
|
38
|
+
Handlebars.registerHelper('ifCond', function (v1, operator, v2, options) {
|
|
39
|
+
if (operator === '||') {
|
|
40
|
+
return (v1 || v2) ? options.fn(this) : options.inverse(this);
|
|
64
41
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return {
|
|
76
|
-
price: priceData.price,
|
|
77
|
-
was_price: priceData.wasPrice,
|
|
78
|
-
finance_price: priceData.financePrice,
|
|
79
|
-
tooltip_text: priceData.tooltipText,
|
|
80
|
-
additional_text: priceData.additionalText,
|
|
81
|
-
price_offer: priceData.isPriceOffer,
|
|
82
|
-
};
|
|
42
|
+
});
|
|
43
|
+
Handlebars.registerHelper('optimizeImageUrl', function(url, width) {
|
|
44
|
+
const queryParameters = `format=pjpg&auto=webp&quality=90&width=${width}`
|
|
45
|
+
const connectSymbol = url.includes('?') ? '&' : '?'
|
|
46
|
+
|
|
47
|
+
return `${url}${connectSymbol}${queryParameters}`;
|
|
48
|
+
});
|
|
49
|
+
Handlebars.registerHelper('formatPrice', function (value) {
|
|
50
|
+
if (typeof value === 'number') {
|
|
51
|
+
return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
83
52
|
}
|
|
84
53
|
|
|
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
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
$(
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
54
|
+
return value;
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
function normalizeKitchenData(kitchens) {
|
|
58
|
+
const transformedKitchens = kitchens.map((kitchen) => ({
|
|
59
|
+
...kitchen,
|
|
60
|
+
colourDatas: arrayToObjectByIndex(kitchen.colourDatas),
|
|
61
|
+
}));
|
|
62
|
+
|
|
63
|
+
return arrayToObjectByIndex(transformedKitchens);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
function transformStripStickerDataForHbs(stickers) {
|
|
67
|
+
return stickers.map(sticker=> ({
|
|
68
|
+
text: sticker.text,
|
|
69
|
+
background: sticker.backgroundColour,
|
|
70
|
+
text_colour: sticker.textColour,
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function transformPriceDataForHbs(priceData) {
|
|
75
|
+
return {
|
|
76
|
+
price: priceData.price,
|
|
77
|
+
was_price: priceData.wasPrice,
|
|
78
|
+
finance_price: priceData.financePrice,
|
|
79
|
+
tooltip_text: priceData.tooltipText,
|
|
80
|
+
additional_text: priceData.additionalText,
|
|
81
|
+
price_offer: priceData.isPriceOffer
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function updateSwiperView($cardSwiper, images, sticker) {
|
|
86
|
+
$cardSwiper.removeAllSlides();
|
|
87
|
+
const newSlidesHtml = slide({images, sticker});
|
|
88
|
+
$cardSwiper.appendSlide(newSlidesHtml);
|
|
89
|
+
$cardSwiper.slideTo(0, 0);
|
|
90
|
+
}
|
|
91
|
+
function updateSwatchesTextView($cardContainer, colourName) {
|
|
92
|
+
$cardContainer.find(SELECTORS.swatchesText).text(`in ${colourName}`)
|
|
93
|
+
}
|
|
94
|
+
function updateParametersView($cardContainer, design, finishes) {
|
|
95
|
+
const finishesText = finishes.join(', ');
|
|
96
|
+
const finishesLabel = (finishes.length > 1) ? 'finishes' : 'finish';
|
|
97
|
+
|
|
98
|
+
$cardContainer.find(SELECTORS.designText).text(`${design} design`)
|
|
99
|
+
$cardContainer.find(SELECTORS.finishesText).text(`${finishesText} ${finishesLabel}`)
|
|
100
|
+
}
|
|
101
|
+
function updateCTALink($cardContainer, url) {
|
|
102
|
+
$cardContainer.find(SELECTORS.ctaLink).attr('href', url)
|
|
103
|
+
}
|
|
104
|
+
function updateStickersView($cardContainer, stickersData) {
|
|
105
|
+
const updatedStickersData = transformStripStickerDataForHbs(stickersData);
|
|
106
|
+
const newStripStickersHtml = stripStickers({strip_stickers: updatedStickersData});
|
|
107
|
+
|
|
108
|
+
$cardContainer.find(SELECTORS.stripsContainer).html(newStripStickersHtml);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function updatePriceView($cardContainer, priceData) {
|
|
112
|
+
const updatedPriceData = transformPriceDataForHbs(priceData);
|
|
113
|
+
const newPriceHtml = price({price: updatedPriceData, small: true});
|
|
114
|
+
|
|
115
|
+
$cardContainer.find(SELECTORS.priceContainer).html(newPriceHtml);
|
|
116
|
+
$cardContainer.find(SELECTORS.tooltip).tooltip();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function handleMoreSwatchesClick() {
|
|
120
|
+
const $button = $(this);
|
|
121
|
+
$button.siblings(SELECTORS.hiddenSwatch).removeClass(CLASSES.hiddenSwatch);
|
|
122
|
+
$button.hide();
|
|
123
|
+
$(window).trigger('kitchenCardChanged');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function handleColourSwatchClick() {
|
|
127
|
+
const $swatch = $(this);
|
|
128
|
+
const $cardContainer = $swatch.closest(SELECTORS.cardContainer);
|
|
129
|
+
const $currentSwatchActive = $swatch.siblings(SELECTORS.activeSwatch);
|
|
130
|
+
|
|
131
|
+
const colourId = $swatch.data('id');
|
|
132
|
+
const kitchenId = $cardContainer.data('id');
|
|
133
|
+
|
|
134
|
+
const currentKitchenData = kitchenData[kitchenId];
|
|
135
|
+
const colourData = currentKitchenData.colourDatas[colourId];
|
|
136
|
+
|
|
137
|
+
const $cardSwiper = Wick.PLPCardSwiper[kitchenId];
|
|
138
|
+
|
|
139
|
+
updatePriceView($cardContainer, colourData.priceData);
|
|
140
|
+
updateStickersView($cardContainer, colourData.stickers);
|
|
141
|
+
updateSwatchesTextView($cardContainer, colourData.colourSwatch.colourName);
|
|
142
|
+
updateSwiperView($cardSwiper, colourData.images, currentKitchenData.rangeStickers[0]);
|
|
143
|
+
updateParametersView($cardContainer, colourData.design, colourData.finishes);
|
|
144
|
+
updateCTALink($cardContainer, colourData.pdpUrl);
|
|
145
|
+
|
|
146
|
+
$currentSwatchActive.removeClass(CLASSES.activeSwatch);
|
|
147
|
+
$swatch.addClass(CLASSES.activeSwatch);
|
|
148
|
+
$(window).trigger('kitchenCardChanged');
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function initKitchenPLP(_, PLPKitchenData) {
|
|
152
|
+
const $kitchenCardsContainer = $(SELECTORS.kitchenCardsContainer);
|
|
153
|
+
|
|
154
|
+
kitchenData = normalizeKitchenData(PLPKitchenData);
|
|
155
|
+
|
|
156
|
+
$kitchenCardsContainer.on('click', SELECTORS.colourSwatch, handleColourSwatchClick);
|
|
157
|
+
$kitchenCardsContainer.on('click', SELECTORS.moreSwatchesButton, handleMoreSwatchesClick);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
$(document).ready(function() {
|
|
161
|
+
$(document).on('initKitchenPLP', initKitchenPLP);
|
|
162
|
+
});
|
|
163
|
+
})()
|