wickes-css2 2.113.0-develop.3 → 2.113.0-develop.6

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.
Files changed (88) hide show
  1. package/build/css/main.css +1 -1
  2. package/build/css/pages/checkout-new.css +1 -1
  3. package/build/css/pages/page_checkout_delivery-new.css +1 -1
  4. package/build/css/pages/page_merged-basket.css +1 -1
  5. package/build/css/pdp-main-before-combine.css +1 -1
  6. package/build/css/pdp-main-non-critical.css +1 -1
  7. package/build/css/pdp-main.css +1 -1
  8. package/build/img/emulation/low-trees.png +0 -0
  9. package/build/img/emulation/overhead-power-cables.png +0 -0
  10. package/build/img/emulation/parked-vehicles.png +0 -0
  11. package/build/img/emulation/traffic-access-issues.png +0 -0
  12. package/build/img/emulation/walls-or-fences.png +0 -0
  13. package/build/js/basket.min.js +1 -1
  14. package/build/js/bloomreach-widget.min.js +1 -1
  15. package/build/js/bundle.min.js +1 -1
  16. package/build/js/checkout.min.js +1 -1
  17. package/build/js/emulation.min.js +360 -3222
  18. package/build/js/general.bundle.min.js +1 -1
  19. package/build/js/merged-checkout.min.js +1 -1
  20. package/build/js/page/bloomreach-widget/bloomreach-recommendation-carousel-widget.js +318 -0
  21. package/build/js/page/bloomreach-widget/bloomreach-widget-core.js +370 -0
  22. package/build/js/page/bloomreach-widget/bloomreach-widget-tracking.js +16 -13
  23. package/build/js/page/bloomreach-widget/bloomreach-widget.js +8 -237
  24. package/build/js/page/bloomreach-widget/complete-your-project/cards.js +308 -0
  25. package/build/js/page/bloomreach-widget/complete-your-project/config.js +60 -0
  26. package/build/js/page/bloomreach-widget/complete-your-project/model.js +140 -0
  27. package/build/js/page/bloomreach-widget/complete-your-project/presenter.js +69 -0
  28. package/build/js/page/bloomreach-widget/complete-your-project/quantity.js +80 -0
  29. package/build/js/page/bloomreach-widget/complete-your-project/view.js +179 -0
  30. package/build/js/page/bloomreach-widget/complete-your-project/widget.js +185 -0
  31. package/build/js/page/bloomreach-widget/dont-forget-widget.js +15 -0
  32. package/build/js/page/bloomreach-widget/why-not-add-widget.js +10 -228
  33. package/build/js/pdp.bundle.min.js +1 -1
  34. package/build/js/plp.bundle.min.js +1 -1
  35. package/build/js/project-list.min.js +1 -1
  36. package/package.json +1 -1
  37. package/src/components/base/button.hbs +7 -0
  38. package/src/components/bloomreach/complete-your-project-skeleton.hbs +21 -0
  39. package/src/components/bloomreach/complete-your-project.hbs +6 -21
  40. package/src/components/bloomreach/why-not-add-card-skeleton.hbs +2 -2
  41. package/src/components/bloomreach/why-not-add-card.hbs +79 -60
  42. package/src/components/bloomreach/why-not-add-content.hbs +3 -3
  43. package/src/components/bloomreach/why-not-add.hbs +1 -1
  44. package/src/components/date-selection.hbs +17 -12
  45. package/src/components/heavy-banners-wrapper.hbs +21 -0
  46. package/src/data/data_heavy-banner.json +29 -0
  47. package/src/img/emulation/low-trees.png +0 -0
  48. package/src/img/emulation/overhead-power-cables.png +0 -0
  49. package/src/img/emulation/parked-vehicles.png +0 -0
  50. package/src/img/emulation/traffic-access-issues.png +0 -0
  51. package/src/img/emulation/walls-or-fences.png +0 -0
  52. package/src/js/components/general/cart-slider.js +41 -4
  53. package/src/js/emulation/complete-your-project-loading.js +16 -0
  54. package/src/js/emulation/custom-slider-emulation.js +21 -8
  55. package/src/js/emulation/dont-forget-loading.js +36 -0
  56. package/src/js/emulation/just-added-scenarios-emulation.js +131 -0
  57. package/src/js/emulation/mini-basket.js +34 -34
  58. package/src/js/emulation/mock.js +429 -4
  59. package/src/js/emulation/why-not-add-loading.js +14 -3
  60. package/src/js/emulation/why-not-add.js +12 -14
  61. package/src/js/page/bloomreach-widget/bloomreach-recommendation-carousel-widget.js +318 -0
  62. package/src/js/page/bloomreach-widget/bloomreach-widget-core.js +370 -0
  63. package/src/js/page/bloomreach-widget/bloomreach-widget-tracking.js +16 -13
  64. package/src/js/page/bloomreach-widget/bloomreach-widget.js +8 -237
  65. package/src/js/page/bloomreach-widget/complete-your-project/cards.js +308 -0
  66. package/src/js/page/bloomreach-widget/complete-your-project/config.js +60 -0
  67. package/src/js/page/bloomreach-widget/complete-your-project/model.js +140 -0
  68. package/src/js/page/bloomreach-widget/complete-your-project/presenter.js +69 -0
  69. package/src/js/page/bloomreach-widget/complete-your-project/quantity.js +80 -0
  70. package/src/js/page/bloomreach-widget/complete-your-project/view.js +179 -0
  71. package/src/js/page/bloomreach-widget/complete-your-project/widget.js +185 -0
  72. package/src/js/page/bloomreach-widget/dont-forget-widget.js +15 -0
  73. package/src/js/page/bloomreach-widget/why-not-add-widget.js +10 -228
  74. package/src/page_checkout_big-bulky-delivery-details.html +272 -0
  75. package/src/page_product-details-with-global-search-v2.html +4 -6
  76. package/src/page_product-details-with-why-not-add-single.html +1 -1
  77. package/src/scss/components/_checkout_order.scss +2 -1
  78. package/src/scss/components/_heavy-banners.scss +216 -0
  79. package/src/scss/components/bloomreach/_bloomreach.scss +1 -0
  80. package/src/scss/components/bloomreach/_card-shared.scss +24 -0
  81. package/src/scss/components/bloomreach/_complete-card.scss +1 -9
  82. package/src/scss/components/bloomreach/_why-not-add-card.scss +137 -10
  83. package/src/scss/components/bloomreach/_why-not-add.scss +31 -2
  84. package/src/scss/main.scss +1 -0
  85. package/src/scss/pages/page_checkout_delivery-new.scss +4 -0
  86. package/src/sitemap.html +2 -0
  87. package/build/js/page/bloomreach-widget/complete-your-project-widget.js +0 -1100
  88. package/src/js/page/bloomreach-widget/complete-your-project-widget.js +0 -1100
@@ -0,0 +1,370 @@
1
+ import { isApp } from '../utils/helpers';
2
+ import { createBloomreachWidgetTracking } from './bloomreach-widget-tracking';
3
+
4
+ var Wick = window.Wick || {};
5
+
6
+ import { createEvent } from '../utils/create-event';
7
+
8
+ export function createBloomreachWidget(config) {
9
+ const tracking = config.tracking || createBloomreachWidgetTracking();
10
+
11
+ const widget = {
12
+ el: config.el || {},
13
+ tracking,
14
+
15
+ getContainers(options = {}) {
16
+ if (options.container) {
17
+ return $(options.container);
18
+ }
19
+
20
+ return $(widget.el.widgetContainer);
21
+ },
22
+
23
+ hide(options = {}) {
24
+ const $containers = widget.getContainers(options);
25
+
26
+ if (config.hide) {
27
+ config.hide($containers, options, widget);
28
+ return;
29
+ }
30
+
31
+ $containers.empty().hide();
32
+ },
33
+
34
+ init(payloadData, options = {}) {
35
+ const $containers = widget.getContainers(options);
36
+
37
+ if (!$containers.length) {
38
+ return;
39
+ }
40
+
41
+ if (!payloadData || !Wick.BloomreachWidget.hasRecommendations(payloadData)) {
42
+ widget.hide(options);
43
+ return;
44
+ }
45
+
46
+ tracking.setPayload(payloadData);
47
+
48
+ if (config.setPayload) {
49
+ config.setPayload(payloadData, widget);
50
+ }
51
+
52
+ $containers.each(function () {
53
+ const $container = $(this);
54
+
55
+ if (config.renderWidget) {
56
+ config.renderWidget($container, payloadData, widget);
57
+ }
58
+
59
+ if (config.initRenderedWidget) {
60
+ config.initRenderedWidget($container, widget);
61
+ }
62
+ });
63
+
64
+ if (config.getViewTargets) {
65
+ tracking.observeView(config.getViewTargets($containers, widget));
66
+ }
67
+ },
68
+ };
69
+
70
+ return widget;
71
+ }
72
+
73
+ Wick.BloomreachWidget = {
74
+ widgets: {},
75
+
76
+ el: {
77
+ loadingButtonText: '.loading-button__text',
78
+ loadingButtonLoader: '.loading-button__loader',
79
+ ratingOverlay: '.rating-overlay',
80
+ starOverlay: '.star-overlay',
81
+ vatInc: '.including-vat-inherit',
82
+ vatExc: '.excluding-vat-inherit',
83
+ },
84
+
85
+ badgeColorMap: {
86
+ blue: '#019ee3',
87
+ gray: '#3e3e3e',
88
+ green: '#9acd32',
89
+ red: '#cf000f',
90
+ yellow: '#f7ca18',
91
+ },
92
+
93
+ getBadgeColor(color) {
94
+ if (!color) {
95
+ return '';
96
+ }
97
+
98
+ return Wick.BloomreachWidget.badgeColorMap[color] || color;
99
+ },
100
+
101
+ getBadge(product) {
102
+ if (!product) {
103
+ return null;
104
+ }
105
+
106
+ const promotion = product.potentialPromotions && product.potentialPromotions[0];
107
+ const promotionAttributes = promotion && promotion.customAttributes;
108
+
109
+ if (promotionAttributes && promotionAttributes.overlayText) {
110
+ return {
111
+ text: promotionAttributes.overlayText,
112
+ textColor: Wick.BloomreachWidget.getBadgeColor(
113
+ promotionAttributes.overlayTextColor
114
+ ),
115
+ color: Wick.BloomreachWidget.getBadgeColor(
116
+ promotionAttributes.overlayBackgroundColor
117
+ ),
118
+ };
119
+ }
120
+
121
+ if (product.badge && product.badge.text) {
122
+ return {
123
+ ...product.badge,
124
+ textColor: Wick.BloomreachWidget.getBadgeColor(product.badge.textColor),
125
+ color: Wick.BloomreachWidget.getBadgeColor(product.badge.color),
126
+ };
127
+ }
128
+
129
+ return product.badge || null;
130
+ },
131
+
132
+ registerWidgets(widgetList) {
133
+ widgetList.forEach(function ({ type, widget }) {
134
+ Wick.BloomreachWidget.widgets[type] = widget;
135
+ });
136
+ },
137
+
138
+ getWidget(type) {
139
+ return Wick.BloomreachWidget.widgets[type];
140
+ },
141
+
142
+ init(type, payloadData, options = {}) {
143
+ const widget = Wick.BloomreachWidget.getWidget(type);
144
+
145
+ if (!widget || typeof widget.init !== 'function') {
146
+ return;
147
+ }
148
+
149
+ widget.init(payloadData, options, Wick.BloomreachWidget);
150
+ },
151
+
152
+ normalizePayload(payloadData) {
153
+ if (Array.isArray(payloadData)) {
154
+ return payloadData;
155
+ }
156
+
157
+ if (payloadData && Array.isArray(payloadData.recommendedProducts)) {
158
+ return payloadData.recommendedProducts;
159
+ }
160
+
161
+ return [];
162
+ },
163
+
164
+ hasRecommendations(payloadData) {
165
+ return Wick.BloomreachWidget.normalizePayload(payloadData).length > 0;
166
+ },
167
+
168
+ removeBlankTargets($root) {
169
+ if (!isApp()) {
170
+ return;
171
+ }
172
+
173
+ $root.find('a[target="_blank"]').removeAttr('target');
174
+ },
175
+
176
+ getDisplayPrice(product) {
177
+ return product.displayPrice || product.price || {};
178
+ },
179
+
180
+ getDisplayPriceExcVat(product) {
181
+ return product.displayPriceExclusiveVat || product.priceExclusiveVat || null;
182
+ },
183
+
184
+ getExcVatFormattedValue(product, displayPrice) {
185
+ const excVat = Wick.BloomreachWidget.getDisplayPriceExcVat(product);
186
+
187
+ if (excVat && excVat.formattedValue) {
188
+ return excVat.formattedValue;
189
+ }
190
+
191
+ if (!displayPrice || typeof displayPrice.value !== 'number') {
192
+ return displayPrice ? displayPrice.formattedValue || '' : '';
193
+ }
194
+
195
+ const vatRate = displayPrice.vatRatePercentage || 20;
196
+
197
+ return Wick.BloomreachWidget.formatPrice(displayPrice.value / (1 + vatRate / 100));
198
+ },
199
+
200
+ getPriceValue(price) {
201
+ return price && typeof price.value === 'number' ? price.value : 0;
202
+ },
203
+
204
+ getPriceFormattedValue(price) {
205
+ if (!price) {
206
+ return '';
207
+ }
208
+
209
+ if (price.formattedValue) {
210
+ return price.formattedValue;
211
+ }
212
+
213
+ if (typeof price.value === 'number') {
214
+ return Wick.BloomreachWidget.formatPrice(price.value);
215
+ }
216
+
217
+ return '';
218
+ },
219
+
220
+ getWasPrice(product) {
221
+ const displayPrice = Wick.BloomreachWidget.getDisplayPrice(product);
222
+
223
+ return displayPrice && displayPrice.wasPrice ? displayPrice.wasPrice : null;
224
+ },
225
+
226
+ getWasPriceFormatted(product) {
227
+ const displayPrice = Wick.BloomreachWidget.getDisplayPrice(product);
228
+ const wasPrice = Wick.BloomreachWidget.getWasPrice(product);
229
+
230
+ if (wasPrice && wasPrice.formattedValue) {
231
+ return wasPrice.formattedValue;
232
+ }
233
+
234
+ if (typeof wasPrice === 'number') {
235
+ return Wick.BloomreachWidget.formatPrice(wasPrice);
236
+ }
237
+
238
+ if (wasPrice) {
239
+ return `${displayPrice.currencySymbol || '£'}${wasPrice}`;
240
+ }
241
+
242
+ return '';
243
+ },
244
+
245
+ getExcVatWasPrice(product) {
246
+ const priceExclusiveVat = product.priceExclusiveVat || null;
247
+ const displayPriceExclusiveVat = product.displayPriceExclusiveVat || null;
248
+ const wasPrice =
249
+ (displayPriceExclusiveVat && displayPriceExclusiveVat.wasPrice) ||
250
+ (priceExclusiveVat && priceExclusiveVat.wasPrice);
251
+
252
+ if (wasPrice && wasPrice.formattedValue) {
253
+ return wasPrice.formattedValue;
254
+ }
255
+
256
+ if (typeof wasPrice === 'number') {
257
+ return Wick.BloomreachWidget.formatPrice(wasPrice);
258
+ }
259
+
260
+ return wasPrice || '';
261
+ },
262
+
263
+ getProductImage(product, fallbackProduct) {
264
+ const productImages = product.images || [];
265
+ const fallbackImages = fallbackProduct ? fallbackProduct.images || [] : [];
266
+ const images = productImages.length ? productImages : fallbackImages;
267
+
268
+ return (
269
+ images.find(function (item) {
270
+ return item.format === 'product';
271
+ }) ||
272
+ images.find(function (item) {
273
+ return item.imageType === 'PRIMARY';
274
+ }) ||
275
+ images[0] ||
276
+ {}
277
+ );
278
+ },
279
+
280
+ getProductRenderData(product, options = {}) {
281
+ const displayPrice = Wick.BloomreachWidget.getDisplayPrice(product);
282
+ const displayPriceExcVat = Wick.BloomreachWidget.getDisplayPriceExcVat(product);
283
+ const wasPriceFormatted = Wick.BloomreachWidget.getWasPriceFormatted(product);
284
+ const isSwitchVat = !!(window.ACC && window.ACC.app && window.ACC.app.isVatToggleAvailable);
285
+ const excVatFormattedValue = options.fallbackExcVat
286
+ ? Wick.BloomreachWidget.getExcVatFormattedValue(product, displayPrice)
287
+ : Wick.BloomreachWidget.getPriceFormattedValue(displayPriceExcVat);
288
+
289
+ return {
290
+ ...product,
291
+ badge: Wick.BloomreachWidget.getBadge(product),
292
+ price: displayPrice,
293
+ image:
294
+ options.image ||
295
+ Wick.BloomreachWidget.getProductImage(product, options.fallbackProduct),
296
+ wasPriceFormatted,
297
+ 'switch-vat': isSwitchVat,
298
+ incVatFormattedValue: Wick.BloomreachWidget.getPriceFormattedValue(displayPrice),
299
+ incVatValue: Wick.BloomreachWidget.getPriceValue(displayPrice),
300
+ excVatFormattedValue,
301
+ excVatValue: Wick.BloomreachWidget.getPriceValue(displayPriceExcVat),
302
+ incVatWasPriceFormatted: wasPriceFormatted,
303
+ excVatWasPriceFormatted: Wick.BloomreachWidget.getExcVatWasPrice(product),
304
+ };
305
+ },
306
+
307
+ drawRating($root) {
308
+ const { ratingOverlay, starOverlay } = Wick.BloomreachWidget.el;
309
+
310
+ $root.find(ratingOverlay).each(function () {
311
+ let rating = parseFloat($(this).attr('data-rating')) || 0;
312
+ const $stars = $(this).children(starOverlay);
313
+
314
+ $stars.each(function () {
315
+ const $star = $(this);
316
+
317
+ if (rating >= 1) {
318
+ rating--;
319
+ } else if (rating > 0) {
320
+ const width = Math.asin(2 * rating - 1) / Math.PI + 0.5;
321
+ $star.css('width', width + 'rem');
322
+ rating = 0;
323
+ } else {
324
+ $star.css('width', '0rem');
325
+ }
326
+ });
327
+ });
328
+ },
329
+
330
+ dispatchWidgetEvent(eventName, payload) {
331
+ return new Promise(function (resolve, reject) {
332
+ const eventDetail = { resolve, reject };
333
+ const event = createEvent(eventName, payload, eventDetail);
334
+
335
+ window.dispatchEvent(event);
336
+ });
337
+ },
338
+
339
+ reapplyVatDisplay() {
340
+ if (!Wick.VatToggle || typeof Wick.VatToggle.isActive !== 'function') {
341
+ return;
342
+ }
343
+
344
+ const { vatInc, vatExc } = Wick.BloomreachWidget.el;
345
+ const hiddenClassName = Wick.VatToggle.HIDDEN_CLASS_NAME || 'd-none';
346
+ const isExcVatActive = Wick.VatToggle.isActive();
347
+
348
+ $(vatInc).toggleClass(hiddenClassName, isExcVatActive);
349
+ $(vatExc).toggleClass(hiddenClassName, !isExcVatActive);
350
+ },
351
+
352
+ bindVatToggle(namespace) {
353
+ if (!Wick.VatToggle || !Wick.VatToggle.TOGGLE_VAT_EVENT_NAME) {
354
+ return;
355
+ }
356
+
357
+ const eventName = `${Wick.VatToggle.TOGGLE_VAT_EVENT_NAME}.${namespace}`;
358
+
359
+ $(window).off(eventName).on(eventName, Wick.BloomreachWidget.reapplyVatDisplay);
360
+ },
361
+
362
+ formatPrice(value) {
363
+ return new Intl.NumberFormat('en-GB', {
364
+ style: 'currency',
365
+ currency: 'GBP',
366
+ minimumFractionDigits: 2,
367
+ maximumFractionDigits: 2,
368
+ }).format(value);
369
+ },
370
+ };
@@ -15,22 +15,24 @@ function disconnectViewObserver(state) {
15
15
  state.viewObserver = null;
16
16
  }
17
17
 
18
- function observeView(state, elements) {
19
- if (!window.IntersectionObserver) {
18
+ function observeView(state, target) {
19
+ if (!target || !window.IntersectionObserver) {
20
20
  return;
21
21
  }
22
22
 
23
- elements = Array.isArray(elements) ? elements : [elements];
23
+ const elements = Array.isArray(target) ? target : [target];
24
24
 
25
25
  state.viewObserver = new IntersectionObserver(function (entries) {
26
- if (
27
- entries.some(function (entry) {
28
- return entry.isIntersecting;
29
- })
30
- ) {
31
- pushDataLayerEvent(EVENT_NAMES.view, state.widgetData);
32
- disconnectViewObserver(state);
26
+ const isVisible = entries.some(function (entry) {
27
+ return entry.isIntersecting;
28
+ });
29
+
30
+ if (!isVisible) {
31
+ return;
33
32
  }
33
+
34
+ pushDataLayerEvent(EVENT_NAMES.view, state.widgetData);
35
+ disconnectViewObserver(state);
34
36
  });
35
37
 
36
38
  elements.forEach(function (element) {
@@ -56,13 +58,14 @@ function trackAddToCart(state, items) {
56
58
 
57
59
  export function createBloomreachWidgetTracking() {
58
60
  const state = {
59
- initWidgetPayload: null,
61
+ widgetData: null,
60
62
  viewObserver: null,
61
63
  };
62
64
 
63
65
  return {
64
66
  setPayload(payloadData) {
65
67
  disconnectViewObserver(state);
68
+
66
69
  const metadata = payloadData.widgetMetadata;
67
70
 
68
71
  state.widgetData = {
@@ -72,8 +75,8 @@ export function createBloomreachWidgetTracking() {
72
75
  };
73
76
  },
74
77
 
75
- observeView(element) {
76
- observeView(state, element);
78
+ observeView(target) {
79
+ observeView(state, target);
77
80
  },
78
81
 
79
82
  trackClick(itemId) {
@@ -1,250 +1,21 @@
1
1
  var Wick = window.Wick || {};
2
2
 
3
- import { isApp } from '../utils/helpers';
4
- import { createEvent } from '../utils/create-event';
5
- import CompleteYourProjectWidget from './complete-your-project-widget';
3
+ import './bloomreach-widget-core';
4
+ import Widget from './complete-your-project/widget';
6
5
  import WhyNotAddWidget from './why-not-add-widget';
7
-
8
- Wick.BloomreachWidget = {
9
- widgets: {},
10
-
11
- el: {
12
- loadingButtonText: '.loading-button__text',
13
- loadingButtonLoader: '.loading-button__loader',
14
- ratingOverlay: '.rating-overlay',
15
- starOverlay: '.star-overlay',
16
- vatInc: '.including-vat-inherit',
17
- vatExc: '.excluding-vat-inherit',
18
- },
19
-
20
- registerWidgets(widgetList) {
21
- widgetList.forEach(function ({ type, widget }) {
22
- Wick.BloomreachWidget.widgets[type] = widget;
23
- });
24
- },
25
-
26
- getWidget(type) {
27
- return Wick.BloomreachWidget.widgets[type];
28
- },
29
-
30
- init(type, payloadData) {
31
- const widget = Wick.BloomreachWidget.getWidget(type);
32
-
33
- if (!widget || typeof widget.init !== 'function') {
34
- return;
35
- }
36
-
37
- widget.init(payloadData, Wick.BloomreachWidget);
38
- },
39
-
40
- normalizePayload(payloadData) {
41
- if (Array.isArray(payloadData)) {
42
- return payloadData;
43
- }
44
-
45
- if (payloadData && Array.isArray(payloadData.recommendedProducts)) {
46
- return payloadData.recommendedProducts;
47
- }
48
-
49
- return [];
50
- },
51
-
52
- hasRecommendations(payloadData) {
53
- return Wick.BloomreachWidget.normalizePayload(payloadData).length > 0;
54
- },
55
-
56
- getDisplayPrice(product) {
57
- return product.displayPrice || product.price || {};
58
- },
59
-
60
- getDisplayPriceExcVat(product) {
61
- return product.displayPriceExclusiveVat || product.priceExclusiveVat || null;
62
- },
63
-
64
- getPriceValue(price) {
65
- return price && typeof price.value === 'number' ? price.value : 0;
66
- },
67
-
68
- getPriceFormattedValue(price) {
69
- if (!price) {
70
- return '';
71
- }
72
-
73
- if (price.formattedValue) {
74
- return price.formattedValue;
75
- }
76
-
77
- if (typeof price.value === 'number') {
78
- return Wick.BloomreachWidget.formatPrice(price.value);
79
- }
80
-
81
- return '';
82
- },
83
-
84
- removeBlankTargets($root) {
85
- if (!isApp()) {
86
- return;
87
- }
88
-
89
- $root.find('a[target="_blank"]').removeAttr('target');
90
- },
91
-
92
- getWasPrice(product) {
93
- const displayPrice = Wick.BloomreachWidget.getDisplayPrice(product);
94
-
95
- return displayPrice && displayPrice.wasPrice ? displayPrice.wasPrice : null;
96
- },
97
-
98
- getWasPriceFormatted(product) {
99
- const displayPrice = Wick.BloomreachWidget.getDisplayPrice(product);
100
- const wasPrice = Wick.BloomreachWidget.getWasPrice(product);
101
-
102
- if (wasPrice && wasPrice.formattedValue) {
103
- return wasPrice.formattedValue;
104
- }
105
-
106
- if (typeof wasPrice === 'number') {
107
- return Wick.BloomreachWidget.formatPrice(wasPrice);
108
- }
109
-
110
- if (wasPrice) {
111
- return `${displayPrice.currencySymbol || '£'}${wasPrice}`;
112
- }
113
-
114
- return '';
115
- },
116
-
117
- getExcVatWasPrice(product) {
118
- const priceExclusiveVat = product.priceExclusiveVat || null;
119
- const displayPriceExclusiveVat = product.displayPriceExclusiveVat || null;
120
- const wasPrice =
121
- (displayPriceExclusiveVat && displayPriceExclusiveVat.wasPrice) ||
122
- (priceExclusiveVat && priceExclusiveVat.wasPrice);
123
-
124
- if (wasPrice && wasPrice.formattedValue) {
125
- return wasPrice.formattedValue;
126
- }
127
-
128
- if (typeof wasPrice === 'number') {
129
- return Wick.BloomreachWidget.formatPrice(wasPrice);
130
- }
131
-
132
- return wasPrice || '';
133
- },
134
-
135
- getProductImage(product, fallbackProduct) {
136
- const productImages = product.images || [];
137
- const fallbackImages = fallbackProduct ? fallbackProduct.images || [] : [];
138
- const images = productImages.length ? productImages : fallbackImages;
139
-
140
- return (
141
- images.find(function (item) {
142
- return item.format === 'product';
143
- }) ||
144
- images.find(function (item) {
145
- return item.imageType === 'PRIMARY';
146
- }) ||
147
- images[0] ||
148
- {}
149
- );
150
- },
151
-
152
- getProductRenderData(product, options = {}) {
153
- const displayPrice = Wick.BloomreachWidget.getDisplayPrice(product);
154
- const displayPriceExcVat = Wick.BloomreachWidget.getDisplayPriceExcVat(product);
155
- const wasPriceFormatted = Wick.BloomreachWidget.getWasPriceFormatted(product);
156
- const excVatWasPriceFormatted = Wick.BloomreachWidget.getExcVatWasPrice(product);
157
- const isSwitchVat = !!(window.ACC && window.ACC.app && window.ACC.app.isVatToggleAvailable);
158
-
159
- return {
160
- ...product,
161
- price: displayPrice,
162
- image:
163
- options.image ||
164
- Wick.BloomreachWidget.getProductImage(product, options.fallbackProduct),
165
- wasPriceFormatted,
166
- 'switch-vat': isSwitchVat,
167
- incVatFormattedValue: Wick.BloomreachWidget.getPriceFormattedValue(displayPrice),
168
- incVatValue: Wick.BloomreachWidget.getPriceValue(displayPrice),
169
- excVatFormattedValue: Wick.BloomreachWidget.getPriceFormattedValue(displayPriceExcVat),
170
- excVatValue: Wick.BloomreachWidget.getPriceValue(displayPriceExcVat),
171
- incVatWasPriceFormatted: wasPriceFormatted,
172
- excVatWasPriceFormatted: Wick.BloomreachWidget.getExcVatWasPrice(product),
173
- };
174
- },
175
-
176
- drawRating($root) {
177
- const { ratingOverlay, starOverlay } = Wick.BloomreachWidget.el;
178
-
179
- $root.find(ratingOverlay).each(function () {
180
- let rating = parseFloat($(this).attr('data-rating')) || 0;
181
- const $stars = $(this).children(starOverlay);
182
-
183
- $stars.each(function () {
184
- const $star = $(this);
185
-
186
- if (rating >= 1) {
187
- rating--;
188
- } else if (rating > 0) {
189
- const width = Math.asin(2 * rating - 1) / Math.PI + 0.5;
190
- $star.css('width', width + 'rem');
191
- rating = 0;
192
- } else {
193
- $star.css('width', '0rem');
194
- }
195
- });
196
- });
197
- },
198
-
199
- dispatchWidgetEvent(eventName, payload) {
200
- return new Promise(function (resolve, reject) {
201
- const eventDetail = { resolve, reject };
202
- const event = createEvent(eventName, payload, eventDetail);
203
-
204
- window.dispatchEvent(event);
205
- });
206
- },
207
-
208
- reapplyVatDisplay() {
209
- if (!Wick.VatToggle || typeof Wick.VatToggle.isActive !== 'function') {
210
- return;
211
- }
212
-
213
- const { vatInc, vatExc } = Wick.BloomreachWidget.el;
214
- const hiddenClassName = Wick.VatToggle.HIDDEN_CLASS_NAME || 'd-none';
215
- const isExcVatActive = Wick.VatToggle.isActive();
216
-
217
- $(vatInc).toggleClass(hiddenClassName, isExcVatActive);
218
- $(vatExc).toggleClass(hiddenClassName, !isExcVatActive);
219
- },
220
-
221
- bindVatToggle(namespace) {
222
- if (!Wick.VatToggle || !Wick.VatToggle.TOGGLE_VAT_EVENT_NAME) {
223
- return;
224
- }
225
-
226
- const eventName = `${Wick.VatToggle.TOGGLE_VAT_EVENT_NAME}.${namespace}`;
227
-
228
- $(window).off(eventName).on(eventName, Wick.BloomreachWidget.reapplyVatDisplay);
229
- },
230
-
231
- formatPrice(value) {
232
- return new Intl.NumberFormat('en-GB', {
233
- style: 'currency',
234
- currency: 'GBP',
235
- minimumFractionDigits: 2,
236
- maximumFractionDigits: 2,
237
- }).format(value);
238
- },
239
- };
6
+ import DontForgetWidget from './dont-forget-widget';
240
7
 
241
8
  Wick.BloomreachWidget.registerWidgets([
242
9
  {
243
10
  type: 'completeYourProject',
244
- widget: CompleteYourProjectWidget,
11
+ widget: Widget,
245
12
  },
246
13
  {
247
14
  type: 'whyNotAdd',
248
15
  widget: WhyNotAddWidget,
249
16
  },
17
+ {
18
+ type: 'dontForget',
19
+ widget: DontForgetWidget,
20
+ },
250
21
  ]);