wickes-css2 2.106.0-develop.6 → 2.106.0-develop.8
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/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.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 +2119 -1842
- 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/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-mobile.js +7 -4
- package/build/js/page/filters/plp-filters-utils.js +0 -9
- package/build/js/page/filters/plp-filters.js +3 -11
- package/build/js/page/plp-img-v2.js +25 -0
- package/build/js/page/share-project-list.js +33 -151
- 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 +2 -2
- 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/share-project-list.min.js +1 -1
- package/build/js/track-my-order.min.js +1 -1
- package/package.json +2 -2
- package/src/components/card_product_v2.hbs +6 -1
- 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/price-block-v2.hbs +16 -15
- package/src/data/data_search-results_v2.json +2 -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/general/switchVat.js +1 -4
- package/src/js/components/share-project-list.js +56 -0
- package/src/js/emulation/basket-data.js +2126 -2038
- 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 +10 -0
- package/src/js/emulation/plp-load-more.js +4 -1
- 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/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-mobile.js +7 -4
- package/src/js/page/filters/plp-filters-utils.js +0 -9
- package/src/js/page/filters/plp-filters.js +3 -11
- package/src/js/page/plp-img-v2.js +25 -0
- package/src/js/page/share-project-list.js +33 -151
- 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 +32 -27
- package/src/page_plp_v2.html +1 -1
- package/src/page_product-details-cnc-success-notification-vat.html +3 -2
- 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 +3 -0
- package/src/scss/components/_custom-slider.scss +2 -2
- package/src/scss/components/_gift-cards.scss +360 -0
- package/src/scss/components/checkout-payment-details-v2.scss +6 -2
- package/src/scss/helpers/_variables.scss +15 -6
- package/src/scss/pages/page_checkout_delivery-new.scss +26 -0
- package/src/scss/pages/page_products-list-combined.scss +2 -34
- package/src/js/components/toggle-password-visibility.js +0 -58
|
@@ -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;
|
|
@@ -65,6 +65,11 @@ Wick.PLPFiltersMobile = {
|
|
|
65
65
|
$btn.text(total > 0 ? `View results (${total})` : 'View results');
|
|
66
66
|
},
|
|
67
67
|
|
|
68
|
+
hideAccordions() {
|
|
69
|
+
$(Wick.PLPFiltersMobile.$ACCORDION).addClass(Wick.PLPFiltersMobile.ACCORDION_COLLAPSED);
|
|
70
|
+
$(Wick.PLPFiltersMobile.$ACCORDION_CONTENT).hide();
|
|
71
|
+
},
|
|
72
|
+
|
|
68
73
|
init() {
|
|
69
74
|
// two-way binding for input between desktop and modal
|
|
70
75
|
$(document)
|
|
@@ -81,14 +86,13 @@ Wick.PLPFiltersMobile = {
|
|
|
81
86
|
$(document)
|
|
82
87
|
.off('shown.bs.modal.plpFiltersMobile', Wick.PLPFiltersMobile.MODAL_SEL)
|
|
83
88
|
.on('shown.bs.modal.plpFiltersMobile', Wick.PLPFiltersMobile.MODAL_SEL, function () {
|
|
84
|
-
Wick.PLPFilters.setDOMFromState($(this), Wick.PLPFilters.
|
|
89
|
+
Wick.PLPFilters.setDOMFromState($(this), Wick.PLPFilters.appliedState);
|
|
85
90
|
});
|
|
86
91
|
|
|
87
92
|
$(document)
|
|
88
93
|
.off('hide.bs.modal.plpFiltersMobile', Wick.PLPFiltersMobile.MODAL_SEL)
|
|
89
94
|
.on('hide.bs.modal.plpFiltersMobile', Wick.PLPFiltersMobile.MODAL_SEL, function () {
|
|
90
|
-
|
|
91
|
-
Wick.PLPFilters.draftState = Wick.PLPFilters.collectStateFromDOM(scope);
|
|
95
|
+
Wick.PLPFiltersMobile.hideAccordions();
|
|
92
96
|
});
|
|
93
97
|
|
|
94
98
|
// mobile "View results" button in modal
|
|
@@ -122,7 +126,6 @@ Wick.PLPFiltersMobile = {
|
|
|
122
126
|
|
|
123
127
|
e.preventDefault();
|
|
124
128
|
|
|
125
|
-
Wick.PLPFilters.draftState = {};
|
|
126
129
|
Wick.PLPFilters.appliedState = {};
|
|
127
130
|
Wick.PLPFilters.writeStateToURL(Wick.PLPFilters.appliedState, false);
|
|
128
131
|
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
var Wick = window.Wick || {};
|
|
2
2
|
|
|
3
3
|
Wick.PLPUtils = (function () {
|
|
4
|
-
function cloneState(state) {
|
|
5
|
-
const out = {};
|
|
6
|
-
Object.keys(state).forEach((k) => {
|
|
7
|
-
out[k] = new Set(state[k]);
|
|
8
|
-
});
|
|
9
|
-
return out;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
4
|
function syncTwinInputsByName(name, checked, source) {
|
|
13
5
|
const all = $('.filter-card__checkbox, .swatch__checkbox, .checkbox__input').filter(
|
|
14
6
|
function () {
|
|
@@ -65,7 +57,6 @@ Wick.PLPUtils = (function () {
|
|
|
65
57
|
}
|
|
66
58
|
|
|
67
59
|
return {
|
|
68
|
-
cloneState,
|
|
69
60
|
syncTwinInputsByName,
|
|
70
61
|
getPanelType,
|
|
71
62
|
countItems,
|
|
@@ -6,7 +6,6 @@ Wick.PLPFilters = {
|
|
|
6
6
|
ROOT: '.plp-filters',
|
|
7
7
|
GROUP: '.plp-filters__group',
|
|
8
8
|
APPLY_BTN: '.plp-filters__apply',
|
|
9
|
-
draftState: null,
|
|
10
9
|
|
|
11
10
|
INPUTS: '.filter-card__checkbox, .swatch__checkbox, .checkbox__input',
|
|
12
11
|
|
|
@@ -25,7 +24,6 @@ Wick.PLPFilters = {
|
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
Wick.PLPFilters.appliedState = Wick.PLPFilters.readStateFromURL(rootWrapper);
|
|
28
|
-
Wick.PLPFilters.draftState = Wick.PLPUtils.cloneState(Wick.PLPFilters.appliedState);
|
|
29
27
|
Wick.PLPFilters.setDOMFromState(rootWrapper, Wick.PLPFilters.appliedState);
|
|
30
28
|
|
|
31
29
|
// 3) chips
|
|
@@ -45,11 +43,8 @@ Wick.PLPFilters = {
|
|
|
45
43
|
handlePageShow() {
|
|
46
44
|
window.addEventListener('pageshow', function () {
|
|
47
45
|
const rootWrapper = $(Wick.PLPFilters.ROOT_WRAPPER);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
Wick.PLPFilters.appliedState = Wick.PLPFilters.readStateFromURL(stateScope);
|
|
51
|
-
Wick.PLPFilters.draftState = Wick.PLPFilters.appliedState;
|
|
52
|
-
Wick.PLPFilters.setDOMFromState(stateScope, Wick.PLPFilters.appliedState);
|
|
46
|
+
Wick.PLPFilters.appliedState = Wick.PLPFilters.readStateFromURL(rootWrapper);
|
|
47
|
+
Wick.PLPFilters.setDOMFromState(rootWrapper, Wick.PLPFilters.appliedState);
|
|
53
48
|
});
|
|
54
49
|
},
|
|
55
50
|
|
|
@@ -192,10 +187,7 @@ Wick.PLPFilters = {
|
|
|
192
187
|
|
|
193
188
|
// ===== APPLY
|
|
194
189
|
applyFromScopes(scopeForCollect, push) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
Wick.PLPFilters.draftState = nextState;
|
|
198
|
-
Wick.PLPFilters.appliedState = nextState;
|
|
190
|
+
Wick.PLPFilters.appliedState = Wick.PLPFilters.collectStateFromDOM(scopeForCollect);
|
|
199
191
|
Wick.PLPFilters.writeStateToURL(Wick.PLPFilters.appliedState, !!push);
|
|
200
192
|
},
|
|
201
193
|
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
$(document).ready(function () {
|
|
2
|
+
|
|
3
|
+
let imgWrap = $('.products-list-v2 .card__img-wrap');
|
|
4
|
+
let img = $('.products-list-v2 .card__img-v2');
|
|
5
|
+
|
|
6
|
+
square();
|
|
7
|
+
|
|
8
|
+
img.height(function () {
|
|
9
|
+
if (Math.round($(this).height()) > Math.round($(this).width())) {
|
|
10
|
+
$(this).height('99.9%'); //fix for ie
|
|
11
|
+
} else if ((Math.round($(this).height()) < Math.round($(this).width()))){
|
|
12
|
+
$(this).width('99.9%'); // fix for ie
|
|
13
|
+
} else {
|
|
14
|
+
$(this).width('99.9%'); // fix for ie
|
|
15
|
+
$(this).height('99.9%'); // fix for ie
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
function square() {
|
|
20
|
+
let width = imgWrap.width();
|
|
21
|
+
imgWrap.height(width);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
$(window).on('resize', square);
|
|
25
|
+
});
|
|
@@ -1,175 +1,57 @@
|
|
|
1
1
|
import { copyToClipboard } from './utils/copy-to-clipboard';
|
|
2
2
|
|
|
3
|
-
var Wick =
|
|
4
|
-
|
|
3
|
+
var Wick = Wick || {};
|
|
5
4
|
Wick.ShareProjectList = (function () {
|
|
6
|
-
|
|
7
|
-
input
|
|
8
|
-
linkContainer
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const CLASSES = {
|
|
13
|
-
copied: 'copy-link_hovered',
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
function logActiveElement() {
|
|
17
|
-
const active = document.activeElement;
|
|
18
|
-
|
|
19
|
-
if (!active) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function getElements() {
|
|
25
|
-
const $input = $(SELECTORS.input);
|
|
26
|
-
const $linkContainer = $(SELECTORS.linkContainer);
|
|
27
|
-
const $link = $linkContainer.find(SELECTORS.link);
|
|
28
|
-
|
|
29
|
-
return {
|
|
30
|
-
$input: $input,
|
|
31
|
-
$linkContainer: $linkContainer,
|
|
32
|
-
$link: $link,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function enableFocusAndSelect($input, source) {
|
|
37
|
-
if (!$input.length) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
5
|
+
function init() {
|
|
6
|
+
var $input = $('#share-list-modal #shopping-list-link');
|
|
7
|
+
var linkContainer = $('#copy-link');
|
|
8
|
+
var $actualLink = linkContainer.find('a');
|
|
9
|
+
var copyClass = 'copy-link_hovered';
|
|
40
10
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
11
|
+
$actualLink.on('click', function (e) {
|
|
12
|
+
e.preventDefault();
|
|
13
|
+
});
|
|
44
14
|
|
|
45
|
-
|
|
15
|
+
function focusAndSelectInput() {
|
|
16
|
+
if (!$input.length) return;
|
|
46
17
|
|
|
47
|
-
|
|
18
|
+
var el = $input.get(0);
|
|
48
19
|
|
|
49
|
-
|
|
50
|
-
input.focus();
|
|
51
|
-
} catch (error) {
|
|
52
|
-
console.error('[ShareProjectList] input.focus() failed', {
|
|
53
|
-
source: source,
|
|
54
|
-
error: error,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
20
|
+
$input.removeAttr('disabled');
|
|
57
21
|
|
|
58
|
-
|
|
22
|
+
el.focus();
|
|
59
23
|
|
|
60
|
-
|
|
61
|
-
if (typeof
|
|
62
|
-
|
|
63
|
-
} else if (typeof
|
|
64
|
-
|
|
24
|
+
var len = (el.value || '').length;
|
|
25
|
+
if (typeof el.setSelectionRange === 'function') {
|
|
26
|
+
el.setSelectionRange(0, len);
|
|
27
|
+
} else if (typeof el.select === 'function') {
|
|
28
|
+
el.select();
|
|
65
29
|
}
|
|
66
|
-
} catch (error) {
|
|
67
|
-
console.error('[ShareProjectList] selection failed', {
|
|
68
|
-
source: source,
|
|
69
|
-
error: error,
|
|
70
|
-
});
|
|
71
30
|
}
|
|
72
31
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
setTimeout(function () {
|
|
76
|
-
logActiveElement('[ShareProjectList] after 0ms timeout');
|
|
77
|
-
}, 0);
|
|
78
|
-
|
|
79
|
-
setTimeout(function () {
|
|
80
|
-
logActiveElement('[ShareProjectList] after 50ms timeout');
|
|
81
|
-
}, 50);
|
|
82
|
-
|
|
83
|
-
setTimeout(function () {
|
|
84
|
-
logActiveElement('[ShareProjectList] after 150ms timeout');
|
|
85
|
-
}, 150);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function getInputValue($input) {
|
|
89
|
-
const value = String($input.val() || '').trim();
|
|
90
|
-
|
|
91
|
-
return value;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function bindEvents(elements) {
|
|
95
|
-
const $input = elements.$input;
|
|
96
|
-
const $linkContainer = elements.$linkContainer;
|
|
97
|
-
const $link = elements.$link;
|
|
32
|
+
linkContainer.on('click', function (e) {
|
|
33
|
+
e.preventDefault();
|
|
98
34
|
|
|
99
|
-
|
|
100
|
-
logActiveElement('[ShareProjectList] on input focus');
|
|
101
|
-
});
|
|
35
|
+
focusAndSelectInput();
|
|
102
36
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
});
|
|
37
|
+
var value = ($input.val() || '').trim();
|
|
38
|
+
if (!value) return;
|
|
106
39
|
|
|
107
|
-
|
|
108
|
-
event.preventDefault();
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
$linkContainer.on('mousedown', function () {
|
|
112
|
-
logActiveElement('[ShareProjectList] on mousedown before focus');
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
$linkContainer.on('click', function (event) {
|
|
116
|
-
let value;
|
|
117
|
-
|
|
118
|
-
logActiveElement('[ShareProjectList] before click preventDefault');
|
|
119
|
-
|
|
120
|
-
event.preventDefault();
|
|
121
|
-
|
|
122
|
-
enableFocusAndSelect($input, 'linkContainer click');
|
|
123
|
-
|
|
124
|
-
value = getInputValue($input);
|
|
125
|
-
if (!value) {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
copyToClipboard(value, $linkContainer.get(0), { noUpperCase: true })
|
|
40
|
+
copyToClipboard(value, linkContainer[0], { noUpperCase: true })
|
|
130
41
|
.then(function () {
|
|
131
|
-
$
|
|
132
|
-
|
|
133
|
-
logActiveElement('[ShareProjectList] after copy success before refocus');
|
|
134
|
-
|
|
135
|
-
enableFocusAndSelect($input, 'copy success refocus');
|
|
136
|
-
|
|
137
|
-
setTimeout(function () {
|
|
138
|
-
enableFocusAndSelect($input, 'copy success refocus timeout 0');
|
|
139
|
-
}, 0);
|
|
140
|
-
|
|
141
|
-
setTimeout(function () {
|
|
142
|
-
enableFocusAndSelect($input, 'copy success refocus timeout 50');
|
|
143
|
-
}, 50);
|
|
42
|
+
$actualLink.addClass(copyClass);
|
|
144
43
|
})
|
|
145
|
-
.catch(function (
|
|
146
|
-
console.error(
|
|
147
|
-
|
|
148
|
-
logActiveElement('[ShareProjectList] after copy error before refocus');
|
|
149
|
-
|
|
150
|
-
enableFocusAndSelect($input, 'copy error refocus');
|
|
44
|
+
.catch(function (e) {
|
|
45
|
+
console.error(e);
|
|
151
46
|
});
|
|
152
47
|
});
|
|
153
48
|
|
|
154
|
-
$input.on('click', function () {
|
|
155
|
-
|
|
156
|
-
|
|
49
|
+
$input.on('click', function (e) {
|
|
50
|
+
e.preventDefault();
|
|
51
|
+
focusAndSelectInput();
|
|
52
|
+
$actualLink.removeClass(copyClass);
|
|
157
53
|
});
|
|
158
54
|
}
|
|
159
55
|
|
|
160
|
-
|
|
161
|
-
var elements = getElements();
|
|
162
|
-
|
|
163
|
-
if (!elements.$input.length || !elements.$linkContainer.length || !elements.$link.length) {
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
bindEvents(elements);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
return {
|
|
171
|
-
init: init,
|
|
172
|
-
};
|
|
56
|
+
init();
|
|
173
57
|
})();
|
|
174
|
-
|
|
175
|
-
Wick.ShareProjectList.init();
|