wickes-css2 2.113.0-develop.1 → 2.113.0-develop.11

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 (267) hide show
  1. package/build/css/category-main.css +1 -1
  2. package/build/css/components/global-search.css +1 -1
  3. package/build/css/components/price-block-v2-critical.css +1 -1
  4. package/build/css/components/price-block-v2.css +1 -1
  5. package/build/css/components/store-locator-facilities.css +1 -1
  6. package/build/css/components/store-locator-lookup.css +1 -1
  7. package/build/css/components/tile-calculator.css +1 -1
  8. package/build/css/homepage-main.css +1 -1
  9. package/build/css/kitchen-plp-main.css +1 -1
  10. package/build/css/main.css +1 -1
  11. package/build/css/my-account-main-v2.css +1 -1
  12. package/build/css/my-account-main.css +1 -1
  13. package/build/css/pages/checkout-new.css +1 -1
  14. package/build/css/pages/checkout.css +1 -1
  15. package/build/css/pages/my-account-v2.css +1 -1
  16. package/build/css/pages/my-account.css +1 -1
  17. package/build/css/pages/page_address-book.css +1 -1
  18. package/build/css/pages/page_checkout_delivery-new.css +1 -1
  19. package/build/css/pages/page_default-store.css +1 -1
  20. package/build/css/pages/page_discount.css +1 -1
  21. package/build/css/pages/page_fi.css +1 -1
  22. package/build/css/pages/page_in-store-checkout.css +1 -1
  23. package/build/css/pages/page_merged-basket.css +1 -1
  24. package/build/css/pages/page_my-order.css +1 -1
  25. package/build/css/pages/page_my-orders.css +1 -1
  26. package/build/css/pages/page_product-details-critical.css +1 -1
  27. package/build/css/pages/page_product-details-v2-critical.css +1 -1
  28. package/build/css/pages/page_product-details-v2.css +1 -1
  29. package/build/css/pages/page_product-details.css +1 -1
  30. package/build/css/pages/page_shopping-cart-v2.css +1 -1
  31. package/build/css/pages/page_store-locator-details.css +1 -1
  32. package/build/css/pages/page_store-locator.css +1 -1
  33. package/build/css/pages/page_ti.css +1 -1
  34. package/build/css/pages/tradePro-discount.css +1 -1
  35. package/build/css/pages/tradePro-rewards-old.css +1 -1
  36. package/build/css/pages/tradePro-rewards.css +1 -1
  37. package/build/css/pdp-main-before-combine.css +1 -1
  38. package/build/css/pdp-main-critical.css +1 -1
  39. package/build/css/pdp-main-non-critical.css +1 -1
  40. package/build/css/pdp-main.css +1 -1
  41. package/build/css/plp-main.css +1 -1
  42. package/build/css/shopping-list-pdf.css +1 -1
  43. package/build/css/store-locator-main.css +1 -1
  44. package/build/img/emulation/low-trees.png +0 -0
  45. package/build/img/emulation/overhead-power-cables.png +0 -0
  46. package/build/img/emulation/parked-vehicles.png +0 -0
  47. package/build/img/emulation/traffic-access-issues.png +0 -0
  48. package/build/img/emulation/walls-or-fences.png +0 -0
  49. package/build/js/account-members.min.js +1 -1
  50. package/build/js/add-project-list-id.min.js +1 -1
  51. package/build/js/address-book.min.js +1 -1
  52. package/build/js/basket.min.js +2 -2
  53. package/build/js/bloomreach-widget.min.js +1 -1
  54. package/build/js/bundle.min.js +1 -1
  55. package/build/js/change-password.min.js +1 -1
  56. package/build/js/checkout.min.js +2 -2
  57. package/build/js/emulation.min.js +456 -3270
  58. package/build/js/general.bundle.min.js +1 -1
  59. package/build/js/gift-cards.min.js +1 -1
  60. package/build/js/kitchen/kitchen-plp.min.js +1 -1
  61. package/build/js/merged-checkout.min.js +2 -2
  62. package/build/js/package-bulk-add.min.js +1 -0
  63. package/build/js/page/bloomreach-widget/bloomreach-recommendation-carousel-widget.js +318 -0
  64. package/build/js/page/bloomreach-widget/bloomreach-widget-core.js +370 -0
  65. package/build/js/page/bloomreach-widget/bloomreach-widget-tracking.js +16 -13
  66. package/build/js/page/bloomreach-widget/bloomreach-widget.js +8 -237
  67. package/build/js/page/bloomreach-widget/complete-your-project/cards.js +308 -0
  68. package/build/js/page/bloomreach-widget/complete-your-project/config.js +60 -0
  69. package/build/js/page/bloomreach-widget/complete-your-project/model.js +140 -0
  70. package/build/js/page/bloomreach-widget/complete-your-project/presenter.js +69 -0
  71. package/build/js/page/bloomreach-widget/complete-your-project/quantity.js +80 -0
  72. package/build/js/page/bloomreach-widget/complete-your-project/view.js +179 -0
  73. package/build/js/page/bloomreach-widget/complete-your-project/widget.js +185 -0
  74. package/build/js/page/bloomreach-widget/dont-forget-widget.js +15 -0
  75. package/build/js/page/bloomreach-widget/why-not-add-widget.js +10 -228
  76. package/build/js/page/plp-load-more.js +81 -66
  77. package/build/js/page/ripple/bulk-add.js +71 -0
  78. package/build/js/page/ripple/package-bulk-add.js +43 -0
  79. package/build/js/page/ripple/postcode-checker.js +83 -0
  80. package/build/js/page/ripple/thumb-gallery.js +168 -0
  81. package/build/js/page/utils/validation.js +1 -1
  82. package/build/js/pdp.bundle.min.js +2 -2
  83. package/build/js/personal-details.min.js +1 -1
  84. package/build/js/plp.bundle.min.js +1 -1
  85. package/build/js/postcode-checker.min.js +1 -0
  86. package/build/js/project-list.min.js +2 -2
  87. package/build/js/quiz.min.js +1 -1
  88. package/build/js/track-my-order.min.js +1 -1
  89. package/package.json +4 -2
  90. package/src/badges-ripple.html +120 -0
  91. package/src/badges.html +9 -18
  92. package/src/components/base/button.hbs +7 -0
  93. package/src/components/bloomreach/complete-your-project-skeleton.hbs +21 -0
  94. package/src/components/bloomreach/complete-your-project.hbs +6 -21
  95. package/src/components/bloomreach/why-not-add-card-skeleton.hbs +2 -2
  96. package/src/components/bloomreach/why-not-add-card.hbs +79 -60
  97. package/src/components/bloomreach/why-not-add-content.hbs +3 -3
  98. package/src/components/bloomreach/why-not-add.hbs +1 -1
  99. package/src/components/date-selection.hbs +19 -10
  100. package/src/components/fulfilment-accordions.hbs +1 -1
  101. package/src/components/heavy-banners-wrapper.hbs +21 -0
  102. package/src/components/image-accordion.hbs +18 -0
  103. package/src/components/kitchen/price.hbs +49 -29
  104. package/src/components/kitchen/strip-stickers.hbs +9 -3
  105. package/src/components/package-card.hbs +30 -0
  106. package/src/components/pdp-price-actions.hbs +17 -0
  107. package/src/components/postcode-checker.hbs +24 -0
  108. package/src/components/price-badges.hbs +12 -10
  109. package/src/components/price-block-v2.hbs +274 -202
  110. package/src/components/product-main-info-v2.hbs +2 -0
  111. package/src/components/suite-includes.hbs +66 -0
  112. package/src/components/suite-product-card.hbs +47 -0
  113. package/src/components/thumb-gallery.hbs +23 -0
  114. package/src/data/data_badges.json +143 -0
  115. package/src/data/data_bathroom-plp.json +814 -0
  116. package/src/data/data_heavy-banner.json +29 -0
  117. package/src/data/data_suite-includes-products.json +134 -0
  118. package/src/data/my-account/data_my-account.json +1 -1
  119. package/src/data/my-account/data_my-order.json +1 -1
  120. package/src/data/my-account/data_my-orders.json +1 -1
  121. package/src/img/emulation/low-trees.png +0 -0
  122. package/src/img/emulation/overhead-power-cables.png +0 -0
  123. package/src/img/emulation/parked-vehicles.png +0 -0
  124. package/src/img/emulation/traffic-access-issues.png +0 -0
  125. package/src/img/emulation/walls-or-fences.png +0 -0
  126. package/src/js/components/banner-placement-manager.js +25 -9
  127. package/src/js/components/general/cart-slider.js +41 -4
  128. package/src/js/components/general/image-accordion.js +54 -0
  129. package/src/js/components/general/switchVat.js +8 -1
  130. package/src/js/components/package-card.js +69 -0
  131. package/src/js/components/store-locator-cards.js +76 -0
  132. package/src/js/emulation/banner-placement-manager.js +219 -188
  133. package/src/js/emulation/complete-your-project-loading.js +16 -0
  134. package/src/js/emulation/custom-slider-emulation.js +21 -8
  135. package/src/js/emulation/date-selection.js +2 -2
  136. package/src/js/emulation/dont-forget-loading.js +36 -0
  137. package/src/js/emulation/just-added-scenarios-emulation.js +131 -0
  138. package/src/js/emulation/mini-basket.js +34 -34
  139. package/src/js/emulation/mock.js +429 -4
  140. package/src/js/emulation/plp-load-more.js +13 -4
  141. package/src/js/emulation/postcode-checker.js +11 -0
  142. package/src/js/emulation/why-not-add-loading.js +14 -3
  143. package/src/js/emulation/why-not-add.js +12 -14
  144. package/src/js/page/bloomreach-widget/bloomreach-recommendation-carousel-widget.js +318 -0
  145. package/src/js/page/bloomreach-widget/bloomreach-widget-core.js +370 -0
  146. package/src/js/page/bloomreach-widget/bloomreach-widget-tracking.js +16 -13
  147. package/src/js/page/bloomreach-widget/bloomreach-widget.js +8 -237
  148. package/src/js/page/bloomreach-widget/complete-your-project/cards.js +308 -0
  149. package/src/js/page/bloomreach-widget/complete-your-project/config.js +60 -0
  150. package/src/js/page/bloomreach-widget/complete-your-project/model.js +140 -0
  151. package/src/js/page/bloomreach-widget/complete-your-project/presenter.js +69 -0
  152. package/src/js/page/bloomreach-widget/complete-your-project/quantity.js +80 -0
  153. package/src/js/page/bloomreach-widget/complete-your-project/view.js +179 -0
  154. package/src/js/page/bloomreach-widget/complete-your-project/widget.js +185 -0
  155. package/src/js/page/bloomreach-widget/dont-forget-widget.js +15 -0
  156. package/src/js/page/bloomreach-widget/why-not-add-widget.js +10 -228
  157. package/src/js/page/plp-load-more.js +81 -66
  158. package/src/js/page/ripple/bulk-add.js +71 -0
  159. package/src/js/page/ripple/package-bulk-add.js +43 -0
  160. package/src/js/page/ripple/postcode-checker.js +83 -0
  161. package/src/js/page/ripple/thumb-gallery.js +168 -0
  162. package/src/js/page/utils/validation.js +1 -1
  163. package/src/page_bathroom-plp-vat.html +81 -0
  164. package/src/page_bathroom-plp-without-load-more.html +83 -0
  165. package/src/page_bathroom-plp.html +98 -0
  166. package/src/page_checkout_big-bulky-delivery-details.html +272 -0
  167. package/src/page_checkout_premium-delivery-details.html +2 -2
  168. package/src/page_product-details-banner.html +1 -3
  169. package/src/page_product-details-big-wins-disabled-delivery.html +1 -3
  170. package/src/page_product-details-big-wins-non-registered.html +1 -3
  171. package/src/page_product-details-big-wins-out-nearest.html +1 -3
  172. package/src/page_product-details-big-wins-unhappy.html +1 -3
  173. package/src/page_product-details-big-wins.html +1 -3
  174. package/src/page_product-details-billie.html +1 -3
  175. package/src/page_product-details-calculator.html +1 -3
  176. package/src/page_product-details-cashback-v2.html +1 -3
  177. package/src/page_product-details-clearpay.html +1 -3
  178. package/src/page_product-details-cnc-error-notification.html +1 -3
  179. package/src/page_product-details-cnc-success-notification-vat.html +1 -4
  180. package/src/page_product-details-cnc-success-notification.html +1 -3
  181. package/src/page_product-details-default-store.html +1 -3
  182. package/src/page_product-details-energy-efficiency.html +1 -3
  183. package/src/page_product-details-flooring-with-pr-placeholder.html +1 -3
  184. package/src/page_product-details-flooring.html +1 -3
  185. package/src/page_product-details-gallery-actual.html +1 -3
  186. package/src/page_product-details-mfe-calculator.html +1 -3
  187. package/src/page_product-details-mtm-doors.html +1 -3
  188. package/src/page_product-details-only-clearpay.html +1 -3
  189. package/src/page_product-details-paint-mixing.html +1 -3
  190. package/src/page_product-details-ripple-gallery.html +121 -0
  191. package/src/page_product-details-saved-pl.html +1 -3
  192. package/src/page_product-details-suite-includes-banners.html +139 -0
  193. package/src/page_product-details-suite-includes-billie.html +128 -0
  194. package/src/page_product-details-suite-includes-klarna.html +120 -0
  195. package/src/page_product-details-suite-includes-vat.html +126 -0
  196. package/src/page_product-details-suite-includes.html +122 -0
  197. package/src/page_product-details-tile-steps-klarna-widget-with-method-ids.html +1 -3
  198. package/src/page_product-details-tile-steps-logout.html +1 -3
  199. package/src/page_product-details-tile-steps-no-new-project-list.html +1 -3
  200. package/src/page_product-details-tile-steps-with-klarna.html +1 -3
  201. package/src/page_product-details-tile-steps.html +1 -3
  202. package/src/page_product-details-v2.html +1 -3
  203. package/src/page_product-details-vat.html +1 -3
  204. package/src/page_product-details-wisdom-mcfc-registered.html +1 -3
  205. package/src/page_product-details-wisdom-mcfc.html +1 -3
  206. package/src/page_product-details-wisdom-oos-registered.html +1 -3
  207. package/src/page_product-details-wisdom-oos.html +1 -3
  208. package/src/page_product-details-wisdom-registered.html +1 -3
  209. package/src/page_product-details-wisdom.html +1 -3
  210. package/src/page_product-details-with-favourite.html +1 -3
  211. package/src/page_product-details-with-global-search-v2.html +6 -9
  212. package/src/page_product-details-with-why-not-add-single.html +2 -1
  213. package/src/page_product-details_no-previous-default.html +1 -3
  214. package/src/scss/components/_cards-slider.scss +3 -1
  215. package/src/scss/components/_checkout_order.scss +2 -1
  216. package/src/scss/components/_date-selection-add-new-styles.scss +29 -0
  217. package/src/scss/components/_heavy-banners.scss +216 -0
  218. package/src/scss/components/_image-accordion.scss +54 -0
  219. package/src/scss/components/_kitchen-card.scss +1 -0
  220. package/src/scss/components/_lines-group.scss +1 -1
  221. package/src/scss/components/_package-card.scss +63 -0
  222. package/src/scss/components/_package-plp.scss +88 -0
  223. package/src/scss/components/_postcode-checker.scss +115 -0
  224. package/src/scss/components/_price-badges-critical.scss +10 -0
  225. package/src/scss/components/_price-badges.scss +10 -0
  226. package/src/scss/components/_price-block-critical.scss +1 -0
  227. package/src/scss/components/_price-block.scss +1 -0
  228. package/src/scss/components/_sticky-element-appearance.scss +6 -2
  229. package/src/scss/components/_suite-includes.scss +141 -0
  230. package/src/scss/components/_suite-product-card.scss +98 -0
  231. package/src/scss/components/_thumb-gallery-critical.scss +34 -0
  232. package/src/scss/components/_thumb-gallery.scss +192 -0
  233. package/src/scss/components/bloomreach/_bloomreach.scss +1 -0
  234. package/src/scss/components/bloomreach/_card-shared.scss +24 -0
  235. package/src/scss/components/bloomreach/_complete-card.scss +1 -9
  236. package/src/scss/components/bloomreach/_reviews.scss +0 -2
  237. package/src/scss/components/bloomreach/_why-not-add-card.scss +137 -10
  238. package/src/scss/components/bloomreach/_why-not-add.scss +31 -2
  239. package/src/scss/components/energy-efficiency.scss +2 -2
  240. package/src/scss/components/global-search.scss +6 -2
  241. package/src/scss/components/kitchen/_price.scss +10 -0
  242. package/src/scss/components/kitchen/_strip-stickers.scss +46 -0
  243. package/src/scss/components/my-account/_active-orders.scss +9 -9
  244. package/src/scss/components/price-block-v2-critical.scss +58 -0
  245. package/src/scss/components/price-block-v2.scss +58 -0
  246. package/src/scss/helpers/helpers-pdp-critical/_helpers-critical-pdp.scss +13 -8
  247. package/src/scss/libs/_bootstrap-extracted.scss +5 -0
  248. package/src/scss/main.scss +1 -0
  249. package/src/scss/pages/iframe-paypage.scss +9 -11
  250. package/src/scss/pages/page_checkout_delivery-new.scss +4 -0
  251. package/src/scss/pages/page_cms_homepage.scss +10 -4
  252. package/src/scss/pages/page_installation.scss +2 -2
  253. package/src/scss/pages/page_online-exclusive.scss +7 -3
  254. package/src/scss/pages/page_product-details-v2-critical.scss +216 -109
  255. package/src/scss/pages/page_product-details-v2.scss +168 -107
  256. package/src/scss/pages/page_product-details.scss +11 -0
  257. package/src/scss/pages/page_top-rated.scss +38 -23
  258. package/src/scss/pdp-main-critical.scss +1 -0
  259. package/src/scss/pdp-main.scss +6 -0
  260. package/src/scss/plp-main.scss +5 -0
  261. package/src/sitemap.html +15 -0
  262. package/build/css/components/kitchen/strip-stickers.css +0 -1
  263. package/build/css/components/strip-stickers.css +0 -1
  264. package/build/js/page/bloomreach-widget/complete-your-project-widget.js +0 -1100
  265. package/src/js/page/bloomreach-widget/complete-your-project-widget.js +0 -1100
  266. package/src/scss/components/kitchen/strip-stickers.scss +0 -18
  267. package/src/scss/components/strip-stickers.scss +0 -18
@@ -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
  ]);