wickes-css2 2.111.0-develop.4 → 2.111.0-dont-forget-widget.1

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 (37) hide show
  1. package/Readme.md +2 -1
  2. package/build/css/pdp-main-before-combine.css +1 -1
  3. package/build/css/pdp-main-non-critical.css +1 -1
  4. package/build/css/pdp-main.css +1 -1
  5. package/build/js/bloomreach-widget.min.js +1 -1
  6. package/build/js/emulation.min.js +334 -8
  7. package/build/js/page/bloomreach-widget/bloomreach-widget.js +241 -0
  8. package/build/js/page/{bloomreach-widget.js → bloomreach-widget/complete-your-project-widget.js} +205 -359
  9. package/build/js/page/bloomreach-widget/why-not-add-widget.js +196 -0
  10. package/package.json +1 -1
  11. package/src/components/bloomreach/complete-card.hbs +4 -32
  12. package/src/components/bloomreach/why-not-add-card-skeleton.hbs +14 -0
  13. package/src/components/bloomreach/why-not-add-card.hbs +73 -0
  14. package/src/components/bloomreach/why-not-add-content.hbs +41 -0
  15. package/src/components/bloomreach/why-not-add-skeleton.hbs +9 -0
  16. package/src/components/bloomreach/why-not-add.hbs +6 -0
  17. package/src/components/pdp-price-actions.hbs +2 -2
  18. package/src/components/price-block-v2.hbs +2 -0
  19. package/src/components/reviews-rating.hbs +22 -0
  20. package/src/js/emulation/bloomreach-widget-loading.js +2 -2
  21. package/src/js/emulation/mock.js +309 -0
  22. package/src/js/emulation/why-not-add-loading.js +11 -0
  23. package/src/js/emulation/why-not-add.js +28 -0
  24. package/src/js/page/bloomreach-widget/bloomreach-widget.js +241 -0
  25. package/src/js/page/{bloomreach-widget.js → bloomreach-widget/complete-your-project-widget.js} +205 -359
  26. package/src/js/page/bloomreach-widget/why-not-add-widget.js +196 -0
  27. package/src/page_product-details-bloomreach.html +1 -1
  28. package/src/page_product-details-with-global-search-v2.html +2 -1
  29. package/src/page_product-details-with-why-not-add-single.html +131 -0
  30. package/src/scss/components/bloomreach/_bloomreach.scss +3 -0
  31. package/src/scss/components/bloomreach/_complete-card.scss +0 -38
  32. package/src/scss/components/bloomreach/_reviews.scss +60 -0
  33. package/src/scss/components/bloomreach/_why-not-add-card.scss +212 -0
  34. package/src/scss/components/bloomreach/_why-not-add.scss +143 -0
  35. package/src/sitemap.html +10 -4
  36. package/src/components/.DS_Store +0 -0
  37. package/src/js/page/.DS_Store +0 -0
@@ -4997,9 +4997,9 @@ var Wick = window.Wick || {};
4997
4997
  $(document).ready(function () {
4998
4998
  window.setTimeout(function () {
4999
4999
  var $container = $('[data-complete-widget]');
5000
- var contextKey = $container.data('context-key');
5000
+ var contextKey = $container.data('mock-key');
5001
5001
  var payloadData = Wick.FEMock.dataBloomreach[contextKey];
5002
- Wick.BloomreachWidget.init(payloadData);
5002
+ Wick.BloomreachWidget.init('completeYourProject', payloadData);
5003
5003
  }, 3000);
5004
5004
  });
5005
5005
 
@@ -5760,7 +5760,7 @@ function waitFor(getter, cb, opts) {
5760
5760
  });
5761
5761
  })();
5762
5762
 
5763
- },{"../page/utils/show-more-less":97}],52:[function(require,module,exports){
5763
+ },{"../page/utils/show-more-less":99}],52:[function(require,module,exports){
5764
5764
  "use strict";
5765
5765
 
5766
5766
  var Wick = Wick || {};
@@ -12932,6 +12932,294 @@ Wick.FEMock = {
12932
12932
  }));
12933
12933
  },
12934
12934
  dataBloomreach: {
12935
+ whyNotAddRecommendationsSingle: {
12936
+ recommendedProducts: [{
12937
+ baseProduct: {
12938
+ code: '153731',
12939
+ name: 'Wickes Trade Paint Roller Set - 9in',
12940
+ url: '/Wickes-Trade-Paint-Roller-Set---9in/p/153731',
12941
+ purchasable: true,
12942
+ productType: 'ProductModel',
12943
+ isBaseProduct: false,
12944
+ availabilityRestriction: 'NO_RESTRICTIONS',
12945
+ fulfilmentType: 'STANDARD',
12946
+ stock: {
12947
+ stockLevelStatus: {
12948
+ code: 'inStock'
12949
+ }
12950
+ },
12951
+ fulfillmentAttributes: {
12952
+ type: 'STANDARD'
12953
+ },
12954
+ images: [{
12955
+ imageType: 'PRIMARY',
12956
+ format: 'product',
12957
+ url: 'https://placehold.co/68x68?text=roller',
12958
+ altText: 'Wickes Trade Paint Roller Set - 9in'
12959
+ }],
12960
+ externalAverageRating: 5,
12961
+ externalReviewCount: 100,
12962
+ displayPrice: {
12963
+ currencyIso: 'GBP',
12964
+ value: 9999,
12965
+ priceType: 'BUY',
12966
+ formattedValue: '£9,999.00',
12967
+ formattedPriceWithoutCurrencySymbol: '16',
12968
+ currencySymbol: '£',
12969
+ vatRatePercentage: 20,
12970
+ valueInPence: 999900,
12971
+ wasPrice: 30
12972
+ },
12973
+ displayPriceExclusiveVat: {
12974
+ currencyIso: 'GBP',
12975
+ value: 9998,
12976
+ priceType: 'BUY',
12977
+ formattedValue: '£9,998.00',
12978
+ formattedPriceWithoutCurrencySymbol: '13.33',
12979
+ currencySymbol: '£',
12980
+ valueInPence: 999800,
12981
+ wasPrice: 25
12982
+ }
12983
+ }
12984
+ }]
12985
+ },
12986
+ whyNotAddRecommendations: {
12987
+ recommendedProducts: [{
12988
+ baseProduct: {
12989
+ code: '153731',
12990
+ name: 'Wickes Trade Paint Roller Set - 9in',
12991
+ url: '/Wickes-Trade-Paint-Roller-Set---9in/p/153731',
12992
+ purchasable: true,
12993
+ productType: 'ProductModel',
12994
+ isBaseProduct: false,
12995
+ availabilityRestriction: 'NO_RESTRICTIONS',
12996
+ fulfilmentType: 'STANDARD',
12997
+ stock: {
12998
+ stockLevelStatus: {
12999
+ code: 'inStock'
13000
+ }
13001
+ },
13002
+ fulfillmentAttributes: {
13003
+ type: 'STANDARD'
13004
+ },
13005
+ images: [{
13006
+ imageType: 'PRIMARY',
13007
+ format: 'product',
13008
+ url: 'https://placehold.co/68x68?text=roller',
13009
+ altText: 'Wickes Trade Paint Roller Set - 9in'
13010
+ }],
13011
+ externalAverageRating: 5,
13012
+ externalReviewCount: 100,
13013
+ displayPrice: {
13014
+ currencyIso: 'GBP',
13015
+ value: 9999,
13016
+ priceType: 'BUY',
13017
+ formattedValue: '£9,999.00',
13018
+ formattedPriceWithoutCurrencySymbol: '16',
13019
+ currencySymbol: '£',
13020
+ vatRatePercentage: 20,
13021
+ valueInPence: 999900,
13022
+ wasPrice: 3000
13023
+ },
13024
+ displayPriceExclusiveVat: {
13025
+ currencyIso: 'GBP',
13026
+ value: 9998,
13027
+ priceType: 'BUY',
13028
+ formattedValue: '£9,998.00',
13029
+ formattedPriceWithoutCurrencySymbol: '13.33',
13030
+ currencySymbol: '£',
13031
+ valueInPence: 999800,
13032
+ wasPrice: 2500
13033
+ }
13034
+ }
13035
+ }, {
13036
+ baseProduct: {
13037
+ code: '349137',
13038
+ name: 'Wickes Microfibre Paint Roller Sleeve - 9in',
13039
+ url: '/Wickes-Microfibre-Paint-Roller-Sleeve---9in/p/349137',
13040
+ purchasable: true,
13041
+ productType: 'ProductModel',
13042
+ isBaseProduct: false,
13043
+ availabilityRestriction: 'NO_RESTRICTIONS',
13044
+ fulfilmentType: 'STANDARD',
13045
+ stock: {
13046
+ stockLevelStatus: {
13047
+ code: 'inStock'
13048
+ }
13049
+ },
13050
+ fulfillmentAttributes: {
13051
+ type: 'STANDARD'
13052
+ },
13053
+ images: [{
13054
+ imageType: 'PRIMARY',
13055
+ format: 'product',
13056
+ url: 'https://placehold.co/68x68?text=sleeve',
13057
+ altText: 'Wickes Microfibre Paint Roller Sleeve - 9in'
13058
+ }],
13059
+ externalAverageRating: 4.2,
13060
+ externalReviewCount: 48,
13061
+ displayPrice: {
13062
+ currencyIso: 'GBP',
13063
+ value: 9999,
13064
+ priceType: 'BUY',
13065
+ formattedValue: '£7.5220',
13066
+ formattedPriceWithoutCurrencySymbol: '7.50',
13067
+ currencySymbol: '£',
13068
+ vatRatePercentage: 20,
13069
+ valueInPence: 999900
13070
+ },
13071
+ displayPriceExclusiveVat: {
13072
+ currencyIso: 'GBP',
13073
+ value: 9998,
13074
+ priceType: 'BUY',
13075
+ formattedValue: '£6.25',
13076
+ formattedPriceWithoutCurrencySymbol: '6.25',
13077
+ currencySymbol: '£',
13078
+ valueInPence: 999800
13079
+ }
13080
+ }
13081
+ }, {
13082
+ baseProduct: {
13083
+ code: '221048',
13084
+ name: 'Wickes Paint Tray - 9in',
13085
+ url: '/Wickes-Paint-Tray---9in/p/221048',
13086
+ purchasable: true,
13087
+ productType: 'ProductModel',
13088
+ isBaseProduct: false,
13089
+ availabilityRestriction: 'NO_RESTRICTIONS',
13090
+ fulfilmentType: 'STANDARD',
13091
+ stock: {
13092
+ stockLevelStatus: {
13093
+ code: 'inStock'
13094
+ }
13095
+ },
13096
+ fulfillmentAttributes: {
13097
+ type: 'STANDARD'
13098
+ },
13099
+ images: [{
13100
+ imageType: 'PRIMARY',
13101
+ format: 'product',
13102
+ url: 'https://placehold.co/68x68?text=tray',
13103
+ altText: 'Wickes Paint Tray - 9in'
13104
+ }],
13105
+ externalAverageRating: 3.8,
13106
+ externalReviewCount: 19,
13107
+ displayPrice: {
13108
+ currencyIso: 'GBP',
13109
+ value: 4,
13110
+ priceType: 'BUY',
13111
+ formattedValue: '£4',
13112
+ formattedPriceWithoutCurrencySymbol: '4',
13113
+ currencySymbol: '£',
13114
+ vatRatePercentage: 20,
13115
+ valueInPence: 400
13116
+ },
13117
+ displayPriceExclusiveVat: {
13118
+ currencyIso: 'GBP',
13119
+ value: 3.33,
13120
+ priceType: 'BUY',
13121
+ formattedValue: '£3.33',
13122
+ formattedPriceWithoutCurrencySymbol: '3.33',
13123
+ currencySymbol: '£',
13124
+ valueInPence: 333
13125
+ }
13126
+ }
13127
+ }, {
13128
+ baseProduct: {
13129
+ code: '654221',
13130
+ name: 'Wickes Professional Masking Tape - 48mm x 50m',
13131
+ url: '/Wickes-Professional-Masking-Tape---48mm-x-50m/p/654221',
13132
+ purchasable: true,
13133
+ productType: 'ProductModel',
13134
+ isBaseProduct: false,
13135
+ availabilityRestriction: 'NO_RESTRICTIONS',
13136
+ fulfilmentType: 'STANDARD',
13137
+ stock: {
13138
+ stockLevelStatus: {
13139
+ code: 'inStock'
13140
+ }
13141
+ },
13142
+ fulfillmentAttributes: {
13143
+ type: 'STANDARD'
13144
+ },
13145
+ images: [{
13146
+ imageType: 'PRIMARY',
13147
+ format: 'product',
13148
+ url: 'https://placehold.co/68x68?text=tape',
13149
+ altText: 'Wickes Professional Masking Tape - 48mm x 50m'
13150
+ }],
13151
+ externalAverageRating: 4.6,
13152
+ externalReviewCount: 72,
13153
+ displayPrice: {
13154
+ currencyIso: 'GBP',
13155
+ value: 5.5,
13156
+ priceType: 'BUY',
13157
+ formattedValue: '£5.50',
13158
+ formattedPriceWithoutCurrencySymbol: '5.50',
13159
+ currencySymbol: '£',
13160
+ vatRatePercentage: 20,
13161
+ valueInPence: 550
13162
+ },
13163
+ displayPriceExclusiveVat: {
13164
+ currencyIso: 'GBP',
13165
+ value: 4.58,
13166
+ priceType: 'BUY',
13167
+ formattedValue: '£4.58',
13168
+ formattedPriceWithoutCurrencySymbol: '4.58',
13169
+ currencySymbol: '£',
13170
+ valueInPence: 458
13171
+ }
13172
+ }
13173
+ }, {
13174
+ baseProduct: {
13175
+ code: '782913',
13176
+ name: 'Wickes Dust Sheet Cotton Twill - 3.6m x 2.7m Extra Long Product Name For Two Line Truncation Test',
13177
+ url: '/Wickes-Dust-Sheet-Cotton-Twill---3-6m-x-2-7m/p/782913',
13178
+ purchasable: true,
13179
+ productType: 'ProductModel',
13180
+ isBaseProduct: false,
13181
+ availabilityRestriction: 'NO_RESTRICTIONS',
13182
+ fulfilmentType: 'STANDARD',
13183
+ stock: {
13184
+ stockLevelStatus: {
13185
+ code: 'inStock'
13186
+ }
13187
+ },
13188
+ fulfillmentAttributes: {
13189
+ type: 'STANDARD'
13190
+ },
13191
+ images: [{
13192
+ imageType: 'PRIMARY',
13193
+ format: 'product',
13194
+ url: 'https://placehold.co/68x68?text=sheet',
13195
+ altText: 'Wickes Dust Sheet Cotton Twill - 3.6m x 2.7m'
13196
+ }],
13197
+ externalAverageRating: 4.1,
13198
+ externalReviewCount: 34,
13199
+ displayPrice: {
13200
+ currencyIso: 'GBP',
13201
+ value: 12,
13202
+ priceType: 'BUY',
13203
+ formattedValue: '£12',
13204
+ formattedPriceWithoutCurrencySymbol: '12',
13205
+ currencySymbol: '£',
13206
+ vatRatePercentage: 20,
13207
+ valueInPence: 1200,
13208
+ wasPrice: 18
13209
+ },
13210
+ displayPriceExclusiveVat: {
13211
+ currencyIso: 'GBP',
13212
+ value: 10,
13213
+ priceType: 'BUY',
13214
+ formattedValue: '£10',
13215
+ formattedPriceWithoutCurrencySymbol: '10',
13216
+ currencySymbol: '£',
13217
+ valueInPence: 1000,
13218
+ wasPrice: 15
13219
+ }
13220
+ }
13221
+ }]
13222
+ },
12935
13223
  completeYourProject3Recomendations: [{
12936
13224
  baseProduct: {
12937
13225
  code: '191018',
@@ -16973,7 +17261,7 @@ $(document).ready(function () {
16973
17261
  initStoreLocatorLoadMore();
16974
17262
  });
16975
17263
 
16976
- },{"../page/utils/loader":96}],88:[function(require,module,exports){
17264
+ },{"../page/utils/loader":98}],88:[function(require,module,exports){
16977
17265
  "use strict";
16978
17266
 
16979
17267
  var Wick = window.Wick || {};
@@ -17123,6 +17411,44 @@ window.ACC.app.isVatToggleAvailable = !!$('.switch-vat input').length;
17123
17411
  },{}],94:[function(require,module,exports){
17124
17412
  "use strict";
17125
17413
 
17414
+ var Wick = window.Wick || {};
17415
+ $(document).ready(function () {
17416
+ window.setTimeout(function () {
17417
+ var $container = $('[data-why-not-add-widget]');
17418
+ var mockDataKey = $container.data('mock-key');
17419
+ var payloadData = Wick.FEMock.dataBloomreach[mockDataKey];
17420
+ Wick.BloomreachWidget.init('whyNotAdd', payloadData);
17421
+ }, 3000);
17422
+ });
17423
+
17424
+ },{}],95:[function(require,module,exports){
17425
+ "use strict";
17426
+
17427
+ var Wick = window.Wick || {};
17428
+ function simulateHybrisSendingHtml() {
17429
+ var htmlFromHybris = Wick.FEMock.cartPDP;
17430
+ window.dispatchEvent(new CustomEvent('productAddedToCart', {
17431
+ detail: {
17432
+ html: htmlFromHybris
17433
+ }
17434
+ }));
17435
+ }
17436
+ function bindWhyNotAddToCartEvent() {
17437
+ $(window).off('addToCart.whyNotAddEmulation').on('addToCart.whyNotAddEmulation', function (_ref) {
17438
+ var resolve = _ref.detail.resolve;
17439
+ setTimeout(function () {
17440
+ resolve();
17441
+ simulateHybrisSendingHtml();
17442
+ }, 3000);
17443
+ });
17444
+ }
17445
+ $(document).ready(function () {
17446
+ bindWhyNotAddToCartEvent();
17447
+ });
17448
+
17449
+ },{}],96:[function(require,module,exports){
17450
+ "use strict";
17451
+
17126
17452
  var Wick = window.Wick = window.Wick || {};
17127
17453
  Wick.Wismo = function () {
17128
17454
  Wick.SnackBar.init();
@@ -17152,7 +17478,7 @@ Wick.Wismo = function () {
17152
17478
  });
17153
17479
  }();
17154
17480
 
17155
- },{}],95:[function(require,module,exports){
17481
+ },{}],97:[function(require,module,exports){
17156
17482
  "use strict";
17157
17483
 
17158
17484
  var Wick = Wick || {};
@@ -17231,7 +17557,7 @@ Wick.YourDetails = function () {
17231
17557
  });
17232
17558
  }();
17233
17559
 
17234
- },{}],96:[function(require,module,exports){
17560
+ },{}],98:[function(require,module,exports){
17235
17561
  "use strict";
17236
17562
 
17237
17563
  Object.defineProperty(exports, "__esModule", {
@@ -17257,7 +17583,7 @@ function hideLoader(loaderSelector) {
17257
17583
  $(defineLoaderWrapper(loaderSelector)).addClass(HIDDEN_CLASS_NAME);
17258
17584
  }
17259
17585
 
17260
- },{"../../../elements/loader.hbs":25}],97:[function(require,module,exports){
17586
+ },{"../../../elements/loader.hbs":25}],99:[function(require,module,exports){
17261
17587
  "use strict";
17262
17588
 
17263
17589
  Object.defineProperty(exports, "__esModule", {
@@ -17494,4 +17820,4 @@ function createShowMoreLess() {
17494
17820
  };
17495
17821
  }
17496
17822
 
17497
- },{"../../../elements/btn.hbs":24}]},{},[26,27,28,29,30,31,32,33,34,35,36,37,38,39,44,40,41,42,43,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95]);
17823
+ },{"../../../elements/btn.hbs":24}]},{},[26,27,28,29,30,31,32,33,34,35,36,37,38,39,44,40,41,42,43,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97]);
@@ -0,0 +1,241 @@
1
+ var Wick = window.Wick || {};
2
+
3
+ import { createEvent } from '../utils/create-event';
4
+ import CompleteYourProjectWidget from './complete-your-project-widget';
5
+ import WhyNotAddWidget from './why-not-add-widget';
6
+
7
+ Wick.BloomreachWidget = {
8
+ widgets: {},
9
+
10
+ el: {
11
+ loadingButtonText: '.loading-button__text',
12
+ loadingButtonLoader: '.loading-button__loader',
13
+ ratingOverlay: '.rating-overlay',
14
+ starOverlay: '.star-overlay',
15
+ vatInc: '.including-vat-inherit',
16
+ vatExc: '.excluding-vat-inherit',
17
+ },
18
+
19
+ registerWidgets(widgetList) {
20
+ widgetList.forEach(function ({ type, widget }) {
21
+ Wick.BloomreachWidget.widgets[type] = widget;
22
+ });
23
+ },
24
+
25
+ getWidget(type) {
26
+ return Wick.BloomreachWidget.widgets[type];
27
+ },
28
+
29
+ init(type, payloadData) {
30
+ const widget = Wick.BloomreachWidget.getWidget(type);
31
+
32
+ if (!widget || typeof widget.init !== 'function') {
33
+ return;
34
+ }
35
+
36
+ widget.init(payloadData, Wick.BloomreachWidget);
37
+ },
38
+
39
+ normalizePayload(payloadData) {
40
+ if (Array.isArray(payloadData)) {
41
+ return payloadData;
42
+ }
43
+
44
+ if (payloadData && Array.isArray(payloadData.recommendedProducts)) {
45
+ return payloadData.recommendedProducts;
46
+ }
47
+
48
+ return [];
49
+ },
50
+
51
+ hasRecommendations(payloadData) {
52
+ return Wick.BloomreachWidget.normalizePayload(payloadData).length > 0;
53
+ },
54
+
55
+ getDisplayPrice(product) {
56
+ return product.displayPrice || product.price || {};
57
+ },
58
+
59
+ getDisplayPriceExcVat(product) {
60
+ return product.displayPriceExclusiveVat || product.priceExclusiveVat || null;
61
+ },
62
+
63
+ getPriceValue(price) {
64
+ return price && typeof price.value === 'number' ? price.value : 0;
65
+ },
66
+
67
+ getPriceFormattedValue(price) {
68
+ if (!price) {
69
+ return '';
70
+ }
71
+
72
+ if (price.formattedValue) {
73
+ return price.formattedValue;
74
+ }
75
+
76
+ if (typeof price.value === 'number') {
77
+ return Wick.BloomreachWidget.formatPrice(price.value);
78
+ }
79
+
80
+ return '';
81
+ },
82
+
83
+ getWasPrice(product) {
84
+ const displayPrice = Wick.BloomreachWidget.getDisplayPrice(product);
85
+
86
+ return displayPrice && displayPrice.wasPrice ? displayPrice.wasPrice : null;
87
+ },
88
+
89
+ getWasPriceFormatted(product) {
90
+ const displayPrice = Wick.BloomreachWidget.getDisplayPrice(product);
91
+ const wasPrice = Wick.BloomreachWidget.getWasPrice(product);
92
+
93
+ if (wasPrice && wasPrice.formattedValue) {
94
+ return wasPrice.formattedValue;
95
+ }
96
+
97
+ if (typeof wasPrice === 'number') {
98
+ return Wick.BloomreachWidget.formatPrice(wasPrice);
99
+ }
100
+
101
+ if (wasPrice) {
102
+ return `${displayPrice.currencySymbol || '£'}${wasPrice}`;
103
+ }
104
+
105
+ return '';
106
+ },
107
+
108
+ getExcVatWasPrice(product) {
109
+ const priceExclusiveVat = product.priceExclusiveVat || null;
110
+ const displayPriceExclusiveVat = product.displayPriceExclusiveVat || null;
111
+ const wasPrice =
112
+ (displayPriceExclusiveVat && displayPriceExclusiveVat.wasPrice) ||
113
+ (priceExclusiveVat && priceExclusiveVat.wasPrice);
114
+
115
+ if (wasPrice && wasPrice.formattedValue) {
116
+ return wasPrice.formattedValue;
117
+ }
118
+
119
+ if (typeof wasPrice === 'number') {
120
+ return Wick.BloomreachWidget.formatPrice(wasPrice);
121
+ }
122
+
123
+ return wasPrice || '';
124
+ },
125
+
126
+ getProductImage(product, fallbackProduct) {
127
+ const productImages = product.images || [];
128
+ const fallbackImages = fallbackProduct ? fallbackProduct.images || [] : [];
129
+ const images = productImages.length ? productImages : fallbackImages;
130
+
131
+ return (
132
+ images.find(function (item) {
133
+ return item.format === 'product';
134
+ }) ||
135
+ images.find(function (item) {
136
+ return item.imageType === 'PRIMARY';
137
+ }) ||
138
+ images[0] ||
139
+ {}
140
+ );
141
+ },
142
+
143
+ getProductRenderData(product, options = {}) {
144
+ const displayPrice = Wick.BloomreachWidget.getDisplayPrice(product);
145
+ const displayPriceExcVat = Wick.BloomreachWidget.getDisplayPriceExcVat(product);
146
+ const wasPriceFormatted = Wick.BloomreachWidget.getWasPriceFormatted(product);
147
+ const excVatWasPriceFormatted = Wick.BloomreachWidget.getExcVatWasPrice(product);
148
+ const isSwitchVat = !!(window.ACC && window.ACC.app && window.ACC.app.isVatToggleAvailable);
149
+
150
+ return {
151
+ ...product,
152
+ price: displayPrice,
153
+ image:
154
+ options.image ||
155
+ Wick.BloomreachWidget.getProductImage(product, options.fallbackProduct),
156
+ wasPriceFormatted,
157
+ 'switch-vat': isSwitchVat,
158
+ incVatFormattedValue: Wick.BloomreachWidget.getPriceFormattedValue(displayPrice),
159
+ incVatValue: Wick.BloomreachWidget.getPriceValue(displayPrice),
160
+ excVatFormattedValue: Wick.BloomreachWidget.getPriceFormattedValue(displayPriceExcVat),
161
+ excVatValue: Wick.BloomreachWidget.getPriceValue(displayPriceExcVat),
162
+ incVatWasPriceFormatted: wasPriceFormatted,
163
+ excVatWasPriceFormatted: Wick.BloomreachWidget.getExcVatWasPrice(product),
164
+ };
165
+ },
166
+
167
+ drawRating($root) {
168
+ const { ratingOverlay, starOverlay } = Wick.BloomreachWidget.el;
169
+
170
+ $root.find(ratingOverlay).each(function () {
171
+ let rating = parseFloat($(this).attr('data-rating')) || 0;
172
+ const $stars = $(this).children(starOverlay);
173
+
174
+ $stars.each(function () {
175
+ const $star = $(this);
176
+
177
+ if (rating >= 1) {
178
+ rating--;
179
+ } else if (rating > 0) {
180
+ const width = Math.asin(2 * rating - 1) / Math.PI + 0.5;
181
+ $star.css('width', width + 'rem');
182
+ rating = 0;
183
+ } else {
184
+ $star.css('width', '0rem');
185
+ }
186
+ });
187
+ });
188
+ },
189
+
190
+ dispatchWidgetEvent(eventName, payload) {
191
+ return new Promise(function (resolve, reject) {
192
+ const eventDetail = { resolve, reject };
193
+ const event = createEvent(eventName, payload, eventDetail);
194
+
195
+ window.dispatchEvent(event);
196
+ });
197
+ },
198
+
199
+ reapplyVatDisplay() {
200
+ if (!Wick.VatToggle || typeof Wick.VatToggle.isActive !== 'function') {
201
+ return;
202
+ }
203
+
204
+ const { vatInc, vatExc } = Wick.BloomreachWidget.el;
205
+ const hiddenClassName = Wick.VatToggle.HIDDEN_CLASS_NAME || 'd-none';
206
+ const isExcVatActive = Wick.VatToggle.isActive();
207
+
208
+ $(vatInc).toggleClass(hiddenClassName, isExcVatActive);
209
+ $(vatExc).toggleClass(hiddenClassName, !isExcVatActive);
210
+ },
211
+
212
+ bindVatToggle(namespace) {
213
+ if (!Wick.VatToggle || !Wick.VatToggle.TOGGLE_VAT_EVENT_NAME) {
214
+ return;
215
+ }
216
+
217
+ const eventName = `${Wick.VatToggle.TOGGLE_VAT_EVENT_NAME}.${namespace}`;
218
+
219
+ $(window).off(eventName).on(eventName, Wick.BloomreachWidget.reapplyVatDisplay);
220
+ },
221
+
222
+ formatPrice(value) {
223
+ return new Intl.NumberFormat('en-GB', {
224
+ style: 'currency',
225
+ currency: 'GBP',
226
+ minimumFractionDigits: 2,
227
+ maximumFractionDigits: 2,
228
+ }).format(value);
229
+ },
230
+ };
231
+
232
+ Wick.BloomreachWidget.registerWidgets([
233
+ {
234
+ type: 'completeYourProject',
235
+ widget: CompleteYourProjectWidget,
236
+ },
237
+ {
238
+ type: 'whyNotAdd',
239
+ widget: WhyNotAddWidget,
240
+ },
241
+ ]);