wickes-css2 2.111.0-develop.5 → 2.111.0-dont-forget-widget.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 +1 -1
- package/build/css/pdp-main-before-combine.css +1 -1
- package/build/css/pdp-main-non-critical.css +1 -1
- package/build/css/pdp-main.css +1 -1
- package/build/js/basket.min.js +1 -1
- package/build/js/bloomreach-widget.min.js +1 -1
- package/build/js/bundle.min.js +1 -1
- package/build/js/checkout.min.js +1 -1
- package/build/js/emulation.min.js +689 -54
- package/build/js/general.bundle.min.js +1 -1
- package/build/js/merged-checkout.min.js +1 -1
- package/build/js/page/bloomreach-widget/bloomreach-recommendation-carousel-widget.js +223 -0
- package/build/js/page/bloomreach-widget/bloomreach-widget.js +319 -0
- package/build/js/page/{bloomreach-widget.js → bloomreach-widget/complete-your-project-widget.js} +214 -387
- package/build/js/page/bloomreach-widget/dont-forget-widget.js +33 -0
- package/build/js/page/bloomreach-widget/why-not-add-widget.js +30 -0
- package/build/js/pdp.bundle.min.js +1 -1
- package/build/js/plp.bundle.min.js +1 -1
- package/build/js/project-list.min.js +1 -1
- package/package.json +1 -1
- package/src/components/bloomreach/complete-card.hbs +4 -32
- package/src/components/bloomreach/complete-your-project-skeleton.hbs +21 -0
- package/src/components/bloomreach/complete-your-project.hbs +4 -21
- package/src/components/bloomreach/why-not-add-card-skeleton.hbs +14 -0
- package/src/components/bloomreach/why-not-add-card.hbs +86 -0
- package/src/components/bloomreach/why-not-add-content.hbs +41 -0
- package/src/components/bloomreach/why-not-add-skeleton.hbs +9 -0
- package/src/components/bloomreach/why-not-add.hbs +4 -0
- package/src/components/pdp-price-actions.hbs +2 -2
- package/src/components/price-block-v2.hbs +2 -0
- package/src/components/reviews-rating.hbs +22 -0
- package/src/js/components/general/cart-slider.js +5 -0
- package/src/js/emulation/bloomreach-widget-loading.js +2 -2
- package/src/js/emulation/complete-your-project-loading.js +16 -0
- package/src/js/emulation/dont-forget-loading.js +18 -0
- package/src/js/emulation/mock.js +611 -3
- package/src/js/emulation/why-not-add-loading.js +16 -0
- package/src/js/emulation/why-not-add.js +28 -0
- package/src/js/page/bloomreach-widget/bloomreach-recommendation-carousel-widget.js +223 -0
- package/src/js/page/bloomreach-widget/bloomreach-widget.js +319 -0
- package/src/js/page/{bloomreach-widget.js → bloomreach-widget/complete-your-project-widget.js} +214 -387
- package/src/js/page/bloomreach-widget/dont-forget-widget.js +33 -0
- package/src/js/page/bloomreach-widget/why-not-add-widget.js +30 -0
- package/src/page_product-details-bloomreach.html +1 -1
- package/src/page_product-details-with-global-search-v2.html +2 -1
- package/src/page_product-details-with-why-not-add-single.html +131 -0
- package/src/scss/components/bloomreach/_bloomreach.scss +3 -0
- package/src/scss/components/bloomreach/_complete-card.scss +0 -38
- package/src/scss/components/bloomreach/_reviews.scss +60 -0
- package/src/scss/components/bloomreach/_why-not-add-card.scss +270 -0
- package/src/scss/components/bloomreach/_why-not-add.scss +172 -0
- package/src/sitemap.html +10 -4
- package/src/components/.DS_Store +0 -0
- package/src/js/page/.DS_Store +0 -0
package/build/js/page/{bloomreach-widget.js → bloomreach-widget/complete-your-project-widget.js}
RENAMED
|
@@ -1,29 +1,41 @@
|
|
|
1
1
|
var Wick = window.Wick || {};
|
|
2
2
|
|
|
3
|
-
import { createCountStepper } from '
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { createToast } from './utils/create-toast';
|
|
3
|
+
import { createCountStepper } from '../utils/create-count-stepper';
|
|
4
|
+
import { createDropdown } from '../utils/custom-dropdown';
|
|
5
|
+
import { createLoadingButton } from '../utils/create-loading-button';
|
|
6
|
+
import { createToast } from '../utils/create-toast';
|
|
8
7
|
|
|
9
8
|
const Handlebars = require('hbsfy/runtime');
|
|
10
9
|
|
|
11
|
-
Handlebars.registerPartial('checkbox', require('
|
|
12
|
-
Handlebars.registerPartial('loader', require('
|
|
13
|
-
Handlebars.registerPartial('button', require('
|
|
10
|
+
Handlebars.registerPartial('checkbox', require('../../../elements/checkbox.hbs'));
|
|
11
|
+
Handlebars.registerPartial('loader', require('../../../elements/loader.hbs'));
|
|
12
|
+
Handlebars.registerPartial('button', require('../../../components/base/button.hbs'));
|
|
14
13
|
Handlebars.registerPartial(
|
|
15
14
|
'bloomreach/complete-card-dropdown',
|
|
16
|
-
require('
|
|
15
|
+
require('../../../components/bloomreach/complete-card-dropdown.hbs')
|
|
16
|
+
);
|
|
17
|
+
Handlebars.registerPartial(
|
|
18
|
+
'bloomreach/complete-card-skeleton',
|
|
19
|
+
require('../../../components/bloomreach/complete-card-skeleton.hbs')
|
|
20
|
+
);
|
|
21
|
+
Handlebars.registerPartial(
|
|
22
|
+
'bloomreach/complete-summary-skeleton',
|
|
23
|
+
require('../../../components/bloomreach/complete-summary-skeleton.hbs')
|
|
24
|
+
);
|
|
25
|
+
Handlebars.registerPartial('notifications', require('../../../elements/notifications.hbs'));
|
|
26
|
+
Handlebars.registerPartial('reviews-rating', require('../../../components/reviews-rating.hbs'));
|
|
27
|
+
|
|
28
|
+
const notificationTemplate = require('../../../elements/notifications.hbs');
|
|
29
|
+
const completeWrapperTemplate = require('../../../components/bloomreach/complete-wrapper.hbs');
|
|
30
|
+
const completeDividerTemplate = require('../../../components/bloomreach/complete-divider.hbs');
|
|
31
|
+
const completeCardTemplate = require('../../../components/bloomreach/complete-card.hbs');
|
|
32
|
+
const completeSummaryTemplate = require('../../../components/bloomreach/complete-summary.hbs');
|
|
33
|
+
const completeYourProjectSkeletonTemplate = require(
|
|
34
|
+
'../../../components/bloomreach/complete-your-project-skeleton.hbs'
|
|
17
35
|
);
|
|
18
|
-
Handlebars.registerPartial('notifications', require('../../elements/notifications.hbs'));
|
|
19
|
-
|
|
20
|
-
const notificationTemplate = require('../../elements/notifications.hbs');
|
|
21
|
-
const completeWrapperTemplate = require('../../components/bloomreach/complete-wrapper.hbs');
|
|
22
|
-
const completeDividerTemplate = require('../../components/bloomreach/complete-divider.hbs');
|
|
23
|
-
const completeCardTemplate = require('../../components/bloomreach/complete-card.hbs');
|
|
24
|
-
const completeSummaryTemplate = require('../../components/bloomreach/complete-summary.hbs');
|
|
25
36
|
|
|
26
|
-
|
|
37
|
+
const CompleteYourProjectWidget = {
|
|
38
|
+
skeletonTemplate: completeYourProjectSkeletonTemplate,
|
|
27
39
|
CALCULATE_PRODUCT_BUNDLE_TOTAL_EVENT: 'calculateProductBundleTotal',
|
|
28
40
|
ADD_PRODUCT_BUNDLE_TO_CART_EVENT: 'bulkAddToCart',
|
|
29
41
|
|
|
@@ -43,14 +55,8 @@ Wick.BloomreachWidget = {
|
|
|
43
55
|
countStepperInitializedData: 'count-stepper-initialized',
|
|
44
56
|
countStepperRoot: '.count-stepper',
|
|
45
57
|
ctaButton: '.complete-widget__cta .btn',
|
|
46
|
-
ctaButtonText: '.loading-button__text',
|
|
47
|
-
ctaButtonLoader: '.loading-button__loader',
|
|
48
58
|
summaryPriceValue: '.complete-widget__price-value',
|
|
49
59
|
summarySalePrice: '.complete-widget__sale-price',
|
|
50
|
-
summaryPriceInc: '.including-vat-inherit',
|
|
51
|
-
summaryPriceExc: '.excluding-vat-inherit',
|
|
52
|
-
summarySalePriceInc: '.including-vat-inherit',
|
|
53
|
-
summarySalePriceExc: '.excluding-vat-inherit',
|
|
54
60
|
|
|
55
61
|
dropdownErrorClass: 'complete-card-dropdown--error',
|
|
56
62
|
dropdownOpenClass: 'complete-card-dropdown--open',
|
|
@@ -68,8 +74,6 @@ Wick.BloomreachWidget = {
|
|
|
68
74
|
recommendationIndexAttr: 'data-recommendation-index',
|
|
69
75
|
selectedClass: 'complete-card--selected',
|
|
70
76
|
selectedValueData: 'selected-value',
|
|
71
|
-
starOverlay: '.star-overlay',
|
|
72
|
-
|
|
73
77
|
titleEl: '.complete-card__title',
|
|
74
78
|
|
|
75
79
|
widgetContainer: '[data-complete-widget]',
|
|
@@ -77,14 +81,6 @@ Wick.BloomreachWidget = {
|
|
|
77
81
|
widgetWrapper: '[data-complete-widget-wrapper]',
|
|
78
82
|
},
|
|
79
83
|
|
|
80
|
-
badgeColorMap: {
|
|
81
|
-
blue: '#019ee3',
|
|
82
|
-
gray: '#3e3e3e',
|
|
83
|
-
green: '#9acd32',
|
|
84
|
-
red: '#cf000f',
|
|
85
|
-
yellow: '#f7ca18',
|
|
86
|
-
},
|
|
87
|
-
|
|
88
84
|
getCtaText(selectedCount) {
|
|
89
85
|
if (!selectedCount) {
|
|
90
86
|
return 'Add product(s) to basket';
|
|
@@ -94,8 +90,7 @@ Wick.BloomreachWidget = {
|
|
|
94
90
|
},
|
|
95
91
|
|
|
96
92
|
setCtaText($button, text) {
|
|
97
|
-
const
|
|
98
|
-
const $text = $button.find(ctaButtonText);
|
|
93
|
+
const $text = $button.find(Wick.BloomreachWidget.el.loadingButtonText);
|
|
99
94
|
|
|
100
95
|
if ($text.length) {
|
|
101
96
|
$text.text(text);
|
|
@@ -105,64 +100,6 @@ Wick.BloomreachWidget = {
|
|
|
105
100
|
$button.text(text);
|
|
106
101
|
},
|
|
107
102
|
|
|
108
|
-
getBadgeColor(color) {
|
|
109
|
-
return Wick.BloomreachWidget.badgeColorMap[color] || color;
|
|
110
|
-
},
|
|
111
|
-
|
|
112
|
-
hasRecommendations(payloadData) {
|
|
113
|
-
if (Array.isArray(payloadData)) {
|
|
114
|
-
return payloadData.length > 0;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return Boolean(
|
|
118
|
-
payloadData &&
|
|
119
|
-
Array.isArray(payloadData.recommendedProducts) &&
|
|
120
|
-
payloadData.recommendedProducts.length
|
|
121
|
-
);
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
normalizePayload(payloadData) {
|
|
125
|
-
if (Array.isArray(payloadData)) {
|
|
126
|
-
return payloadData;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if (payloadData && Array.isArray(payloadData.recommendedProducts)) {
|
|
130
|
-
return payloadData.recommendedProducts;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return [];
|
|
134
|
-
},
|
|
135
|
-
|
|
136
|
-
getDisplayPrice(product) {
|
|
137
|
-
return product.displayPrice || product.price || {};
|
|
138
|
-
},
|
|
139
|
-
|
|
140
|
-
dispatchWidgetEvent(eventName, payload) {
|
|
141
|
-
return new Promise(function (resolve, reject) {
|
|
142
|
-
const eventDetail = { resolve, reject };
|
|
143
|
-
const event = createEvent(eventName, payload, eventDetail);
|
|
144
|
-
|
|
145
|
-
window.dispatchEvent(event);
|
|
146
|
-
});
|
|
147
|
-
},
|
|
148
|
-
|
|
149
|
-
getProductImage(product, fallbackProduct) {
|
|
150
|
-
const productImages = product.images || [];
|
|
151
|
-
const fallbackImages = fallbackProduct ? fallbackProduct.images || [] : [];
|
|
152
|
-
const images = productImages.length ? productImages : fallbackImages;
|
|
153
|
-
|
|
154
|
-
return (
|
|
155
|
-
images.find(function (item) {
|
|
156
|
-
return item.format === 'product';
|
|
157
|
-
}) ||
|
|
158
|
-
images.find(function (item) {
|
|
159
|
-
return item.imageType === 'PRIMARY';
|
|
160
|
-
}) ||
|
|
161
|
-
images[0] ||
|
|
162
|
-
{}
|
|
163
|
-
);
|
|
164
|
-
},
|
|
165
|
-
|
|
166
103
|
getDropdownOptions(product) {
|
|
167
104
|
if (!product.variantOptions || !product.variantOptions.length) {
|
|
168
105
|
return [];
|
|
@@ -199,95 +136,12 @@ Wick.BloomreachWidget = {
|
|
|
199
136
|
return;
|
|
200
137
|
}
|
|
201
138
|
|
|
202
|
-
|
|
139
|
+
CompleteYourProjectWidget.toast.show({
|
|
203
140
|
type: bulkData.messageType,
|
|
204
141
|
text: bulkData.messageText,
|
|
205
142
|
});
|
|
206
143
|
},
|
|
207
144
|
|
|
208
|
-
getBadge(product) {
|
|
209
|
-
const promotion = product.potentialPromotions && product.potentialPromotions[0];
|
|
210
|
-
const promotionAttributes = promotion && promotion.customAttributes;
|
|
211
|
-
|
|
212
|
-
if (promotionAttributes && promotionAttributes.overlayText) {
|
|
213
|
-
return {
|
|
214
|
-
text: promotionAttributes.overlayText,
|
|
215
|
-
textColor: Wick.BloomreachWidget.getBadgeColor(
|
|
216
|
-
promotionAttributes.overlayTextColor
|
|
217
|
-
),
|
|
218
|
-
color: Wick.BloomreachWidget.getBadgeColor(
|
|
219
|
-
promotionAttributes.overlayBackgroundColor
|
|
220
|
-
),
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
return product.badge;
|
|
225
|
-
},
|
|
226
|
-
|
|
227
|
-
getWasPrice(product) {
|
|
228
|
-
const displayPrice = Wick.BloomreachWidget.getDisplayPrice(product);
|
|
229
|
-
|
|
230
|
-
return displayPrice && displayPrice.wasPrice ? displayPrice.wasPrice : null;
|
|
231
|
-
},
|
|
232
|
-
|
|
233
|
-
getWasPriceFormatted(product) {
|
|
234
|
-
const displayPrice = Wick.BloomreachWidget.getDisplayPrice(product);
|
|
235
|
-
const wasPrice = Wick.BloomreachWidget.getWasPrice(product);
|
|
236
|
-
|
|
237
|
-
if (wasPrice && wasPrice.formattedValue) {
|
|
238
|
-
return wasPrice.formattedValue;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
if (typeof wasPrice === 'number') {
|
|
242
|
-
return Wick.BloomreachWidget.formatPrice(wasPrice);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
if (wasPrice) {
|
|
246
|
-
return `${displayPrice.currencySymbol || '£'}${wasPrice}`;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
return '';
|
|
250
|
-
},
|
|
251
|
-
|
|
252
|
-
getDisplayPriceExcVat(product) {
|
|
253
|
-
return product.displayPriceExclusiveVat || product.priceExclusiveVat || null;
|
|
254
|
-
},
|
|
255
|
-
|
|
256
|
-
getPriceValue(price) {
|
|
257
|
-
return price && typeof price.value === 'number' ? price.value : 0;
|
|
258
|
-
},
|
|
259
|
-
|
|
260
|
-
getPriceFormattedValue(price) {
|
|
261
|
-
if (!price) {
|
|
262
|
-
return '';
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
if (price.formattedValue) {
|
|
266
|
-
return price.formattedValue;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
if (typeof price.value === 'number') {
|
|
270
|
-
return Wick.BloomreachWidget.formatPrice(price.value);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
return '';
|
|
274
|
-
},
|
|
275
|
-
|
|
276
|
-
getExcVatWasPrice(product) {
|
|
277
|
-
const displayPriceExclusiveVat = Wick.BloomreachWidget.getDisplayPriceExcVat(product);
|
|
278
|
-
const wasPrice = displayPriceExclusiveVat && displayPriceExclusiveVat.wasPrice;
|
|
279
|
-
|
|
280
|
-
if (wasPrice && wasPrice.formattedValue) {
|
|
281
|
-
return wasPrice.formattedValue;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
if (typeof wasPrice === 'number') {
|
|
285
|
-
return Wick.BloomreachWidget.formatPrice(wasPrice);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
return wasPrice || '';
|
|
289
|
-
},
|
|
290
|
-
|
|
291
145
|
getExcVatFormattedValue(displayPrice, product) {
|
|
292
146
|
const excVat = product ? Wick.BloomreachWidget.getDisplayPriceExcVat(product) : null;
|
|
293
147
|
if (excVat && excVat.formattedValue) {
|
|
@@ -303,10 +157,10 @@ Wick.BloomreachWidget = {
|
|
|
303
157
|
getProductRenderData(product, index, options = {}) {
|
|
304
158
|
const shouldShowDropdown = index !== 0;
|
|
305
159
|
const dropdownOptions = shouldShowDropdown
|
|
306
|
-
?
|
|
160
|
+
? CompleteYourProjectWidget.getDropdownOptions(product)
|
|
307
161
|
: [];
|
|
308
162
|
const selectedDropdownValue = options.selectedDropdownValue || '';
|
|
309
|
-
const selectedDropdownLabel =
|
|
163
|
+
const selectedDropdownLabel = CompleteYourProjectWidget.getSelectedDropdownLabel(
|
|
310
164
|
dropdownOptions,
|
|
311
165
|
selectedDropdownValue
|
|
312
166
|
);
|
|
@@ -319,15 +173,13 @@ Wick.BloomreachWidget = {
|
|
|
319
173
|
);
|
|
320
174
|
|
|
321
175
|
const wasPriceFormatted = Wick.BloomreachWidget.getWasPriceFormatted(product);
|
|
322
|
-
const excVatFormattedValue =
|
|
176
|
+
const excVatFormattedValue = CompleteYourProjectWidget.getExcVatFormattedValue(
|
|
323
177
|
displayPrice,
|
|
324
178
|
product
|
|
325
179
|
);
|
|
326
180
|
const isSwitchVat = !!(window.ACC && window.ACC.app && window.ACC.app.isVatToggleAvailable);
|
|
327
181
|
|
|
328
|
-
const excVatWasPriceFormatted =
|
|
329
|
-
? Wick.BloomreachWidget.getExcVatWasPrice(product)
|
|
330
|
-
: '';
|
|
182
|
+
const excVatWasPriceFormatted = Wick.BloomreachWidget.getExcVatWasPrice(product);
|
|
331
183
|
|
|
332
184
|
return {
|
|
333
185
|
...product,
|
|
@@ -342,7 +194,11 @@ Wick.BloomreachWidget = {
|
|
|
342
194
|
Wick.BloomreachWidget.getDisplayPriceExcVat(product)
|
|
343
195
|
),
|
|
344
196
|
incVatWasPriceFormatted: wasPriceFormatted,
|
|
197
|
+
wasPriceIncVatFormattedValue: wasPriceFormatted,
|
|
198
|
+
incVatWasPriceFormattedValue: wasPriceFormatted,
|
|
345
199
|
excVatWasPriceFormatted,
|
|
200
|
+
wasPriceExcVatFormattedValue: excVatWasPriceFormatted,
|
|
201
|
+
excVatWasPriceFormattedValue: excVatWasPriceFormatted,
|
|
346
202
|
showFromPrice,
|
|
347
203
|
image:
|
|
348
204
|
options.image ||
|
|
@@ -363,7 +219,7 @@ Wick.BloomreachWidget = {
|
|
|
363
219
|
|
|
364
220
|
renderWidget($container, context) {
|
|
365
221
|
const { widgetContent, widgetWrapper, completeCard, recommendationIndexAttr } =
|
|
366
|
-
|
|
222
|
+
CompleteYourProjectWidget.el;
|
|
367
223
|
|
|
368
224
|
const $content = $container.find(widgetContent);
|
|
369
225
|
const recommendations = Wick.BloomreachWidget.normalizePayload(context);
|
|
@@ -372,16 +228,16 @@ Wick.BloomreachWidget = {
|
|
|
372
228
|
return;
|
|
373
229
|
}
|
|
374
230
|
|
|
375
|
-
|
|
231
|
+
CompleteYourProjectWidget.recommendations = recommendations;
|
|
376
232
|
|
|
377
233
|
$content.html(completeWrapperTemplate());
|
|
378
234
|
|
|
379
235
|
const $wrapper = $content.find(widgetWrapper);
|
|
380
236
|
|
|
381
|
-
|
|
237
|
+
CompleteYourProjectWidget.dropdownCurrent = {};
|
|
382
238
|
|
|
383
239
|
recommendations.forEach(function (recommendation, index) {
|
|
384
|
-
const product =
|
|
240
|
+
const product = CompleteYourProjectWidget.getProductRenderData(
|
|
385
241
|
recommendation.baseProduct,
|
|
386
242
|
index
|
|
387
243
|
);
|
|
@@ -402,7 +258,7 @@ Wick.BloomreachWidget = {
|
|
|
402
258
|
},
|
|
403
259
|
|
|
404
260
|
renderWidgetFromPayload(payloadData) {
|
|
405
|
-
const { widgetContainer, completeWidget } =
|
|
261
|
+
const { widgetContainer, completeWidget } = CompleteYourProjectWidget.el;
|
|
406
262
|
const $containers = $(widgetContainer);
|
|
407
263
|
|
|
408
264
|
if (!$containers.length) {
|
|
@@ -417,46 +273,23 @@ Wick.BloomreachWidget = {
|
|
|
417
273
|
$containers.each(function () {
|
|
418
274
|
const $container = $(this);
|
|
419
275
|
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
});
|
|
423
|
-
},
|
|
424
|
-
|
|
425
|
-
drawRating($root) {
|
|
426
|
-
const $ratingOverlay = $root.find('.rating-overlay');
|
|
427
|
-
|
|
428
|
-
$ratingOverlay.each(function () {
|
|
429
|
-
let rating = parseFloat($(this).attr('data-rating')) || 0;
|
|
430
|
-
const $stars = $(this).children(Wick.BloomreachWidget.el.starOverlay);
|
|
431
|
-
|
|
432
|
-
$stars.each(function () {
|
|
433
|
-
const $star = $(this);
|
|
434
|
-
|
|
435
|
-
if (rating >= 1) {
|
|
436
|
-
rating--;
|
|
437
|
-
} else if (rating > 0) {
|
|
438
|
-
const width = Math.asin(2 * rating - 1) / Math.PI + 0.5;
|
|
439
|
-
$star.css('width', width + 'rem');
|
|
440
|
-
rating = 0;
|
|
441
|
-
} else {
|
|
442
|
-
$star.css('width', '0rem');
|
|
443
|
-
}
|
|
444
|
-
});
|
|
276
|
+
CompleteYourProjectWidget.renderWidget($container, payloadData);
|
|
277
|
+
CompleteYourProjectWidget.initRenderedWidget($container);
|
|
445
278
|
});
|
|
446
279
|
},
|
|
447
280
|
|
|
448
281
|
getDropdownCard($dropdown) {
|
|
449
|
-
return $dropdown.closest(
|
|
282
|
+
return $dropdown.closest(CompleteYourProjectWidget.el.completeCard);
|
|
450
283
|
},
|
|
451
284
|
|
|
452
285
|
getDropdownCheckbox($dropdown) {
|
|
453
|
-
return
|
|
454
|
-
|
|
286
|
+
return CompleteYourProjectWidget.getDropdownCard($dropdown).find(
|
|
287
|
+
CompleteYourProjectWidget.el.cardCheckbox
|
|
455
288
|
);
|
|
456
289
|
},
|
|
457
290
|
|
|
458
291
|
setDropdownCheckboxState($dropdown, isChecked, shouldTriggerChange = true) {
|
|
459
|
-
const $checkbox =
|
|
292
|
+
const $checkbox = CompleteYourProjectWidget.getDropdownCheckbox($dropdown);
|
|
460
293
|
|
|
461
294
|
if (!$checkbox.length) {
|
|
462
295
|
return;
|
|
@@ -470,18 +303,18 @@ Wick.BloomreachWidget = {
|
|
|
470
303
|
},
|
|
471
304
|
|
|
472
305
|
setDropdownError($dropdown, hasError) {
|
|
473
|
-
$dropdown.toggleClass(
|
|
306
|
+
$dropdown.toggleClass(CompleteYourProjectWidget.el.dropdownErrorClass, hasError);
|
|
474
307
|
},
|
|
475
308
|
|
|
476
309
|
validateDropdown($dropdown, options = {}) {
|
|
477
|
-
const isValid = Boolean($dropdown.data(
|
|
310
|
+
const isValid = Boolean($dropdown.data(CompleteYourProjectWidget.el.selectedValueData));
|
|
478
311
|
|
|
479
|
-
|
|
312
|
+
CompleteYourProjectWidget.setDropdownError($dropdown, !isValid);
|
|
480
313
|
|
|
481
314
|
if (!isValid && options.uncheck) {
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
315
|
+
CompleteYourProjectWidget.setDropdownCheckboxState($dropdown, false, false);
|
|
316
|
+
CompleteYourProjectWidget.getDropdownCard($dropdown).removeClass(
|
|
317
|
+
CompleteYourProjectWidget.el.selectedClass
|
|
485
318
|
);
|
|
486
319
|
}
|
|
487
320
|
|
|
@@ -489,13 +322,13 @@ Wick.BloomreachWidget = {
|
|
|
489
322
|
},
|
|
490
323
|
|
|
491
324
|
validateCardDropdown($card, options = {}) {
|
|
492
|
-
const $dropdown = $card.find(
|
|
325
|
+
const $dropdown = $card.find(CompleteYourProjectWidget.el.dropdownRoot);
|
|
493
326
|
|
|
494
327
|
if (!$dropdown.length) {
|
|
495
328
|
return true;
|
|
496
329
|
}
|
|
497
330
|
|
|
498
|
-
return
|
|
331
|
+
return CompleteYourProjectWidget.validateDropdown($dropdown, options);
|
|
499
332
|
},
|
|
500
333
|
|
|
501
334
|
findVariantProduct(recommendation, selectedValue) {
|
|
@@ -509,7 +342,7 @@ Wick.BloomreachWidget = {
|
|
|
509
342
|
},
|
|
510
343
|
|
|
511
344
|
getCardQuantity($card) {
|
|
512
|
-
const $input = $card.find(
|
|
345
|
+
const $input = $card.find(CompleteYourProjectWidget.el.quantityInput);
|
|
513
346
|
const quantity = parseInt($input.val(), 10);
|
|
514
347
|
|
|
515
348
|
return Number.isNaN(quantity) ? 1 : quantity;
|
|
@@ -517,10 +350,10 @@ Wick.BloomreachWidget = {
|
|
|
517
350
|
|
|
518
351
|
getCardProduct($card) {
|
|
519
352
|
const { recommendationIndexAttr, dropdownRoot, selectedValueData } =
|
|
520
|
-
|
|
353
|
+
CompleteYourProjectWidget.el;
|
|
521
354
|
|
|
522
355
|
const recommendationIndex = Number($card.attr(recommendationIndexAttr));
|
|
523
|
-
const recommendation =
|
|
356
|
+
const recommendation = CompleteYourProjectWidget.recommendations[recommendationIndex];
|
|
524
357
|
|
|
525
358
|
if (!recommendation) {
|
|
526
359
|
return null;
|
|
@@ -531,7 +364,7 @@ Wick.BloomreachWidget = {
|
|
|
531
364
|
|
|
532
365
|
if (selectedValue) {
|
|
533
366
|
return (
|
|
534
|
-
|
|
367
|
+
CompleteYourProjectWidget.findVariantProduct(recommendation, selectedValue) ||
|
|
535
368
|
recommendation.baseProduct
|
|
536
369
|
);
|
|
537
370
|
}
|
|
@@ -540,7 +373,7 @@ Wick.BloomreachWidget = {
|
|
|
540
373
|
},
|
|
541
374
|
|
|
542
375
|
getSelectedEntries($root) {
|
|
543
|
-
const { completeCard, cardCheckbox } =
|
|
376
|
+
const { completeCard, cardCheckbox } = CompleteYourProjectWidget.el;
|
|
544
377
|
const entries = [];
|
|
545
378
|
|
|
546
379
|
$root.find(completeCard).each(function () {
|
|
@@ -551,7 +384,7 @@ Wick.BloomreachWidget = {
|
|
|
551
384
|
return;
|
|
552
385
|
}
|
|
553
386
|
|
|
554
|
-
const product =
|
|
387
|
+
const product = CompleteYourProjectWidget.getCardProduct($card);
|
|
555
388
|
|
|
556
389
|
if (!product) {
|
|
557
390
|
return;
|
|
@@ -559,7 +392,7 @@ Wick.BloomreachWidget = {
|
|
|
559
392
|
|
|
560
393
|
entries.push({
|
|
561
394
|
product,
|
|
562
|
-
quantity:
|
|
395
|
+
quantity: CompleteYourProjectWidget.getCardQuantity($card),
|
|
563
396
|
});
|
|
564
397
|
});
|
|
565
398
|
|
|
@@ -567,7 +400,7 @@ Wick.BloomreachWidget = {
|
|
|
567
400
|
},
|
|
568
401
|
|
|
569
402
|
getAddToCartEntries($root) {
|
|
570
|
-
return
|
|
403
|
+
return CompleteYourProjectWidget.getSelectedEntries($root).map(function (entry) {
|
|
571
404
|
return {
|
|
572
405
|
productCode: entry.product.code,
|
|
573
406
|
quantity: entry.quantity,
|
|
@@ -581,16 +414,10 @@ Wick.BloomreachWidget = {
|
|
|
581
414
|
const totalWasPriceExclusiveVat =
|
|
582
415
|
response.totalWasPriceExclusiveVat || response.totalExcVatWasPrice;
|
|
583
416
|
|
|
584
|
-
const {
|
|
585
|
-
|
|
586
|
-
summarySalePrice,
|
|
587
|
-
summaryPriceInc,
|
|
588
|
-
summaryPriceExc,
|
|
589
|
-
summarySalePriceInc,
|
|
590
|
-
summarySalePriceExc,
|
|
591
|
-
} = Wick.BloomreachWidget.el;
|
|
417
|
+
const { summaryPriceValue, summarySalePrice } = CompleteYourProjectWidget.el;
|
|
418
|
+
const { vatInc, vatExc } = Wick.BloomreachWidget.el;
|
|
592
419
|
|
|
593
|
-
|
|
420
|
+
CompleteYourProjectWidget.lastCalculationResponse = response;
|
|
594
421
|
|
|
595
422
|
const $price = $root.find(summaryPriceValue);
|
|
596
423
|
const $salePrice = $root.find(summarySalePrice);
|
|
@@ -602,46 +429,43 @@ Wick.BloomreachWidget = {
|
|
|
602
429
|
|
|
603
430
|
if (response.totalWasPrice) {
|
|
604
431
|
$total.addClass('complete-widget__total-sale');
|
|
605
|
-
const $priceInc = $price.find(
|
|
432
|
+
const $priceInc = $price.find(vatInc);
|
|
606
433
|
|
|
607
434
|
if ($priceInc.length) {
|
|
608
435
|
$priceInc.text(response.totalWasPrice);
|
|
609
|
-
$price
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
$salePrice.find(summarySalePriceInc).text(response.totalPrice || '');
|
|
614
|
-
$salePrice
|
|
615
|
-
.find(summarySalePriceExc)
|
|
616
|
-
.text(totalPriceExclusiveVat || response.totalPrice || '');
|
|
436
|
+
$price.find(vatExc).text(totalWasPriceExclusiveVat || response.totalWasPrice);
|
|
437
|
+
|
|
438
|
+
$salePrice.find(vatInc).text(response.totalPrice || '');
|
|
439
|
+
$salePrice.find(vatExc).text(totalPriceExclusiveVat || response.totalPrice || '');
|
|
617
440
|
} else {
|
|
618
441
|
$price.text(response.totalWasPrice);
|
|
619
442
|
$salePrice.text(response.totalPrice || '');
|
|
620
443
|
}
|
|
621
444
|
|
|
622
445
|
$salePrice.show();
|
|
446
|
+
Wick.BloomreachWidget.reapplyVatDisplay();
|
|
623
447
|
return;
|
|
624
448
|
}
|
|
625
449
|
|
|
626
450
|
$total.removeClass('complete-widget__total-sale');
|
|
627
|
-
const $priceInc = $price.find(
|
|
451
|
+
const $priceInc = $price.find(vatInc);
|
|
628
452
|
if ($priceInc.length) {
|
|
629
453
|
$priceInc.text(response.totalPrice || '£0.00');
|
|
630
|
-
$price
|
|
631
|
-
.find(summaryPriceExc)
|
|
632
|
-
.text(totalPriceExclusiveVat || response.totalPrice || '£0.00');
|
|
454
|
+
$price.find(vatExc).text(totalPriceExclusiveVat || response.totalPrice || '£0.00');
|
|
633
455
|
|
|
634
|
-
$salePrice.find(
|
|
635
|
-
$salePrice.find(
|
|
456
|
+
$salePrice.find(vatInc).text('');
|
|
457
|
+
$salePrice.find(vatExc).text('');
|
|
636
458
|
$salePrice.hide();
|
|
637
459
|
} else {
|
|
638
460
|
$price.text(response.totalPrice || '£0.00');
|
|
639
461
|
$salePrice.text('').hide();
|
|
640
462
|
}
|
|
463
|
+
|
|
464
|
+
Wick.BloomreachWidget.reapplyVatDisplay();
|
|
641
465
|
},
|
|
642
466
|
|
|
643
467
|
updateCta($root) {
|
|
644
|
-
const { ctaButton, cardCheckbox } =
|
|
468
|
+
const { ctaButton, cardCheckbox } = CompleteYourProjectWidget.el;
|
|
645
469
|
const selectedCount = $root.find(cardCheckbox).filter(':checked').length;
|
|
646
470
|
const $cta = $root.find(ctaButton);
|
|
647
471
|
|
|
@@ -650,44 +474,43 @@ Wick.BloomreachWidget = {
|
|
|
650
474
|
}
|
|
651
475
|
|
|
652
476
|
$cta.prop('disabled', !selectedCount);
|
|
653
|
-
|
|
477
|
+
CompleteYourProjectWidget.setCtaText(
|
|
478
|
+
$cta,
|
|
479
|
+
CompleteYourProjectWidget.getCtaText(selectedCount)
|
|
480
|
+
);
|
|
654
481
|
},
|
|
655
482
|
|
|
656
483
|
dispatchCalculateTotal($root) {
|
|
657
|
-
|
|
484
|
+
CompleteYourProjectWidget.updateCta($root);
|
|
658
485
|
|
|
659
486
|
return Wick.BloomreachWidget.dispatchWidgetEvent(
|
|
660
|
-
|
|
487
|
+
CompleteYourProjectWidget.CALCULATE_PRODUCT_BUNDLE_TOTAL_EVENT,
|
|
661
488
|
{
|
|
662
|
-
entries:
|
|
489
|
+
entries: CompleteYourProjectWidget.getSelectedEntries($root),
|
|
663
490
|
}
|
|
664
491
|
).then(function (response) {
|
|
665
|
-
|
|
492
|
+
CompleteYourProjectWidget.updateSummary($root, response);
|
|
666
493
|
});
|
|
667
494
|
},
|
|
668
495
|
|
|
669
496
|
dispatchAddToCart($root, $button) {
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
return new Promise(function (resolve, reject) {
|
|
673
|
-
const eventDetail = { resolve, reject };
|
|
674
|
-
const event = createEvent(
|
|
675
|
-
Wick.BloomreachWidget.ADD_PRODUCT_BUNDLE_TO_CART_EVENT,
|
|
676
|
-
{
|
|
677
|
-
entries: Wick.BloomreachWidget.getAddToCartEntries($root),
|
|
678
|
-
},
|
|
679
|
-
eventDetail
|
|
680
|
-
);
|
|
497
|
+
CompleteYourProjectWidget.loadingButton.start($button);
|
|
681
498
|
|
|
682
|
-
|
|
683
|
-
|
|
499
|
+
return Wick.BloomreachWidget.dispatchWidgetEvent(
|
|
500
|
+
CompleteYourProjectWidget.ADD_PRODUCT_BUNDLE_TO_CART_EVENT,
|
|
501
|
+
{
|
|
502
|
+
entries: CompleteYourProjectWidget.getAddToCartEntries($root),
|
|
503
|
+
}
|
|
504
|
+
)
|
|
684
505
|
.then(function (response) {
|
|
685
|
-
|
|
506
|
+
CompleteYourProjectWidget.handleBulkAddToCartResponse(response);
|
|
686
507
|
|
|
687
|
-
Wick.MiniBasketSliderFE
|
|
508
|
+
if (Wick.MiniBasketSliderFE) {
|
|
509
|
+
Wick.MiniBasketSliderFE.isMiniBasketLoaded = false;
|
|
510
|
+
}
|
|
688
511
|
})
|
|
689
512
|
.catch(function () {
|
|
690
|
-
|
|
513
|
+
CompleteYourProjectWidget.handleBulkAddToCartResponse({
|
|
691
514
|
bulkAddToCartData: {
|
|
692
515
|
messageType: 'error',
|
|
693
516
|
messageText: 'Selected product(s) were not added to basket',
|
|
@@ -695,19 +518,20 @@ Wick.BloomreachWidget = {
|
|
|
695
518
|
});
|
|
696
519
|
})
|
|
697
520
|
.finally(function () {
|
|
698
|
-
|
|
699
|
-
|
|
521
|
+
CompleteYourProjectWidget.loadingButton.stop($button);
|
|
522
|
+
CompleteYourProjectWidget.updateCta($root);
|
|
700
523
|
});
|
|
701
524
|
},
|
|
702
525
|
|
|
703
526
|
reinitCard($card) {
|
|
704
|
-
const { countBtn, completeWidget } =
|
|
527
|
+
const { countBtn, completeWidget } = CompleteYourProjectWidget.el;
|
|
705
528
|
|
|
706
529
|
$card.find(countBtn).remove();
|
|
707
530
|
|
|
708
|
-
|
|
531
|
+
CompleteYourProjectWidget.initQuantityFields($card);
|
|
709
532
|
Wick.BloomreachWidget.drawRating($card);
|
|
710
|
-
|
|
533
|
+
CompleteYourProjectWidget.alignCardBlocks($card.closest(completeWidget));
|
|
534
|
+
Wick.BloomreachWidget.reapplyVatDisplay();
|
|
711
535
|
},
|
|
712
536
|
|
|
713
537
|
replaceCardWithBaseProduct($dropdown, options = {}) {
|
|
@@ -717,17 +541,17 @@ Wick.BloomreachWidget = {
|
|
|
717
541
|
dropdownRoot,
|
|
718
542
|
dropdownErrorClass,
|
|
719
543
|
cardCheckbox,
|
|
720
|
-
} =
|
|
544
|
+
} = CompleteYourProjectWidget.el;
|
|
721
545
|
|
|
722
546
|
const $card = $dropdown.closest(completeCard);
|
|
723
547
|
const recommendationIndex = Number($card.attr(recommendationIndexAttr));
|
|
724
|
-
const recommendation =
|
|
548
|
+
const recommendation = CompleteYourProjectWidget.recommendations[recommendationIndex];
|
|
725
549
|
|
|
726
550
|
if (!recommendation || !recommendation.baseProduct) {
|
|
727
551
|
return null;
|
|
728
552
|
}
|
|
729
553
|
|
|
730
|
-
const productData =
|
|
554
|
+
const productData = CompleteYourProjectWidget.getProductRenderData(
|
|
731
555
|
recommendation.baseProduct,
|
|
732
556
|
recommendationIndex,
|
|
733
557
|
{
|
|
@@ -750,13 +574,13 @@ Wick.BloomreachWidget = {
|
|
|
750
574
|
$newCard.find(cardCheckbox).prop('checked', false);
|
|
751
575
|
|
|
752
576
|
$newCard
|
|
753
|
-
.find(
|
|
577
|
+
.find(CompleteYourProjectWidget.el.quantityInput)
|
|
754
578
|
.val(1)
|
|
755
|
-
.data(
|
|
756
|
-
.removeData(
|
|
757
|
-
.removeData(
|
|
579
|
+
.data(CompleteYourProjectWidget.el.previousQuantityData, 1)
|
|
580
|
+
.removeData(CompleteYourProjectWidget.el.quantityReadyData)
|
|
581
|
+
.removeData(CompleteYourProjectWidget.el.countStepperInitializedData);
|
|
758
582
|
|
|
759
|
-
|
|
583
|
+
CompleteYourProjectWidget.reinitCard($newCard);
|
|
760
584
|
|
|
761
585
|
return $newCard;
|
|
762
586
|
},
|
|
@@ -769,17 +593,17 @@ Wick.BloomreachWidget = {
|
|
|
769
593
|
dropdownRoot,
|
|
770
594
|
selectedValueData,
|
|
771
595
|
cardCheckbox,
|
|
772
|
-
} =
|
|
596
|
+
} = CompleteYourProjectWidget.el;
|
|
773
597
|
|
|
774
598
|
const $card = $dropdown.closest(completeCard);
|
|
775
599
|
const recommendationIndex = Number($card.attr(recommendationIndexAttr));
|
|
776
|
-
const recommendation =
|
|
600
|
+
const recommendation = CompleteYourProjectWidget.recommendations[recommendationIndex];
|
|
777
601
|
|
|
778
602
|
if (!recommendation) {
|
|
779
603
|
return null;
|
|
780
604
|
}
|
|
781
605
|
|
|
782
|
-
const variantProduct =
|
|
606
|
+
const variantProduct = CompleteYourProjectWidget.findVariantProduct(
|
|
783
607
|
recommendation,
|
|
784
608
|
selectedValue
|
|
785
609
|
);
|
|
@@ -788,7 +612,7 @@ Wick.BloomreachWidget = {
|
|
|
788
612
|
return null;
|
|
789
613
|
}
|
|
790
614
|
|
|
791
|
-
const productData =
|
|
615
|
+
const productData = CompleteYourProjectWidget.getProductRenderData(
|
|
792
616
|
{
|
|
793
617
|
...variantProduct,
|
|
794
618
|
variantOptions: recommendation.baseProduct.variantOptions,
|
|
@@ -818,51 +642,53 @@ Wick.BloomreachWidget = {
|
|
|
818
642
|
$newCard.find(cardCheckbox).prop('checked', true);
|
|
819
643
|
|
|
820
644
|
$newCard
|
|
821
|
-
.find(
|
|
645
|
+
.find(CompleteYourProjectWidget.el.quantityInput)
|
|
822
646
|
.val(1)
|
|
823
|
-
.data(
|
|
824
|
-
.removeData(
|
|
825
|
-
.removeData(
|
|
647
|
+
.data(CompleteYourProjectWidget.el.previousQuantityData, 1)
|
|
648
|
+
.removeData(CompleteYourProjectWidget.el.quantityReadyData)
|
|
649
|
+
.removeData(CompleteYourProjectWidget.el.countStepperInitializedData);
|
|
826
650
|
|
|
827
|
-
|
|
651
|
+
CompleteYourProjectWidget.reinitCard($newCard);
|
|
828
652
|
|
|
829
653
|
return $newCard;
|
|
830
654
|
},
|
|
831
655
|
|
|
832
656
|
handleDropdownSelect($dropdown, selectedValue) {
|
|
833
|
-
const $card = $dropdown.closest(
|
|
834
|
-
const recommendationIndex = $card.attr(
|
|
835
|
-
|
|
657
|
+
const $card = $dropdown.closest(CompleteYourProjectWidget.el.completeCard);
|
|
658
|
+
const recommendationIndex = $card.attr(
|
|
659
|
+
CompleteYourProjectWidget.el.recommendationIndexAttr
|
|
660
|
+
);
|
|
661
|
+
const currentValue = CompleteYourProjectWidget.dropdownCurrent[recommendationIndex];
|
|
836
662
|
|
|
837
663
|
if (`${currentValue}` === `${selectedValue}`) {
|
|
838
664
|
return;
|
|
839
665
|
}
|
|
840
666
|
|
|
841
|
-
|
|
667
|
+
CompleteYourProjectWidget.dropdownCurrent[recommendationIndex] = selectedValue;
|
|
842
668
|
|
|
843
|
-
const $completeWidget = $dropdown.closest(
|
|
669
|
+
const $completeWidget = $dropdown.closest(CompleteYourProjectWidget.el.completeWidget);
|
|
844
670
|
const isPlaceholder = !selectedValue;
|
|
845
671
|
|
|
846
672
|
if (isPlaceholder) {
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
673
|
+
CompleteYourProjectWidget.setDropdownError($dropdown, true);
|
|
674
|
+
CompleteYourProjectWidget.setDropdownCheckboxState($dropdown, false, false);
|
|
675
|
+
CompleteYourProjectWidget.replaceCardWithBaseProduct($dropdown, {
|
|
850
676
|
dropdownError: true,
|
|
851
677
|
});
|
|
852
678
|
|
|
853
679
|
if ($completeWidget.length) {
|
|
854
|
-
|
|
680
|
+
CompleteYourProjectWidget.dispatchCalculateTotal($completeWidget);
|
|
855
681
|
}
|
|
856
682
|
|
|
857
683
|
return;
|
|
858
684
|
}
|
|
859
685
|
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
686
|
+
CompleteYourProjectWidget.setDropdownError($dropdown, false);
|
|
687
|
+
CompleteYourProjectWidget.setDropdownCheckboxState($dropdown, true, false);
|
|
688
|
+
CompleteYourProjectWidget.replaceCardWithVariant($dropdown, selectedValue);
|
|
863
689
|
|
|
864
690
|
if ($completeWidget.length) {
|
|
865
|
-
|
|
691
|
+
CompleteYourProjectWidget.dispatchCalculateTotal($completeWidget);
|
|
866
692
|
}
|
|
867
693
|
},
|
|
868
694
|
|
|
@@ -874,9 +700,9 @@ Wick.BloomreachWidget = {
|
|
|
874
700
|
dropdownOption,
|
|
875
701
|
dropdownOpenClass,
|
|
876
702
|
dropdownOptionSelectedClass,
|
|
877
|
-
} =
|
|
703
|
+
} = CompleteYourProjectWidget.el;
|
|
878
704
|
|
|
879
|
-
|
|
705
|
+
CompleteYourProjectWidget.dropdown = createDropdown({
|
|
880
706
|
root: dropdownRoot,
|
|
881
707
|
toggle: dropdownToggle,
|
|
882
708
|
value: dropdownValue,
|
|
@@ -885,15 +711,15 @@ Wick.BloomreachWidget = {
|
|
|
885
711
|
selectedClass: dropdownOptionSelectedClass,
|
|
886
712
|
namespace: 'bloomreachDropdown',
|
|
887
713
|
onSelect($dropdown, $option, selectedValue) {
|
|
888
|
-
|
|
714
|
+
CompleteYourProjectWidget.handleDropdownSelect($dropdown, selectedValue);
|
|
889
715
|
},
|
|
890
716
|
});
|
|
891
717
|
|
|
892
|
-
|
|
718
|
+
CompleteYourProjectWidget.dropdown.bind();
|
|
893
719
|
},
|
|
894
720
|
|
|
895
721
|
bindCardSelection($root) {
|
|
896
|
-
const { completeCard, cardCheckbox, selectedClass } =
|
|
722
|
+
const { completeCard, cardCheckbox, selectedClass } = CompleteYourProjectWidget.el;
|
|
897
723
|
|
|
898
724
|
const $firstCard = $root.find(completeCard).first();
|
|
899
725
|
|
|
@@ -904,11 +730,11 @@ Wick.BloomreachWidget = {
|
|
|
904
730
|
$root.on('change.bloomreachCardSelection', cardCheckbox, function () {
|
|
905
731
|
const $checkbox = $(this);
|
|
906
732
|
const $card = $checkbox.closest(completeCard);
|
|
907
|
-
const $dropdown = $card.find(
|
|
733
|
+
const $dropdown = $card.find(CompleteYourProjectWidget.el.dropdownRoot);
|
|
908
734
|
|
|
909
735
|
if (
|
|
910
736
|
!$checkbox.prop('checked') &&
|
|
911
|
-
$dropdown.hasClass(
|
|
737
|
+
$dropdown.hasClass(CompleteYourProjectWidget.el.dropdownErrorClass)
|
|
912
738
|
) {
|
|
913
739
|
$card.removeClass(selectedClass);
|
|
914
740
|
return;
|
|
@@ -916,7 +742,7 @@ Wick.BloomreachWidget = {
|
|
|
916
742
|
|
|
917
743
|
if (
|
|
918
744
|
$checkbox.prop('checked') &&
|
|
919
|
-
!
|
|
745
|
+
!CompleteYourProjectWidget.validateCardDropdown($card, {
|
|
920
746
|
uncheck: true,
|
|
921
747
|
})
|
|
922
748
|
) {
|
|
@@ -927,12 +753,12 @@ Wick.BloomreachWidget = {
|
|
|
927
753
|
|
|
928
754
|
$card.toggleClass(selectedClass, this.checked);
|
|
929
755
|
|
|
930
|
-
|
|
756
|
+
CompleteYourProjectWidget.dispatchCalculateTotal($root);
|
|
931
757
|
});
|
|
932
758
|
},
|
|
933
759
|
|
|
934
760
|
bindDropdownValidation($root) {
|
|
935
|
-
const { cardCheckbox, completeCard } =
|
|
761
|
+
const { cardCheckbox, completeCard } = CompleteYourProjectWidget.el;
|
|
936
762
|
|
|
937
763
|
$root.off('click.bloomreachDropdownValidation', cardCheckbox);
|
|
938
764
|
$root.on('click.bloomreachDropdownValidation', cardCheckbox, function () {
|
|
@@ -941,18 +767,24 @@ Wick.BloomreachWidget = {
|
|
|
941
767
|
|
|
942
768
|
if (
|
|
943
769
|
$checkbox.prop('checked') &&
|
|
944
|
-
!
|
|
770
|
+
!CompleteYourProjectWidget.validateCardDropdown($card, {
|
|
945
771
|
uncheck: true,
|
|
946
772
|
})
|
|
947
773
|
) {
|
|
948
774
|
$checkbox.prop('checked', false);
|
|
949
|
-
$card.removeClass(
|
|
775
|
+
$card.removeClass(CompleteYourProjectWidget.el.selectedClass);
|
|
950
776
|
}
|
|
951
777
|
});
|
|
952
778
|
},
|
|
953
779
|
|
|
780
|
+
bindVatToggle() {
|
|
781
|
+
if (Wick.BloomreachWidget.bindVatToggle) {
|
|
782
|
+
Wick.BloomreachWidget.bindVatToggle('completeYourProjectVatToggle');
|
|
783
|
+
}
|
|
784
|
+
},
|
|
785
|
+
|
|
954
786
|
bindAddToCart($root) {
|
|
955
|
-
const { ctaButton } =
|
|
787
|
+
const { ctaButton } = CompleteYourProjectWidget.el;
|
|
956
788
|
|
|
957
789
|
$root.off('click.bloomreachAddToCart', ctaButton);
|
|
958
790
|
$root.on('click.bloomreachAddToCart', ctaButton, function (event) {
|
|
@@ -962,12 +794,12 @@ Wick.BloomreachWidget = {
|
|
|
962
794
|
|
|
963
795
|
if (
|
|
964
796
|
$button.prop('disabled') ||
|
|
965
|
-
|
|
797
|
+
CompleteYourProjectWidget.loadingButton.isLoading($button)
|
|
966
798
|
) {
|
|
967
799
|
return;
|
|
968
800
|
}
|
|
969
801
|
|
|
970
|
-
|
|
802
|
+
CompleteYourProjectWidget.dispatchAddToCart($root, $button);
|
|
971
803
|
});
|
|
972
804
|
},
|
|
973
805
|
|
|
@@ -992,14 +824,14 @@ Wick.BloomreachWidget = {
|
|
|
992
824
|
},
|
|
993
825
|
|
|
994
826
|
alignCardBlocks($root) {
|
|
995
|
-
const { titleEl, optionsEl } =
|
|
827
|
+
const { titleEl, optionsEl } = CompleteYourProjectWidget.el;
|
|
996
828
|
|
|
997
|
-
|
|
998
|
-
|
|
829
|
+
CompleteYourProjectWidget.alignBlock(titleEl, $root);
|
|
830
|
+
CompleteYourProjectWidget.alignBlock(optionsEl, $root);
|
|
999
831
|
},
|
|
1000
832
|
|
|
1001
833
|
setInitialSummary($root) {
|
|
1002
|
-
const entries =
|
|
834
|
+
const entries = CompleteYourProjectWidget.getSelectedEntries($root);
|
|
1003
835
|
const firstEntry = entries[0];
|
|
1004
836
|
|
|
1005
837
|
if (!firstEntry || !firstEntry.product) {
|
|
@@ -1011,7 +843,7 @@ Wick.BloomreachWidget = {
|
|
|
1011
843
|
const priceExcVat = Wick.BloomreachWidget.getDisplayPriceExcVat(product);
|
|
1012
844
|
const wasPriceFormatted = Wick.BloomreachWidget.getWasPriceFormatted(product);
|
|
1013
845
|
|
|
1014
|
-
|
|
846
|
+
CompleteYourProjectWidget.updateSummary($root, {
|
|
1015
847
|
totalPrice: Wick.BloomreachWidget.getPriceFormattedValue(displayPrice) || '£0.00',
|
|
1016
848
|
totalWasPrice: wasPriceFormatted || null,
|
|
1017
849
|
totalPriceExclusiveVat: Wick.BloomreachWidget.getPriceFormattedValue(priceExcVat),
|
|
@@ -1025,18 +857,18 @@ Wick.BloomreachWidget = {
|
|
|
1025
857
|
min: 1,
|
|
1026
858
|
onChange(qty, inputEl) {
|
|
1027
859
|
const $input = $(inputEl);
|
|
1028
|
-
const $card = $input.closest(
|
|
1029
|
-
const $completeWidget = $input.closest(
|
|
1030
|
-
const $checkbox = $card.find(
|
|
860
|
+
const $card = $input.closest(CompleteYourProjectWidget.el.completeCard);
|
|
861
|
+
const $completeWidget = $input.closest(CompleteYourProjectWidget.el.completeWidget);
|
|
862
|
+
const $checkbox = $card.find(CompleteYourProjectWidget.el.cardCheckbox);
|
|
1031
863
|
const previousQuantity =
|
|
1032
|
-
$input.data(
|
|
864
|
+
$input.data(CompleteYourProjectWidget.el.previousQuantityData) || 1;
|
|
1033
865
|
|
|
1034
|
-
if (!$input.data(
|
|
1035
|
-
$input.data(
|
|
866
|
+
if (!$input.data(CompleteYourProjectWidget.el.quantityReadyData)) {
|
|
867
|
+
$input.data(CompleteYourProjectWidget.el.previousQuantityData, qty || 1);
|
|
1036
868
|
return;
|
|
1037
869
|
}
|
|
1038
870
|
|
|
1039
|
-
if (!
|
|
871
|
+
if (!CompleteYourProjectWidget.validateCardDropdown($card)) {
|
|
1040
872
|
$input.val(previousQuantity);
|
|
1041
873
|
|
|
1042
874
|
const $minus = $card.find('.count-btn--minus');
|
|
@@ -1049,22 +881,22 @@ Wick.BloomreachWidget = {
|
|
|
1049
881
|
}
|
|
1050
882
|
|
|
1051
883
|
$checkbox.prop('checked', true);
|
|
1052
|
-
$card.addClass(
|
|
884
|
+
$card.addClass(CompleteYourProjectWidget.el.selectedClass);
|
|
1053
885
|
|
|
1054
|
-
$input.data(
|
|
886
|
+
$input.data(CompleteYourProjectWidget.el.previousQuantityData, qty);
|
|
1055
887
|
$input.trigger('change');
|
|
1056
888
|
|
|
1057
889
|
if ($completeWidget.length) {
|
|
1058
|
-
|
|
890
|
+
CompleteYourProjectWidget.dispatchCalculateTotal($completeWidget);
|
|
1059
891
|
}
|
|
1060
892
|
},
|
|
1061
893
|
});
|
|
1062
894
|
|
|
1063
895
|
stepper.init($root);
|
|
1064
896
|
|
|
1065
|
-
$root.find(inputSel).data(
|
|
897
|
+
$root.find(inputSel).data(CompleteYourProjectWidget.el.quantityReadyData, true);
|
|
1066
898
|
|
|
1067
|
-
|
|
899
|
+
CompleteYourProjectWidget.steppers.push(stepper);
|
|
1068
900
|
},
|
|
1069
901
|
|
|
1070
902
|
initQuantityFields($root) {
|
|
@@ -1073,7 +905,7 @@ Wick.BloomreachWidget = {
|
|
|
1073
905
|
countStepperInitializedData,
|
|
1074
906
|
countStepperRoot,
|
|
1075
907
|
previousQuantityData,
|
|
1076
|
-
} =
|
|
908
|
+
} = CompleteYourProjectWidget.el;
|
|
1077
909
|
|
|
1078
910
|
$root.find(quantityInput).each(function () {
|
|
1079
911
|
const $input = $(this);
|
|
@@ -1091,99 +923,94 @@ Wick.BloomreachWidget = {
|
|
|
1091
923
|
$input.data(countStepperInitializedData, true);
|
|
1092
924
|
$input.data(previousQuantityData, parseInt($input.val(), 10) || 1);
|
|
1093
925
|
|
|
1094
|
-
|
|
926
|
+
CompleteYourProjectWidget.initQuantityField(
|
|
1095
927
|
$input.closest(countStepperRoot),
|
|
1096
928
|
`#${inputId}`
|
|
1097
929
|
);
|
|
1098
930
|
});
|
|
1099
931
|
},
|
|
1100
932
|
|
|
1101
|
-
formatPrice(value) {
|
|
1102
|
-
return new Intl.NumberFormat('en-GB', {
|
|
1103
|
-
style: 'currency',
|
|
1104
|
-
currency: 'GBP',
|
|
1105
|
-
minimumFractionDigits: 2,
|
|
1106
|
-
maximumFractionDigits: 2,
|
|
1107
|
-
}).format(value);
|
|
1108
|
-
},
|
|
1109
|
-
|
|
1110
933
|
resetWidgetState($root) {
|
|
1111
|
-
$root.find(
|
|
934
|
+
$root.find(CompleteYourProjectWidget.el.cardCheckbox).prop('checked', false);
|
|
1112
935
|
|
|
1113
936
|
$root
|
|
1114
|
-
.find(
|
|
1115
|
-
.removeClass(
|
|
937
|
+
.find(CompleteYourProjectWidget.el.completeCard)
|
|
938
|
+
.removeClass(CompleteYourProjectWidget.el.selectedClass);
|
|
1116
939
|
|
|
1117
940
|
$root
|
|
1118
|
-
.find(
|
|
941
|
+
.find(CompleteYourProjectWidget.el.quantityInput)
|
|
1119
942
|
.val(1)
|
|
1120
|
-
.data(
|
|
943
|
+
.data(CompleteYourProjectWidget.el.previousQuantityData, 1);
|
|
1121
944
|
},
|
|
1122
945
|
|
|
1123
946
|
resetBackForwardState() {
|
|
1124
|
-
$(
|
|
947
|
+
$(CompleteYourProjectWidget.el.completeWidget).each(function () {
|
|
1125
948
|
const $widget = $(this);
|
|
1126
949
|
|
|
1127
|
-
|
|
1128
|
-
|
|
950
|
+
CompleteYourProjectWidget.resetWidgetState($widget);
|
|
951
|
+
CompleteYourProjectWidget.bindCardSelection($widget);
|
|
1129
952
|
});
|
|
1130
953
|
},
|
|
1131
954
|
|
|
1132
955
|
initRenderedWidget($container) {
|
|
1133
|
-
if (!
|
|
1134
|
-
|
|
956
|
+
if (!CompleteYourProjectWidget.toast) {
|
|
957
|
+
CompleteYourProjectWidget.toast = createToast({
|
|
1135
958
|
template: notificationTemplate,
|
|
1136
959
|
});
|
|
1137
960
|
}
|
|
1138
|
-
if (!
|
|
1139
|
-
|
|
961
|
+
if (!CompleteYourProjectWidget.loadingButton) {
|
|
962
|
+
CompleteYourProjectWidget.loadingButton = createLoadingButton();
|
|
1140
963
|
}
|
|
1141
|
-
const $completeWidget = $container.find(
|
|
964
|
+
const $completeWidget = $container.find(CompleteYourProjectWidget.el.completeWidget);
|
|
1142
965
|
|
|
1143
966
|
if (!$completeWidget.length) {
|
|
1144
967
|
return;
|
|
1145
968
|
}
|
|
1146
969
|
|
|
1147
970
|
Wick.BloomreachWidget.drawRating($completeWidget);
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
971
|
+
CompleteYourProjectWidget.bindCardSelection($completeWidget);
|
|
972
|
+
CompleteYourProjectWidget.bindDropdowns();
|
|
973
|
+
CompleteYourProjectWidget.bindDropdownValidation($completeWidget);
|
|
974
|
+
CompleteYourProjectWidget.bindAddToCart($completeWidget);
|
|
975
|
+
CompleteYourProjectWidget.bindVatToggle();
|
|
976
|
+
CompleteYourProjectWidget.initQuantityFields($completeWidget);
|
|
1153
977
|
|
|
1154
978
|
$completeWidget
|
|
1155
|
-
.find(
|
|
1156
|
-
.removeClass(
|
|
979
|
+
.find(CompleteYourProjectWidget.el.dropdownRoot)
|
|
980
|
+
.removeClass(CompleteYourProjectWidget.el.dropdownErrorClass);
|
|
1157
981
|
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
982
|
+
CompleteYourProjectWidget.alignCardBlocks($completeWidget);
|
|
983
|
+
CompleteYourProjectWidget.updateCta($completeWidget);
|
|
984
|
+
CompleteYourProjectWidget.setInitialSummary($completeWidget);
|
|
985
|
+
Wick.BloomreachWidget.reapplyVatDisplay();
|
|
1161
986
|
},
|
|
1162
987
|
|
|
1163
988
|
init(payloadData) {
|
|
1164
|
-
const $containers = $(
|
|
989
|
+
const $containers = $(CompleteYourProjectWidget.el.widgetContainer);
|
|
1165
990
|
|
|
1166
991
|
if (!payloadData || !Wick.BloomreachWidget.hasRecommendations(payloadData)) {
|
|
1167
|
-
$containers.find(
|
|
992
|
+
$containers.find(CompleteYourProjectWidget.el.completeWidget).hide();
|
|
1168
993
|
return;
|
|
1169
994
|
}
|
|
1170
995
|
|
|
1171
|
-
|
|
996
|
+
CompleteYourProjectWidget.renderWidgetFromPayload(payloadData);
|
|
1172
997
|
},
|
|
1173
998
|
};
|
|
1174
999
|
|
|
1175
1000
|
$(document).ready(function () {
|
|
1176
1001
|
Wick.Responsive.onResize(function () {
|
|
1177
|
-
$(
|
|
1178
|
-
const $completeWidget = $(this).find(
|
|
1002
|
+
$(CompleteYourProjectWidget.el.widgetContainer).each(function () {
|
|
1003
|
+
const $completeWidget = $(this).find(CompleteYourProjectWidget.el.completeWidget);
|
|
1179
1004
|
|
|
1180
1005
|
if ($completeWidget.length) {
|
|
1181
|
-
|
|
1006
|
+
CompleteYourProjectWidget.alignCardBlocks($completeWidget);
|
|
1182
1007
|
}
|
|
1183
1008
|
});
|
|
1184
1009
|
});
|
|
1185
1010
|
});
|
|
1186
1011
|
|
|
1187
1012
|
window.addEventListener('pagehide', function () {
|
|
1188
|
-
|
|
1013
|
+
CompleteYourProjectWidget.resetBackForwardState();
|
|
1189
1014
|
});
|
|
1015
|
+
|
|
1016
|
+
export default CompleteYourProjectWidget;
|