wickes-css2 2.111.0-why-not-add-refactor-fix.2 → 2.111.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Readme.md +1 -2
- package/build/css/kitchen-plp-main.css +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/bloomreach-widget.min.js +1 -1
- package/build/js/emulation.min.js +8 -334
- package/build/js/page/{bloomreach-widget/complete-your-project-widget.js → bloomreach-widget.js} +359 -205
- package/package.json +1 -1
- package/src/components/.DS_Store +0 -0
- package/src/components/bloomreach/complete-card.hbs +32 -4
- package/src/components/pdp-price-actions.hbs +2 -2
- package/src/components/price-block-v2.hbs +0 -2
- package/src/data/data_kitchen-plp.json +7 -16
- package/src/js/emulation/bloomreach-widget-loading.js +2 -2
- package/src/js/emulation/mock.js +0 -309
- package/src/js/page/.DS_Store +0 -0
- package/src/js/page/{bloomreach-widget/complete-your-project-widget.js → bloomreach-widget.js} +359 -205
- package/src/page_product-details-bloomreach.html +1 -1
- package/src/page_product-details-with-global-search-v2.html +1 -2
- package/src/scss/components/bloomreach/_bloomreach.scss +0 -3
- package/src/scss/components/bloomreach/_complete-card.scss +38 -0
- package/src/scss/components/kitchen/_colour-swatches.scss +9 -3
- package/src/sitemap.html +4 -10
- package/build/js/page/bloomreach-widget/bloomreach-widget.js +0 -241
- package/build/js/page/bloomreach-widget/why-not-add-widget.js +0 -196
- package/src/components/bloomreach/why-not-add-card-skeleton.hbs +0 -14
- package/src/components/bloomreach/why-not-add-card.hbs +0 -73
- package/src/components/bloomreach/why-not-add-content.hbs +0 -41
- package/src/components/bloomreach/why-not-add-skeleton.hbs +0 -9
- package/src/components/bloomreach/why-not-add.hbs +0 -6
- package/src/components/reviews-rating.hbs +0 -22
- package/src/js/emulation/why-not-add-loading.js +0 -11
- package/src/js/emulation/why-not-add.js +0 -28
- package/src/js/page/bloomreach-widget/bloomreach-widget.js +0 -241
- package/src/js/page/bloomreach-widget/why-not-add-widget.js +0 -196
- package/src/page_product-details-with-why-not-add-single.html +0 -131
- package/src/scss/components/bloomreach/_reviews.scss +0 -60
- package/src/scss/components/bloomreach/_why-not-add-card.scss +0 -212
- package/src/scss/components/bloomreach/_why-not-add.scss +0 -143
package/src/js/page/{bloomreach-widget/complete-your-project-widget.js → bloomreach-widget.js}
RENAMED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
var Wick = window.Wick || {};
|
|
2
2
|
|
|
3
|
-
import { createCountStepper } from '
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { createCountStepper } from './utils/create-count-stepper';
|
|
4
|
+
import { createEvent } from './utils/create-event';
|
|
5
|
+
import { createDropdown } from './utils/custom-dropdown';
|
|
6
|
+
import { createLoadingButton } from './utils/create-loading-button';
|
|
7
|
+
import { createToast } from './utils/create-toast';
|
|
7
8
|
|
|
8
9
|
const Handlebars = require('hbsfy/runtime');
|
|
9
10
|
|
|
10
|
-
Handlebars.registerPartial('checkbox', require('
|
|
11
|
-
Handlebars.registerPartial('loader', require('
|
|
12
|
-
Handlebars.registerPartial('button', require('
|
|
11
|
+
Handlebars.registerPartial('checkbox', require('../../elements/checkbox.hbs'));
|
|
12
|
+
Handlebars.registerPartial('loader', require('../../elements/loader.hbs'));
|
|
13
|
+
Handlebars.registerPartial('button', require('../../components/base/button.hbs'));
|
|
13
14
|
Handlebars.registerPartial(
|
|
14
15
|
'bloomreach/complete-card-dropdown',
|
|
15
|
-
require('
|
|
16
|
+
require('../../components/bloomreach/complete-card-dropdown.hbs')
|
|
16
17
|
);
|
|
17
|
-
Handlebars.registerPartial('notifications', require('
|
|
18
|
-
Handlebars.registerPartial('reviews-rating', require('../../../components/reviews-rating.hbs'));
|
|
18
|
+
Handlebars.registerPartial('notifications', require('../../elements/notifications.hbs'));
|
|
19
19
|
|
|
20
|
-
const notificationTemplate = require('
|
|
21
|
-
const completeWrapperTemplate = require('
|
|
22
|
-
const completeDividerTemplate = require('
|
|
23
|
-
const completeCardTemplate = require('
|
|
24
|
-
const completeSummaryTemplate = require('
|
|
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
25
|
|
|
26
|
-
|
|
26
|
+
Wick.BloomreachWidget = {
|
|
27
27
|
CALCULATE_PRODUCT_BUNDLE_TOTAL_EVENT: 'calculateProductBundleTotal',
|
|
28
28
|
ADD_PRODUCT_BUNDLE_TO_CART_EVENT: 'bulkAddToCart',
|
|
29
29
|
|
|
@@ -43,8 +43,14 @@ const CompleteYourProjectWidget = {
|
|
|
43
43
|
countStepperInitializedData: 'count-stepper-initialized',
|
|
44
44
|
countStepperRoot: '.count-stepper',
|
|
45
45
|
ctaButton: '.complete-widget__cta .btn',
|
|
46
|
+
ctaButtonText: '.loading-button__text',
|
|
47
|
+
ctaButtonLoader: '.loading-button__loader',
|
|
46
48
|
summaryPriceValue: '.complete-widget__price-value',
|
|
47
49
|
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',
|
|
48
54
|
|
|
49
55
|
dropdownErrorClass: 'complete-card-dropdown--error',
|
|
50
56
|
dropdownOpenClass: 'complete-card-dropdown--open',
|
|
@@ -62,6 +68,8 @@ const CompleteYourProjectWidget = {
|
|
|
62
68
|
recommendationIndexAttr: 'data-recommendation-index',
|
|
63
69
|
selectedClass: 'complete-card--selected',
|
|
64
70
|
selectedValueData: 'selected-value',
|
|
71
|
+
starOverlay: '.star-overlay',
|
|
72
|
+
|
|
65
73
|
titleEl: '.complete-card__title',
|
|
66
74
|
|
|
67
75
|
widgetContainer: '[data-complete-widget]',
|
|
@@ -86,7 +94,8 @@ const CompleteYourProjectWidget = {
|
|
|
86
94
|
},
|
|
87
95
|
|
|
88
96
|
setCtaText($button, text) {
|
|
89
|
-
const
|
|
97
|
+
const { ctaButtonText } = Wick.BloomreachWidget.el;
|
|
98
|
+
const $text = $button.find(ctaButtonText);
|
|
90
99
|
|
|
91
100
|
if ($text.length) {
|
|
92
101
|
$text.text(text);
|
|
@@ -97,7 +106,61 @@ const CompleteYourProjectWidget = {
|
|
|
97
106
|
},
|
|
98
107
|
|
|
99
108
|
getBadgeColor(color) {
|
|
100
|
-
return
|
|
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
|
+
);
|
|
101
164
|
},
|
|
102
165
|
|
|
103
166
|
getDropdownOptions(product) {
|
|
@@ -136,7 +199,7 @@ const CompleteYourProjectWidget = {
|
|
|
136
199
|
return;
|
|
137
200
|
}
|
|
138
201
|
|
|
139
|
-
|
|
202
|
+
Wick.BloomreachWidget.toast.show({
|
|
140
203
|
type: bulkData.messageType,
|
|
141
204
|
text: bulkData.messageText,
|
|
142
205
|
});
|
|
@@ -149,10 +212,10 @@ const CompleteYourProjectWidget = {
|
|
|
149
212
|
if (promotionAttributes && promotionAttributes.overlayText) {
|
|
150
213
|
return {
|
|
151
214
|
text: promotionAttributes.overlayText,
|
|
152
|
-
textColor:
|
|
215
|
+
textColor: Wick.BloomreachWidget.getBadgeColor(
|
|
153
216
|
promotionAttributes.overlayTextColor
|
|
154
217
|
),
|
|
155
|
-
color:
|
|
218
|
+
color: Wick.BloomreachWidget.getBadgeColor(
|
|
156
219
|
promotionAttributes.overlayBackgroundColor
|
|
157
220
|
),
|
|
158
221
|
};
|
|
@@ -161,6 +224,70 @@ const CompleteYourProjectWidget = {
|
|
|
161
224
|
return product.badge;
|
|
162
225
|
},
|
|
163
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
|
+
|
|
164
291
|
getExcVatFormattedValue(displayPrice, product) {
|
|
165
292
|
const excVat = product ? Wick.BloomreachWidget.getDisplayPriceExcVat(product) : null;
|
|
166
293
|
if (excVat && excVat.formattedValue) {
|
|
@@ -176,10 +303,10 @@ const CompleteYourProjectWidget = {
|
|
|
176
303
|
getProductRenderData(product, index, options = {}) {
|
|
177
304
|
const shouldShowDropdown = index !== 0;
|
|
178
305
|
const dropdownOptions = shouldShowDropdown
|
|
179
|
-
?
|
|
306
|
+
? Wick.BloomreachWidget.getDropdownOptions(product)
|
|
180
307
|
: [];
|
|
181
308
|
const selectedDropdownValue = options.selectedDropdownValue || '';
|
|
182
|
-
const selectedDropdownLabel =
|
|
309
|
+
const selectedDropdownLabel = Wick.BloomreachWidget.getSelectedDropdownLabel(
|
|
183
310
|
dropdownOptions,
|
|
184
311
|
selectedDropdownValue
|
|
185
312
|
);
|
|
@@ -192,17 +319,19 @@ const CompleteYourProjectWidget = {
|
|
|
192
319
|
);
|
|
193
320
|
|
|
194
321
|
const wasPriceFormatted = Wick.BloomreachWidget.getWasPriceFormatted(product);
|
|
195
|
-
const excVatFormattedValue =
|
|
322
|
+
const excVatFormattedValue = Wick.BloomreachWidget.getExcVatFormattedValue(
|
|
196
323
|
displayPrice,
|
|
197
324
|
product
|
|
198
325
|
);
|
|
199
326
|
const isSwitchVat = !!(window.ACC && window.ACC.app && window.ACC.app.isVatToggleAvailable);
|
|
200
327
|
|
|
201
|
-
const excVatWasPriceFormatted =
|
|
328
|
+
const excVatWasPriceFormatted = wasPriceFormatted
|
|
329
|
+
? Wick.BloomreachWidget.getExcVatWasPrice(product)
|
|
330
|
+
: '';
|
|
202
331
|
|
|
203
332
|
return {
|
|
204
333
|
...product,
|
|
205
|
-
badge:
|
|
334
|
+
badge: Wick.BloomreachWidget.getBadge(product),
|
|
206
335
|
price: displayPrice,
|
|
207
336
|
wasPriceFormatted,
|
|
208
337
|
'switch-vat': isSwitchVat,
|
|
@@ -213,11 +342,7 @@ const CompleteYourProjectWidget = {
|
|
|
213
342
|
Wick.BloomreachWidget.getDisplayPriceExcVat(product)
|
|
214
343
|
),
|
|
215
344
|
incVatWasPriceFormatted: wasPriceFormatted,
|
|
216
|
-
wasPriceIncVatFormattedValue: wasPriceFormatted,
|
|
217
|
-
incVatWasPriceFormattedValue: wasPriceFormatted,
|
|
218
345
|
excVatWasPriceFormatted,
|
|
219
|
-
wasPriceExcVatFormattedValue: excVatWasPriceFormatted,
|
|
220
|
-
excVatWasPriceFormattedValue: excVatWasPriceFormatted,
|
|
221
346
|
showFromPrice,
|
|
222
347
|
image:
|
|
223
348
|
options.image ||
|
|
@@ -238,7 +363,7 @@ const CompleteYourProjectWidget = {
|
|
|
238
363
|
|
|
239
364
|
renderWidget($container, context) {
|
|
240
365
|
const { widgetContent, widgetWrapper, completeCard, recommendationIndexAttr } =
|
|
241
|
-
|
|
366
|
+
Wick.BloomreachWidget.el;
|
|
242
367
|
|
|
243
368
|
const $content = $container.find(widgetContent);
|
|
244
369
|
const recommendations = Wick.BloomreachWidget.normalizePayload(context);
|
|
@@ -247,16 +372,16 @@ const CompleteYourProjectWidget = {
|
|
|
247
372
|
return;
|
|
248
373
|
}
|
|
249
374
|
|
|
250
|
-
|
|
375
|
+
Wick.BloomreachWidget.recommendations = recommendations;
|
|
251
376
|
|
|
252
377
|
$content.html(completeWrapperTemplate());
|
|
253
378
|
|
|
254
379
|
const $wrapper = $content.find(widgetWrapper);
|
|
255
380
|
|
|
256
|
-
|
|
381
|
+
Wick.BloomreachWidget.dropdownCurrent = {};
|
|
257
382
|
|
|
258
383
|
recommendations.forEach(function (recommendation, index) {
|
|
259
|
-
const product =
|
|
384
|
+
const product = Wick.BloomreachWidget.getProductRenderData(
|
|
260
385
|
recommendation.baseProduct,
|
|
261
386
|
index
|
|
262
387
|
);
|
|
@@ -277,7 +402,7 @@ const CompleteYourProjectWidget = {
|
|
|
277
402
|
},
|
|
278
403
|
|
|
279
404
|
renderWidgetFromPayload(payloadData) {
|
|
280
|
-
const { widgetContainer, completeWidget } =
|
|
405
|
+
const { widgetContainer, completeWidget } = Wick.BloomreachWidget.el;
|
|
281
406
|
const $containers = $(widgetContainer);
|
|
282
407
|
|
|
283
408
|
if (!$containers.length) {
|
|
@@ -292,23 +417,46 @@ const CompleteYourProjectWidget = {
|
|
|
292
417
|
$containers.each(function () {
|
|
293
418
|
const $container = $(this);
|
|
294
419
|
|
|
295
|
-
|
|
296
|
-
|
|
420
|
+
Wick.BloomreachWidget.renderWidget($container, payloadData);
|
|
421
|
+
Wick.BloomreachWidget.initRenderedWidget($container);
|
|
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
|
+
});
|
|
297
445
|
});
|
|
298
446
|
},
|
|
299
447
|
|
|
300
448
|
getDropdownCard($dropdown) {
|
|
301
|
-
return $dropdown.closest(
|
|
449
|
+
return $dropdown.closest(Wick.BloomreachWidget.el.completeCard);
|
|
302
450
|
},
|
|
303
451
|
|
|
304
452
|
getDropdownCheckbox($dropdown) {
|
|
305
|
-
return
|
|
306
|
-
|
|
453
|
+
return Wick.BloomreachWidget.getDropdownCard($dropdown).find(
|
|
454
|
+
Wick.BloomreachWidget.el.cardCheckbox
|
|
307
455
|
);
|
|
308
456
|
},
|
|
309
457
|
|
|
310
458
|
setDropdownCheckboxState($dropdown, isChecked, shouldTriggerChange = true) {
|
|
311
|
-
const $checkbox =
|
|
459
|
+
const $checkbox = Wick.BloomreachWidget.getDropdownCheckbox($dropdown);
|
|
312
460
|
|
|
313
461
|
if (!$checkbox.length) {
|
|
314
462
|
return;
|
|
@@ -322,18 +470,18 @@ const CompleteYourProjectWidget = {
|
|
|
322
470
|
},
|
|
323
471
|
|
|
324
472
|
setDropdownError($dropdown, hasError) {
|
|
325
|
-
$dropdown.toggleClass(
|
|
473
|
+
$dropdown.toggleClass(Wick.BloomreachWidget.el.dropdownErrorClass, hasError);
|
|
326
474
|
},
|
|
327
475
|
|
|
328
476
|
validateDropdown($dropdown, options = {}) {
|
|
329
|
-
const isValid = Boolean($dropdown.data(
|
|
477
|
+
const isValid = Boolean($dropdown.data(Wick.BloomreachWidget.el.selectedValueData));
|
|
330
478
|
|
|
331
|
-
|
|
479
|
+
Wick.BloomreachWidget.setDropdownError($dropdown, !isValid);
|
|
332
480
|
|
|
333
481
|
if (!isValid && options.uncheck) {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
482
|
+
Wick.BloomreachWidget.setDropdownCheckboxState($dropdown, false, false);
|
|
483
|
+
Wick.BloomreachWidget.getDropdownCard($dropdown).removeClass(
|
|
484
|
+
Wick.BloomreachWidget.el.selectedClass
|
|
337
485
|
);
|
|
338
486
|
}
|
|
339
487
|
|
|
@@ -341,13 +489,13 @@ const CompleteYourProjectWidget = {
|
|
|
341
489
|
},
|
|
342
490
|
|
|
343
491
|
validateCardDropdown($card, options = {}) {
|
|
344
|
-
const $dropdown = $card.find(
|
|
492
|
+
const $dropdown = $card.find(Wick.BloomreachWidget.el.dropdownRoot);
|
|
345
493
|
|
|
346
494
|
if (!$dropdown.length) {
|
|
347
495
|
return true;
|
|
348
496
|
}
|
|
349
497
|
|
|
350
|
-
return
|
|
498
|
+
return Wick.BloomreachWidget.validateDropdown($dropdown, options);
|
|
351
499
|
},
|
|
352
500
|
|
|
353
501
|
findVariantProduct(recommendation, selectedValue) {
|
|
@@ -361,7 +509,7 @@ const CompleteYourProjectWidget = {
|
|
|
361
509
|
},
|
|
362
510
|
|
|
363
511
|
getCardQuantity($card) {
|
|
364
|
-
const $input = $card.find(
|
|
512
|
+
const $input = $card.find(Wick.BloomreachWidget.el.quantityInput);
|
|
365
513
|
const quantity = parseInt($input.val(), 10);
|
|
366
514
|
|
|
367
515
|
return Number.isNaN(quantity) ? 1 : quantity;
|
|
@@ -369,10 +517,10 @@ const CompleteYourProjectWidget = {
|
|
|
369
517
|
|
|
370
518
|
getCardProduct($card) {
|
|
371
519
|
const { recommendationIndexAttr, dropdownRoot, selectedValueData } =
|
|
372
|
-
|
|
520
|
+
Wick.BloomreachWidget.el;
|
|
373
521
|
|
|
374
522
|
const recommendationIndex = Number($card.attr(recommendationIndexAttr));
|
|
375
|
-
const recommendation =
|
|
523
|
+
const recommendation = Wick.BloomreachWidget.recommendations[recommendationIndex];
|
|
376
524
|
|
|
377
525
|
if (!recommendation) {
|
|
378
526
|
return null;
|
|
@@ -383,7 +531,7 @@ const CompleteYourProjectWidget = {
|
|
|
383
531
|
|
|
384
532
|
if (selectedValue) {
|
|
385
533
|
return (
|
|
386
|
-
|
|
534
|
+
Wick.BloomreachWidget.findVariantProduct(recommendation, selectedValue) ||
|
|
387
535
|
recommendation.baseProduct
|
|
388
536
|
);
|
|
389
537
|
}
|
|
@@ -392,7 +540,7 @@ const CompleteYourProjectWidget = {
|
|
|
392
540
|
},
|
|
393
541
|
|
|
394
542
|
getSelectedEntries($root) {
|
|
395
|
-
const { completeCard, cardCheckbox } =
|
|
543
|
+
const { completeCard, cardCheckbox } = Wick.BloomreachWidget.el;
|
|
396
544
|
const entries = [];
|
|
397
545
|
|
|
398
546
|
$root.find(completeCard).each(function () {
|
|
@@ -403,7 +551,7 @@ const CompleteYourProjectWidget = {
|
|
|
403
551
|
return;
|
|
404
552
|
}
|
|
405
553
|
|
|
406
|
-
const product =
|
|
554
|
+
const product = Wick.BloomreachWidget.getCardProduct($card);
|
|
407
555
|
|
|
408
556
|
if (!product) {
|
|
409
557
|
return;
|
|
@@ -411,7 +559,7 @@ const CompleteYourProjectWidget = {
|
|
|
411
559
|
|
|
412
560
|
entries.push({
|
|
413
561
|
product,
|
|
414
|
-
quantity:
|
|
562
|
+
quantity: Wick.BloomreachWidget.getCardQuantity($card),
|
|
415
563
|
});
|
|
416
564
|
});
|
|
417
565
|
|
|
@@ -419,7 +567,7 @@ const CompleteYourProjectWidget = {
|
|
|
419
567
|
},
|
|
420
568
|
|
|
421
569
|
getAddToCartEntries($root) {
|
|
422
|
-
return
|
|
570
|
+
return Wick.BloomreachWidget.getSelectedEntries($root).map(function (entry) {
|
|
423
571
|
return {
|
|
424
572
|
productCode: entry.product.code,
|
|
425
573
|
quantity: entry.quantity,
|
|
@@ -433,10 +581,16 @@ const CompleteYourProjectWidget = {
|
|
|
433
581
|
const totalWasPriceExclusiveVat =
|
|
434
582
|
response.totalWasPriceExclusiveVat || response.totalExcVatWasPrice;
|
|
435
583
|
|
|
436
|
-
const {
|
|
437
|
-
|
|
584
|
+
const {
|
|
585
|
+
summaryPriceValue,
|
|
586
|
+
summarySalePrice,
|
|
587
|
+
summaryPriceInc,
|
|
588
|
+
summaryPriceExc,
|
|
589
|
+
summarySalePriceInc,
|
|
590
|
+
summarySalePriceExc,
|
|
591
|
+
} = Wick.BloomreachWidget.el;
|
|
438
592
|
|
|
439
|
-
|
|
593
|
+
Wick.BloomreachWidget.lastCalculationResponse = response;
|
|
440
594
|
|
|
441
595
|
const $price = $root.find(summaryPriceValue);
|
|
442
596
|
const $salePrice = $root.find(summarySalePrice);
|
|
@@ -448,43 +602,46 @@ const CompleteYourProjectWidget = {
|
|
|
448
602
|
|
|
449
603
|
if (response.totalWasPrice) {
|
|
450
604
|
$total.addClass('complete-widget__total-sale');
|
|
451
|
-
const $priceInc = $price.find(
|
|
605
|
+
const $priceInc = $price.find(summaryPriceInc);
|
|
452
606
|
|
|
453
607
|
if ($priceInc.length) {
|
|
454
608
|
$priceInc.text(response.totalWasPrice);
|
|
455
|
-
$price
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
609
|
+
$price
|
|
610
|
+
.find(summaryPriceExc)
|
|
611
|
+
.text(totalWasPriceExclusiveVat || response.totalWasPrice);
|
|
612
|
+
|
|
613
|
+
$salePrice.find(summarySalePriceInc).text(response.totalPrice || '');
|
|
614
|
+
$salePrice
|
|
615
|
+
.find(summarySalePriceExc)
|
|
616
|
+
.text(totalPriceExclusiveVat || response.totalPrice || '');
|
|
459
617
|
} else {
|
|
460
618
|
$price.text(response.totalWasPrice);
|
|
461
619
|
$salePrice.text(response.totalPrice || '');
|
|
462
620
|
}
|
|
463
621
|
|
|
464
622
|
$salePrice.show();
|
|
465
|
-
Wick.BloomreachWidget.reapplyVatDisplay();
|
|
466
623
|
return;
|
|
467
624
|
}
|
|
468
625
|
|
|
469
626
|
$total.removeClass('complete-widget__total-sale');
|
|
470
|
-
const $priceInc = $price.find(
|
|
627
|
+
const $priceInc = $price.find(summaryPriceInc);
|
|
471
628
|
if ($priceInc.length) {
|
|
472
629
|
$priceInc.text(response.totalPrice || '£0.00');
|
|
473
|
-
$price
|
|
630
|
+
$price
|
|
631
|
+
.find(summaryPriceExc)
|
|
632
|
+
.text(totalPriceExclusiveVat || response.totalPrice || '£0.00');
|
|
474
633
|
|
|
475
|
-
$salePrice.find(
|
|
476
|
-
$salePrice.find(
|
|
634
|
+
$salePrice.find(summarySalePriceInc).text('');
|
|
635
|
+
$salePrice.find(summarySalePriceExc).text('');
|
|
477
636
|
$salePrice.hide();
|
|
478
637
|
} else {
|
|
479
638
|
$price.text(response.totalPrice || '£0.00');
|
|
480
639
|
$salePrice.text('').hide();
|
|
481
640
|
}
|
|
482
|
-
|
|
483
|
-
Wick.BloomreachWidget.reapplyVatDisplay();
|
|
484
641
|
},
|
|
485
642
|
|
|
486
643
|
updateCta($root) {
|
|
487
|
-
const { ctaButton, cardCheckbox } =
|
|
644
|
+
const { ctaButton, cardCheckbox } = Wick.BloomreachWidget.el;
|
|
488
645
|
const selectedCount = $root.find(cardCheckbox).filter(':checked').length;
|
|
489
646
|
const $cta = $root.find(ctaButton);
|
|
490
647
|
|
|
@@ -493,43 +650,44 @@ const CompleteYourProjectWidget = {
|
|
|
493
650
|
}
|
|
494
651
|
|
|
495
652
|
$cta.prop('disabled', !selectedCount);
|
|
496
|
-
|
|
497
|
-
$cta,
|
|
498
|
-
CompleteYourProjectWidget.getCtaText(selectedCount)
|
|
499
|
-
);
|
|
653
|
+
Wick.BloomreachWidget.setCtaText($cta, Wick.BloomreachWidget.getCtaText(selectedCount));
|
|
500
654
|
},
|
|
501
655
|
|
|
502
656
|
dispatchCalculateTotal($root) {
|
|
503
|
-
|
|
657
|
+
Wick.BloomreachWidget.updateCta($root);
|
|
504
658
|
|
|
505
659
|
return Wick.BloomreachWidget.dispatchWidgetEvent(
|
|
506
|
-
|
|
660
|
+
Wick.BloomreachWidget.CALCULATE_PRODUCT_BUNDLE_TOTAL_EVENT,
|
|
507
661
|
{
|
|
508
|
-
entries:
|
|
662
|
+
entries: Wick.BloomreachWidget.getSelectedEntries($root),
|
|
509
663
|
}
|
|
510
664
|
).then(function (response) {
|
|
511
|
-
|
|
665
|
+
Wick.BloomreachWidget.updateSummary($root, response);
|
|
512
666
|
});
|
|
513
667
|
},
|
|
514
668
|
|
|
515
669
|
dispatchAddToCart($root, $button) {
|
|
516
|
-
|
|
670
|
+
Wick.BloomreachWidget.loadingButton.start($button);
|
|
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
|
+
);
|
|
517
681
|
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
{
|
|
521
|
-
entries: CompleteYourProjectWidget.getAddToCartEntries($root),
|
|
522
|
-
}
|
|
523
|
-
)
|
|
682
|
+
window.dispatchEvent(event);
|
|
683
|
+
})
|
|
524
684
|
.then(function (response) {
|
|
525
|
-
|
|
685
|
+
Wick.BloomreachWidget.handleBulkAddToCartResponse(response);
|
|
526
686
|
|
|
527
|
-
|
|
528
|
-
Wick.MiniBasketSliderFE.isMiniBasketLoaded = false;
|
|
529
|
-
}
|
|
687
|
+
Wick.MiniBasketSliderFE.isMiniBasketLoaded = false;
|
|
530
688
|
})
|
|
531
689
|
.catch(function () {
|
|
532
|
-
|
|
690
|
+
Wick.BloomreachWidget.handleBulkAddToCartResponse({
|
|
533
691
|
bulkAddToCartData: {
|
|
534
692
|
messageType: 'error',
|
|
535
693
|
messageText: 'Selected product(s) were not added to basket',
|
|
@@ -537,20 +695,19 @@ const CompleteYourProjectWidget = {
|
|
|
537
695
|
});
|
|
538
696
|
})
|
|
539
697
|
.finally(function () {
|
|
540
|
-
|
|
541
|
-
|
|
698
|
+
Wick.BloomreachWidget.loadingButton.stop($button);
|
|
699
|
+
Wick.BloomreachWidget.updateCta($root);
|
|
542
700
|
});
|
|
543
701
|
},
|
|
544
702
|
|
|
545
703
|
reinitCard($card) {
|
|
546
|
-
const { countBtn, completeWidget } =
|
|
704
|
+
const { countBtn, completeWidget } = Wick.BloomreachWidget.el;
|
|
547
705
|
|
|
548
706
|
$card.find(countBtn).remove();
|
|
549
707
|
|
|
550
|
-
|
|
708
|
+
Wick.BloomreachWidget.initQuantityFields($card);
|
|
551
709
|
Wick.BloomreachWidget.drawRating($card);
|
|
552
|
-
|
|
553
|
-
Wick.BloomreachWidget.reapplyVatDisplay();
|
|
710
|
+
Wick.BloomreachWidget.alignCardBlocks($card.closest(completeWidget));
|
|
554
711
|
},
|
|
555
712
|
|
|
556
713
|
replaceCardWithBaseProduct($dropdown, options = {}) {
|
|
@@ -560,17 +717,17 @@ const CompleteYourProjectWidget = {
|
|
|
560
717
|
dropdownRoot,
|
|
561
718
|
dropdownErrorClass,
|
|
562
719
|
cardCheckbox,
|
|
563
|
-
} =
|
|
720
|
+
} = Wick.BloomreachWidget.el;
|
|
564
721
|
|
|
565
722
|
const $card = $dropdown.closest(completeCard);
|
|
566
723
|
const recommendationIndex = Number($card.attr(recommendationIndexAttr));
|
|
567
|
-
const recommendation =
|
|
724
|
+
const recommendation = Wick.BloomreachWidget.recommendations[recommendationIndex];
|
|
568
725
|
|
|
569
726
|
if (!recommendation || !recommendation.baseProduct) {
|
|
570
727
|
return null;
|
|
571
728
|
}
|
|
572
729
|
|
|
573
|
-
const productData =
|
|
730
|
+
const productData = Wick.BloomreachWidget.getProductRenderData(
|
|
574
731
|
recommendation.baseProduct,
|
|
575
732
|
recommendationIndex,
|
|
576
733
|
{
|
|
@@ -593,13 +750,13 @@ const CompleteYourProjectWidget = {
|
|
|
593
750
|
$newCard.find(cardCheckbox).prop('checked', false);
|
|
594
751
|
|
|
595
752
|
$newCard
|
|
596
|
-
.find(
|
|
753
|
+
.find(Wick.BloomreachWidget.el.quantityInput)
|
|
597
754
|
.val(1)
|
|
598
|
-
.data(
|
|
599
|
-
.removeData(
|
|
600
|
-
.removeData(
|
|
755
|
+
.data(Wick.BloomreachWidget.el.previousQuantityData, 1)
|
|
756
|
+
.removeData(Wick.BloomreachWidget.el.quantityReadyData)
|
|
757
|
+
.removeData(Wick.BloomreachWidget.el.countStepperInitializedData);
|
|
601
758
|
|
|
602
|
-
|
|
759
|
+
Wick.BloomreachWidget.reinitCard($newCard);
|
|
603
760
|
|
|
604
761
|
return $newCard;
|
|
605
762
|
},
|
|
@@ -612,17 +769,17 @@ const CompleteYourProjectWidget = {
|
|
|
612
769
|
dropdownRoot,
|
|
613
770
|
selectedValueData,
|
|
614
771
|
cardCheckbox,
|
|
615
|
-
} =
|
|
772
|
+
} = Wick.BloomreachWidget.el;
|
|
616
773
|
|
|
617
774
|
const $card = $dropdown.closest(completeCard);
|
|
618
775
|
const recommendationIndex = Number($card.attr(recommendationIndexAttr));
|
|
619
|
-
const recommendation =
|
|
776
|
+
const recommendation = Wick.BloomreachWidget.recommendations[recommendationIndex];
|
|
620
777
|
|
|
621
778
|
if (!recommendation) {
|
|
622
779
|
return null;
|
|
623
780
|
}
|
|
624
781
|
|
|
625
|
-
const variantProduct =
|
|
782
|
+
const variantProduct = Wick.BloomreachWidget.findVariantProduct(
|
|
626
783
|
recommendation,
|
|
627
784
|
selectedValue
|
|
628
785
|
);
|
|
@@ -631,7 +788,7 @@ const CompleteYourProjectWidget = {
|
|
|
631
788
|
return null;
|
|
632
789
|
}
|
|
633
790
|
|
|
634
|
-
const productData =
|
|
791
|
+
const productData = Wick.BloomreachWidget.getProductRenderData(
|
|
635
792
|
{
|
|
636
793
|
...variantProduct,
|
|
637
794
|
variantOptions: recommendation.baseProduct.variantOptions,
|
|
@@ -661,53 +818,51 @@ const CompleteYourProjectWidget = {
|
|
|
661
818
|
$newCard.find(cardCheckbox).prop('checked', true);
|
|
662
819
|
|
|
663
820
|
$newCard
|
|
664
|
-
.find(
|
|
821
|
+
.find(Wick.BloomreachWidget.el.quantityInput)
|
|
665
822
|
.val(1)
|
|
666
|
-
.data(
|
|
667
|
-
.removeData(
|
|
668
|
-
.removeData(
|
|
823
|
+
.data(Wick.BloomreachWidget.el.previousQuantityData, 1)
|
|
824
|
+
.removeData(Wick.BloomreachWidget.el.quantityReadyData)
|
|
825
|
+
.removeData(Wick.BloomreachWidget.el.countStepperInitializedData);
|
|
669
826
|
|
|
670
|
-
|
|
827
|
+
Wick.BloomreachWidget.reinitCard($newCard);
|
|
671
828
|
|
|
672
829
|
return $newCard;
|
|
673
830
|
},
|
|
674
831
|
|
|
675
832
|
handleDropdownSelect($dropdown, selectedValue) {
|
|
676
|
-
const $card = $dropdown.closest(
|
|
677
|
-
const recommendationIndex = $card.attr(
|
|
678
|
-
|
|
679
|
-
);
|
|
680
|
-
const currentValue = CompleteYourProjectWidget.dropdownCurrent[recommendationIndex];
|
|
833
|
+
const $card = $dropdown.closest(Wick.BloomreachWidget.el.completeCard);
|
|
834
|
+
const recommendationIndex = $card.attr(Wick.BloomreachWidget.el.recommendationIndexAttr);
|
|
835
|
+
const currentValue = Wick.BloomreachWidget.dropdownCurrent[recommendationIndex];
|
|
681
836
|
|
|
682
837
|
if (`${currentValue}` === `${selectedValue}`) {
|
|
683
838
|
return;
|
|
684
839
|
}
|
|
685
840
|
|
|
686
|
-
|
|
841
|
+
Wick.BloomreachWidget.dropdownCurrent[recommendationIndex] = selectedValue;
|
|
687
842
|
|
|
688
|
-
const $completeWidget = $dropdown.closest(
|
|
843
|
+
const $completeWidget = $dropdown.closest(Wick.BloomreachWidget.el.completeWidget);
|
|
689
844
|
const isPlaceholder = !selectedValue;
|
|
690
845
|
|
|
691
846
|
if (isPlaceholder) {
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
847
|
+
Wick.BloomreachWidget.setDropdownError($dropdown, true);
|
|
848
|
+
Wick.BloomreachWidget.setDropdownCheckboxState($dropdown, false, false);
|
|
849
|
+
Wick.BloomreachWidget.replaceCardWithBaseProduct($dropdown, {
|
|
695
850
|
dropdownError: true,
|
|
696
851
|
});
|
|
697
852
|
|
|
698
853
|
if ($completeWidget.length) {
|
|
699
|
-
|
|
854
|
+
Wick.BloomreachWidget.dispatchCalculateTotal($completeWidget);
|
|
700
855
|
}
|
|
701
856
|
|
|
702
857
|
return;
|
|
703
858
|
}
|
|
704
859
|
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
860
|
+
Wick.BloomreachWidget.setDropdownError($dropdown, false);
|
|
861
|
+
Wick.BloomreachWidget.setDropdownCheckboxState($dropdown, true, false);
|
|
862
|
+
Wick.BloomreachWidget.replaceCardWithVariant($dropdown, selectedValue);
|
|
708
863
|
|
|
709
864
|
if ($completeWidget.length) {
|
|
710
|
-
|
|
865
|
+
Wick.BloomreachWidget.dispatchCalculateTotal($completeWidget);
|
|
711
866
|
}
|
|
712
867
|
},
|
|
713
868
|
|
|
@@ -719,9 +874,9 @@ const CompleteYourProjectWidget = {
|
|
|
719
874
|
dropdownOption,
|
|
720
875
|
dropdownOpenClass,
|
|
721
876
|
dropdownOptionSelectedClass,
|
|
722
|
-
} =
|
|
877
|
+
} = Wick.BloomreachWidget.el;
|
|
723
878
|
|
|
724
|
-
|
|
879
|
+
Wick.BloomreachWidget.dropdown = createDropdown({
|
|
725
880
|
root: dropdownRoot,
|
|
726
881
|
toggle: dropdownToggle,
|
|
727
882
|
value: dropdownValue,
|
|
@@ -730,15 +885,15 @@ const CompleteYourProjectWidget = {
|
|
|
730
885
|
selectedClass: dropdownOptionSelectedClass,
|
|
731
886
|
namespace: 'bloomreachDropdown',
|
|
732
887
|
onSelect($dropdown, $option, selectedValue) {
|
|
733
|
-
|
|
888
|
+
Wick.BloomreachWidget.handleDropdownSelect($dropdown, selectedValue);
|
|
734
889
|
},
|
|
735
890
|
});
|
|
736
891
|
|
|
737
|
-
|
|
892
|
+
Wick.BloomreachWidget.dropdown.bind();
|
|
738
893
|
},
|
|
739
894
|
|
|
740
895
|
bindCardSelection($root) {
|
|
741
|
-
const { completeCard, cardCheckbox, selectedClass } =
|
|
896
|
+
const { completeCard, cardCheckbox, selectedClass } = Wick.BloomreachWidget.el;
|
|
742
897
|
|
|
743
898
|
const $firstCard = $root.find(completeCard).first();
|
|
744
899
|
|
|
@@ -749,11 +904,11 @@ const CompleteYourProjectWidget = {
|
|
|
749
904
|
$root.on('change.bloomreachCardSelection', cardCheckbox, function () {
|
|
750
905
|
const $checkbox = $(this);
|
|
751
906
|
const $card = $checkbox.closest(completeCard);
|
|
752
|
-
const $dropdown = $card.find(
|
|
907
|
+
const $dropdown = $card.find(Wick.BloomreachWidget.el.dropdownRoot);
|
|
753
908
|
|
|
754
909
|
if (
|
|
755
910
|
!$checkbox.prop('checked') &&
|
|
756
|
-
$dropdown.hasClass(
|
|
911
|
+
$dropdown.hasClass(Wick.BloomreachWidget.el.dropdownErrorClass)
|
|
757
912
|
) {
|
|
758
913
|
$card.removeClass(selectedClass);
|
|
759
914
|
return;
|
|
@@ -761,7 +916,7 @@ const CompleteYourProjectWidget = {
|
|
|
761
916
|
|
|
762
917
|
if (
|
|
763
918
|
$checkbox.prop('checked') &&
|
|
764
|
-
!
|
|
919
|
+
!Wick.BloomreachWidget.validateCardDropdown($card, {
|
|
765
920
|
uncheck: true,
|
|
766
921
|
})
|
|
767
922
|
) {
|
|
@@ -772,12 +927,12 @@ const CompleteYourProjectWidget = {
|
|
|
772
927
|
|
|
773
928
|
$card.toggleClass(selectedClass, this.checked);
|
|
774
929
|
|
|
775
|
-
|
|
930
|
+
Wick.BloomreachWidget.dispatchCalculateTotal($root);
|
|
776
931
|
});
|
|
777
932
|
},
|
|
778
933
|
|
|
779
934
|
bindDropdownValidation($root) {
|
|
780
|
-
const { cardCheckbox, completeCard } =
|
|
935
|
+
const { cardCheckbox, completeCard } = Wick.BloomreachWidget.el;
|
|
781
936
|
|
|
782
937
|
$root.off('click.bloomreachDropdownValidation', cardCheckbox);
|
|
783
938
|
$root.on('click.bloomreachDropdownValidation', cardCheckbox, function () {
|
|
@@ -786,24 +941,18 @@ const CompleteYourProjectWidget = {
|
|
|
786
941
|
|
|
787
942
|
if (
|
|
788
943
|
$checkbox.prop('checked') &&
|
|
789
|
-
!
|
|
944
|
+
!Wick.BloomreachWidget.validateCardDropdown($card, {
|
|
790
945
|
uncheck: true,
|
|
791
946
|
})
|
|
792
947
|
) {
|
|
793
948
|
$checkbox.prop('checked', false);
|
|
794
|
-
$card.removeClass(
|
|
949
|
+
$card.removeClass(Wick.BloomreachWidget.el.selectedClass);
|
|
795
950
|
}
|
|
796
951
|
});
|
|
797
952
|
},
|
|
798
953
|
|
|
799
|
-
bindVatToggle() {
|
|
800
|
-
if (Wick.BloomreachWidget.bindVatToggle) {
|
|
801
|
-
Wick.BloomreachWidget.bindVatToggle('completeYourProjectVatToggle');
|
|
802
|
-
}
|
|
803
|
-
},
|
|
804
|
-
|
|
805
954
|
bindAddToCart($root) {
|
|
806
|
-
const { ctaButton } =
|
|
955
|
+
const { ctaButton } = Wick.BloomreachWidget.el;
|
|
807
956
|
|
|
808
957
|
$root.off('click.bloomreachAddToCart', ctaButton);
|
|
809
958
|
$root.on('click.bloomreachAddToCart', ctaButton, function (event) {
|
|
@@ -813,12 +962,12 @@ const CompleteYourProjectWidget = {
|
|
|
813
962
|
|
|
814
963
|
if (
|
|
815
964
|
$button.prop('disabled') ||
|
|
816
|
-
|
|
965
|
+
Wick.BloomreachWidget.loadingButton.isLoading($button)
|
|
817
966
|
) {
|
|
818
967
|
return;
|
|
819
968
|
}
|
|
820
969
|
|
|
821
|
-
|
|
970
|
+
Wick.BloomreachWidget.dispatchAddToCart($root, $button);
|
|
822
971
|
});
|
|
823
972
|
},
|
|
824
973
|
|
|
@@ -843,14 +992,14 @@ const CompleteYourProjectWidget = {
|
|
|
843
992
|
},
|
|
844
993
|
|
|
845
994
|
alignCardBlocks($root) {
|
|
846
|
-
const { titleEl, optionsEl } =
|
|
995
|
+
const { titleEl, optionsEl } = Wick.BloomreachWidget.el;
|
|
847
996
|
|
|
848
|
-
|
|
849
|
-
|
|
997
|
+
Wick.BloomreachWidget.alignBlock(titleEl, $root);
|
|
998
|
+
Wick.BloomreachWidget.alignBlock(optionsEl, $root);
|
|
850
999
|
},
|
|
851
1000
|
|
|
852
1001
|
setInitialSummary($root) {
|
|
853
|
-
const entries =
|
|
1002
|
+
const entries = Wick.BloomreachWidget.getSelectedEntries($root);
|
|
854
1003
|
const firstEntry = entries[0];
|
|
855
1004
|
|
|
856
1005
|
if (!firstEntry || !firstEntry.product) {
|
|
@@ -862,7 +1011,7 @@ const CompleteYourProjectWidget = {
|
|
|
862
1011
|
const priceExcVat = Wick.BloomreachWidget.getDisplayPriceExcVat(product);
|
|
863
1012
|
const wasPriceFormatted = Wick.BloomreachWidget.getWasPriceFormatted(product);
|
|
864
1013
|
|
|
865
|
-
|
|
1014
|
+
Wick.BloomreachWidget.updateSummary($root, {
|
|
866
1015
|
totalPrice: Wick.BloomreachWidget.getPriceFormattedValue(displayPrice) || '£0.00',
|
|
867
1016
|
totalWasPrice: wasPriceFormatted || null,
|
|
868
1017
|
totalPriceExclusiveVat: Wick.BloomreachWidget.getPriceFormattedValue(priceExcVat),
|
|
@@ -876,18 +1025,18 @@ const CompleteYourProjectWidget = {
|
|
|
876
1025
|
min: 1,
|
|
877
1026
|
onChange(qty, inputEl) {
|
|
878
1027
|
const $input = $(inputEl);
|
|
879
|
-
const $card = $input.closest(
|
|
880
|
-
const $completeWidget = $input.closest(
|
|
881
|
-
const $checkbox = $card.find(
|
|
1028
|
+
const $card = $input.closest(Wick.BloomreachWidget.el.completeCard);
|
|
1029
|
+
const $completeWidget = $input.closest(Wick.BloomreachWidget.el.completeWidget);
|
|
1030
|
+
const $checkbox = $card.find(Wick.BloomreachWidget.el.cardCheckbox);
|
|
882
1031
|
const previousQuantity =
|
|
883
|
-
$input.data(
|
|
1032
|
+
$input.data(Wick.BloomreachWidget.el.previousQuantityData) || 1;
|
|
884
1033
|
|
|
885
|
-
if (!$input.data(
|
|
886
|
-
$input.data(
|
|
1034
|
+
if (!$input.data(Wick.BloomreachWidget.el.quantityReadyData)) {
|
|
1035
|
+
$input.data(Wick.BloomreachWidget.el.previousQuantityData, qty || 1);
|
|
887
1036
|
return;
|
|
888
1037
|
}
|
|
889
1038
|
|
|
890
|
-
if (!
|
|
1039
|
+
if (!Wick.BloomreachWidget.validateCardDropdown($card)) {
|
|
891
1040
|
$input.val(previousQuantity);
|
|
892
1041
|
|
|
893
1042
|
const $minus = $card.find('.count-btn--minus');
|
|
@@ -900,22 +1049,22 @@ const CompleteYourProjectWidget = {
|
|
|
900
1049
|
}
|
|
901
1050
|
|
|
902
1051
|
$checkbox.prop('checked', true);
|
|
903
|
-
$card.addClass(
|
|
1052
|
+
$card.addClass(Wick.BloomreachWidget.el.selectedClass);
|
|
904
1053
|
|
|
905
|
-
$input.data(
|
|
1054
|
+
$input.data(Wick.BloomreachWidget.el.previousQuantityData, qty);
|
|
906
1055
|
$input.trigger('change');
|
|
907
1056
|
|
|
908
1057
|
if ($completeWidget.length) {
|
|
909
|
-
|
|
1058
|
+
Wick.BloomreachWidget.dispatchCalculateTotal($completeWidget);
|
|
910
1059
|
}
|
|
911
1060
|
},
|
|
912
1061
|
});
|
|
913
1062
|
|
|
914
1063
|
stepper.init($root);
|
|
915
1064
|
|
|
916
|
-
$root.find(inputSel).data(
|
|
1065
|
+
$root.find(inputSel).data(Wick.BloomreachWidget.el.quantityReadyData, true);
|
|
917
1066
|
|
|
918
|
-
|
|
1067
|
+
Wick.BloomreachWidget.steppers.push(stepper);
|
|
919
1068
|
},
|
|
920
1069
|
|
|
921
1070
|
initQuantityFields($root) {
|
|
@@ -924,7 +1073,7 @@ const CompleteYourProjectWidget = {
|
|
|
924
1073
|
countStepperInitializedData,
|
|
925
1074
|
countStepperRoot,
|
|
926
1075
|
previousQuantityData,
|
|
927
|
-
} =
|
|
1076
|
+
} = Wick.BloomreachWidget.el;
|
|
928
1077
|
|
|
929
1078
|
$root.find(quantityInput).each(function () {
|
|
930
1079
|
const $input = $(this);
|
|
@@ -942,94 +1091,99 @@ const CompleteYourProjectWidget = {
|
|
|
942
1091
|
$input.data(countStepperInitializedData, true);
|
|
943
1092
|
$input.data(previousQuantityData, parseInt($input.val(), 10) || 1);
|
|
944
1093
|
|
|
945
|
-
|
|
1094
|
+
Wick.BloomreachWidget.initQuantityField(
|
|
946
1095
|
$input.closest(countStepperRoot),
|
|
947
1096
|
`#${inputId}`
|
|
948
1097
|
);
|
|
949
1098
|
});
|
|
950
1099
|
},
|
|
951
1100
|
|
|
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
|
+
|
|
952
1110
|
resetWidgetState($root) {
|
|
953
|
-
$root.find(
|
|
1111
|
+
$root.find(Wick.BloomreachWidget.el.cardCheckbox).prop('checked', false);
|
|
954
1112
|
|
|
955
1113
|
$root
|
|
956
|
-
.find(
|
|
957
|
-
.removeClass(
|
|
1114
|
+
.find(Wick.BloomreachWidget.el.completeCard)
|
|
1115
|
+
.removeClass(Wick.BloomreachWidget.el.selectedClass);
|
|
958
1116
|
|
|
959
1117
|
$root
|
|
960
|
-
.find(
|
|
1118
|
+
.find(Wick.BloomreachWidget.el.quantityInput)
|
|
961
1119
|
.val(1)
|
|
962
|
-
.data(
|
|
1120
|
+
.data(Wick.BloomreachWidget.el.previousQuantityData, 1);
|
|
963
1121
|
},
|
|
964
1122
|
|
|
965
1123
|
resetBackForwardState() {
|
|
966
|
-
$(
|
|
1124
|
+
$(Wick.BloomreachWidget.el.completeWidget).each(function () {
|
|
967
1125
|
const $widget = $(this);
|
|
968
1126
|
|
|
969
|
-
|
|
970
|
-
|
|
1127
|
+
Wick.BloomreachWidget.resetWidgetState($widget);
|
|
1128
|
+
Wick.BloomreachWidget.bindCardSelection($widget);
|
|
971
1129
|
});
|
|
972
1130
|
},
|
|
973
1131
|
|
|
974
1132
|
initRenderedWidget($container) {
|
|
975
|
-
if (!
|
|
976
|
-
|
|
1133
|
+
if (!Wick.BloomreachWidget.toast) {
|
|
1134
|
+
Wick.BloomreachWidget.toast = createToast({
|
|
977
1135
|
template: notificationTemplate,
|
|
978
1136
|
});
|
|
979
1137
|
}
|
|
980
|
-
if (!
|
|
981
|
-
|
|
1138
|
+
if (!Wick.BloomreachWidget.loadingButton) {
|
|
1139
|
+
Wick.BloomreachWidget.loadingButton = createLoadingButton();
|
|
982
1140
|
}
|
|
983
|
-
const $completeWidget = $container.find(
|
|
1141
|
+
const $completeWidget = $container.find(Wick.BloomreachWidget.el.completeWidget);
|
|
984
1142
|
|
|
985
1143
|
if (!$completeWidget.length) {
|
|
986
1144
|
return;
|
|
987
1145
|
}
|
|
988
1146
|
|
|
989
1147
|
Wick.BloomreachWidget.drawRating($completeWidget);
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
CompleteYourProjectWidget.initQuantityFields($completeWidget);
|
|
1148
|
+
Wick.BloomreachWidget.bindCardSelection($completeWidget);
|
|
1149
|
+
Wick.BloomreachWidget.bindDropdowns();
|
|
1150
|
+
Wick.BloomreachWidget.bindDropdownValidation($completeWidget);
|
|
1151
|
+
Wick.BloomreachWidget.bindAddToCart($completeWidget);
|
|
1152
|
+
Wick.BloomreachWidget.initQuantityFields($completeWidget);
|
|
996
1153
|
|
|
997
1154
|
$completeWidget
|
|
998
|
-
.find(
|
|
999
|
-
.removeClass(
|
|
1155
|
+
.find(Wick.BloomreachWidget.el.dropdownRoot)
|
|
1156
|
+
.removeClass(Wick.BloomreachWidget.el.dropdownErrorClass);
|
|
1000
1157
|
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
Wick.BloomreachWidget.reapplyVatDisplay();
|
|
1158
|
+
Wick.BloomreachWidget.alignCardBlocks($completeWidget);
|
|
1159
|
+
Wick.BloomreachWidget.updateCta($completeWidget);
|
|
1160
|
+
Wick.BloomreachWidget.setInitialSummary($completeWidget);
|
|
1005
1161
|
},
|
|
1006
1162
|
|
|
1007
1163
|
init(payloadData) {
|
|
1008
|
-
const $containers = $(
|
|
1164
|
+
const $containers = $(Wick.BloomreachWidget.el.widgetContainer);
|
|
1009
1165
|
|
|
1010
1166
|
if (!payloadData || !Wick.BloomreachWidget.hasRecommendations(payloadData)) {
|
|
1011
|
-
$containers.find(
|
|
1167
|
+
$containers.find(Wick.BloomreachWidget.el.completeWidget).hide();
|
|
1012
1168
|
return;
|
|
1013
1169
|
}
|
|
1014
1170
|
|
|
1015
|
-
|
|
1171
|
+
Wick.BloomreachWidget.renderWidgetFromPayload(payloadData);
|
|
1016
1172
|
},
|
|
1017
1173
|
};
|
|
1018
1174
|
|
|
1019
1175
|
$(document).ready(function () {
|
|
1020
1176
|
Wick.Responsive.onResize(function () {
|
|
1021
|
-
$(
|
|
1022
|
-
const $completeWidget = $(this).find(
|
|
1177
|
+
$(Wick.BloomreachWidget.el.widgetContainer).each(function () {
|
|
1178
|
+
const $completeWidget = $(this).find(Wick.BloomreachWidget.el.completeWidget);
|
|
1023
1179
|
|
|
1024
1180
|
if ($completeWidget.length) {
|
|
1025
|
-
|
|
1181
|
+
Wick.BloomreachWidget.alignCardBlocks($completeWidget);
|
|
1026
1182
|
}
|
|
1027
1183
|
});
|
|
1028
1184
|
});
|
|
1029
1185
|
});
|
|
1030
1186
|
|
|
1031
1187
|
window.addEventListener('pagehide', function () {
|
|
1032
|
-
|
|
1188
|
+
Wick.BloomreachWidget.resetBackForwardState();
|
|
1033
1189
|
});
|
|
1034
|
-
|
|
1035
|
-
export default CompleteYourProjectWidget;
|