wickes-css2 2.113.0-develop.2 → 2.113.0-develop.20

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 (301) hide show
  1. package/Readme.md +1 -2
  2. package/build/css/category-main.css +1 -1
  3. package/build/css/components/checkout-payment-details-v2.css +1 -1
  4. package/build/css/components/checkout-payment-repayment-terms.css +1 -1
  5. package/build/css/components/global-search.css +1 -1
  6. package/build/css/components/price-block-v2-critical.css +1 -1
  7. package/build/css/components/price-block-v2.css +1 -1
  8. package/build/css/components/store-locator-facilities.css +1 -1
  9. package/build/css/components/store-locator-lookup.css +1 -1
  10. package/build/css/components/tile-calculator.css +1 -1
  11. package/build/css/homepage-main.css +1 -1
  12. package/build/css/kitchen-plp-main.css +1 -1
  13. package/build/css/main.css +1 -1
  14. package/build/css/my-account-main-v2.css +1 -1
  15. package/build/css/my-account-main.css +1 -1
  16. package/build/css/pages/checkout-new.css +1 -1
  17. package/build/css/pages/checkout.css +1 -1
  18. package/build/css/pages/my-account-v2.css +1 -1
  19. package/build/css/pages/my-account.css +1 -1
  20. package/build/css/pages/page_address-book.css +1 -1
  21. package/build/css/pages/page_checkout_delivery-new.css +1 -1
  22. package/build/css/pages/page_default-store.css +1 -1
  23. package/build/css/pages/page_discount.css +1 -1
  24. package/build/css/pages/page_fi.css +1 -1
  25. package/build/css/pages/page_in-store-checkout.css +1 -1
  26. package/build/css/pages/page_merged-basket.css +1 -1
  27. package/build/css/pages/page_my-order.css +1 -1
  28. package/build/css/pages/page_my-orders.css +1 -1
  29. package/build/css/pages/page_product-details-critical.css +1 -1
  30. package/build/css/pages/page_product-details-v2-critical.css +1 -1
  31. package/build/css/pages/page_product-details-v2.css +1 -1
  32. package/build/css/pages/page_product-details.css +1 -1
  33. package/build/css/pages/page_products-list-combined.css +1 -1
  34. package/build/css/pages/page_products-list_v2.css +1 -1
  35. package/build/css/pages/page_shopping-cart-v2.css +1 -1
  36. package/build/css/pages/page_store-locator-details.css +1 -1
  37. package/build/css/pages/page_store-locator.css +1 -1
  38. package/build/css/pages/page_ti.css +1 -1
  39. package/build/css/pages/tradePro-discount.css +1 -1
  40. package/build/css/pages/tradePro-rewards-old.css +1 -1
  41. package/build/css/pages/tradePro-rewards.css +1 -1
  42. package/build/css/pdp-main-before-combine.css +1 -1
  43. package/build/css/pdp-main-critical.css +1 -1
  44. package/build/css/pdp-main-non-critical.css +1 -1
  45. package/build/css/pdp-main.css +1 -1
  46. package/build/css/plp-main.css +1 -1
  47. package/build/css/shopping-list-pdf.css +1 -1
  48. package/build/css/store-locator-main.css +1 -1
  49. package/build/img/emulation/low-trees.png +0 -0
  50. package/build/img/emulation/overhead-power-cables.png +0 -0
  51. package/build/img/emulation/parked-vehicles.png +0 -0
  52. package/build/img/emulation/traffic-access-issues.png +0 -0
  53. package/build/img/emulation/walls-or-fences.png +0 -0
  54. package/build/js/account-members.min.js +1 -1
  55. package/build/js/add-project-list-id.min.js +1 -1
  56. package/build/js/address-book.min.js +1 -1
  57. package/build/js/basket.min.js +2 -2
  58. package/build/js/bloomreach-widget.min.js +1 -1
  59. package/build/js/bundle.min.js +1 -1
  60. package/build/js/change-password.min.js +1 -1
  61. package/build/js/checkout.min.js +2 -2
  62. package/build/js/emulation.min.js +477 -3271
  63. package/build/js/general.bundle.min.js +1 -1
  64. package/build/js/gift-cards.min.js +1 -1
  65. package/build/js/kitchen/kitchen-plp.min.js +1 -1
  66. package/build/js/merged-checkout.min.js +2 -2
  67. package/build/js/package-bulk-add.min.js +1 -0
  68. package/build/js/page/bloomreach-widget/bloomreach-recommendation-carousel-widget.js +319 -0
  69. package/build/js/page/bloomreach-widget/bloomreach-widget-core.js +390 -0
  70. package/build/js/page/bloomreach-widget/bloomreach-widget-tracking.js +16 -13
  71. package/build/js/page/bloomreach-widget/bloomreach-widget.js +13 -237
  72. package/build/js/page/bloomreach-widget/complete-your-project/cards.js +308 -0
  73. package/build/js/page/bloomreach-widget/complete-your-project/config.js +60 -0
  74. package/build/js/page/bloomreach-widget/complete-your-project/model.js +140 -0
  75. package/build/js/page/bloomreach-widget/complete-your-project/presenter.js +69 -0
  76. package/build/js/page/bloomreach-widget/complete-your-project/quantity.js +80 -0
  77. package/build/js/page/bloomreach-widget/complete-your-project/view.js +184 -0
  78. package/build/js/page/bloomreach-widget/complete-your-project/widget.js +184 -0
  79. package/build/js/page/bloomreach-widget/dont-forget-widget.js +15 -0
  80. package/build/js/page/bloomreach-widget/similar-products-widget.js +17 -0
  81. package/build/js/page/bloomreach-widget/why-not-add-widget.js +10 -228
  82. package/build/js/page/plp-load-more.js +81 -66
  83. package/build/js/page/ripple/bulk-add.js +71 -0
  84. package/build/js/page/ripple/package-bulk-add.js +43 -0
  85. package/build/js/page/ripple/postcode-checker.js +83 -0
  86. package/build/js/page/ripple/thumb-gallery.js +236 -0
  87. package/build/js/page/utils/validation.js +1 -1
  88. package/build/js/pdp.bundle.min.js +2 -2
  89. package/build/js/personal-details.min.js +1 -1
  90. package/build/js/plp.bundle.min.js +1 -1
  91. package/build/js/postcode-checker.min.js +1 -0
  92. package/build/js/project-list.min.js +2 -2
  93. package/build/js/quiz.min.js +1 -1
  94. package/build/js/track-my-order.min.js +1 -1
  95. package/package.json +4 -2
  96. package/src/badges-ripple.html +120 -0
  97. package/src/badges.html +9 -18
  98. package/src/components/base/button.hbs +7 -0
  99. package/src/components/bloomreach/complete-card.hbs +1 -1
  100. package/src/components/bloomreach/complete-your-project-skeleton.hbs +21 -0
  101. package/src/components/bloomreach/complete-your-project.hbs +6 -21
  102. package/src/components/bloomreach/why-not-add-card-skeleton.hbs +2 -2
  103. package/src/components/bloomreach/why-not-add-card.hbs +98 -60
  104. package/src/components/bloomreach/why-not-add-content.hbs +3 -3
  105. package/src/components/bloomreach/why-not-add.hbs +2 -2
  106. package/src/components/date-selection.hbs +19 -10
  107. package/src/components/fulfilment-accordions.hbs +1 -1
  108. package/src/components/heavy-banners-wrapper.hbs +21 -0
  109. package/src/components/image-accordion.hbs +18 -0
  110. package/src/components/kitchen/price.hbs +49 -29
  111. package/src/components/kitchen/strip-stickers.hbs +9 -3
  112. package/src/components/package-card.hbs +30 -0
  113. package/src/components/pdp-price-actions.hbs +17 -0
  114. package/src/components/postcode-checker.hbs +24 -0
  115. package/src/components/price-badges.hbs +12 -10
  116. package/src/components/price-block-v2.hbs +289 -199
  117. package/src/components/product-main-info-v2.hbs +2 -0
  118. package/src/components/suite-includes.hbs +66 -0
  119. package/src/components/suite-product-card.hbs +47 -0
  120. package/src/components/thumb-gallery.hbs +23 -0
  121. package/src/data/data_badges.json +143 -0
  122. package/src/data/data_bathroom-plp.json +814 -0
  123. package/src/data/data_heavy-banner.json +29 -0
  124. package/src/data/data_suite-includes-products.json +134 -0
  125. package/src/data/my-account/data_my-account.json +1 -1
  126. package/src/data/my-account/data_my-order.json +1 -1
  127. package/src/data/my-account/data_my-orders.json +1 -1
  128. package/src/img/emulation/low-trees.png +0 -0
  129. package/src/img/emulation/overhead-power-cables.png +0 -0
  130. package/src/img/emulation/parked-vehicles.png +0 -0
  131. package/src/img/emulation/traffic-access-issues.png +0 -0
  132. package/src/img/emulation/walls-or-fences.png +0 -0
  133. package/src/js/components/banner-placement-manager.js +25 -9
  134. package/src/js/components/general/cart-slider.js +41 -4
  135. package/src/js/components/general/image-accordion.js +54 -0
  136. package/src/js/components/general/switchVat.js +8 -1
  137. package/src/js/components/package-card.js +69 -0
  138. package/src/js/components/store-locator-cards.js +76 -0
  139. package/src/js/emulation/banner-placement-manager.js +219 -188
  140. package/src/js/emulation/bloomreach-widget-calculations.js +1 -1
  141. package/src/js/emulation/complete-your-project-loading.js +16 -0
  142. package/src/js/emulation/custom-slider-emulation.js +21 -8
  143. package/src/js/emulation/date-selection.js +2 -2
  144. package/src/js/emulation/dont-forget-loading.js +36 -0
  145. package/src/js/emulation/just-added-scenarios-emulation.js +131 -0
  146. package/src/js/emulation/mini-basket.js +34 -34
  147. package/src/js/emulation/mock.js +495 -38
  148. package/src/js/emulation/plp-load-more.js +13 -4
  149. package/src/js/emulation/postcode-checker.js +11 -0
  150. package/src/js/emulation/similar-products-loading.js +22 -0
  151. package/src/js/emulation/why-not-add-loading.js +14 -3
  152. package/src/js/emulation/why-not-add.js +12 -14
  153. package/src/js/page/bloomreach-widget/bloomreach-recommendation-carousel-widget.js +319 -0
  154. package/src/js/page/bloomreach-widget/bloomreach-widget-core.js +390 -0
  155. package/src/js/page/bloomreach-widget/bloomreach-widget-tracking.js +16 -13
  156. package/src/js/page/bloomreach-widget/bloomreach-widget.js +13 -237
  157. package/src/js/page/bloomreach-widget/complete-your-project/cards.js +308 -0
  158. package/src/js/page/bloomreach-widget/complete-your-project/config.js +60 -0
  159. package/src/js/page/bloomreach-widget/complete-your-project/model.js +140 -0
  160. package/src/js/page/bloomreach-widget/complete-your-project/presenter.js +69 -0
  161. package/src/js/page/bloomreach-widget/complete-your-project/quantity.js +80 -0
  162. package/src/js/page/bloomreach-widget/complete-your-project/view.js +184 -0
  163. package/src/js/page/bloomreach-widget/complete-your-project/widget.js +184 -0
  164. package/src/js/page/bloomreach-widget/dont-forget-widget.js +15 -0
  165. package/src/js/page/bloomreach-widget/similar-products-widget.js +17 -0
  166. package/src/js/page/bloomreach-widget/why-not-add-widget.js +10 -228
  167. package/src/js/page/plp-load-more.js +81 -66
  168. package/src/js/page/ripple/bulk-add.js +71 -0
  169. package/src/js/page/ripple/package-bulk-add.js +43 -0
  170. package/src/js/page/ripple/postcode-checker.js +83 -0
  171. package/src/js/page/ripple/thumb-gallery.js +236 -0
  172. package/src/js/page/utils/validation.js +1 -1
  173. package/src/page_bathroom-plp-vat.html +81 -0
  174. package/src/page_bathroom-plp-without-load-more.html +83 -0
  175. package/src/page_bathroom-plp.html +98 -0
  176. package/src/page_checkout_big-bulky-delivery-details.html +272 -0
  177. package/src/page_checkout_delivery-details-v2-calendar-not-loaded.html +167 -0
  178. package/src/page_checkout_payment-details-v2-asm.html +2 -3
  179. package/src/page_checkout_payment-details-v2.html +2 -3
  180. package/src/page_checkout_payment-details_with-card-loader.html +2 -3
  181. package/src/page_checkout_payment-details_with-klarna-loader.html +2 -3
  182. package/src/page_checkout_payment-details_with-loader-v2.html +2 -3
  183. package/src/page_checkout_premium-delivery-details.html +2 -2
  184. package/src/page_klarna_payment-details_with-klarna.html +2 -3
  185. package/src/page_payment-details-billie-registered-only.html +2 -3
  186. package/src/page_payment-details-billie-unregistered-only.html +2 -3
  187. package/src/page_payment-details-with-billie.html +2 -3
  188. package/src/page_payment-details-with-clearpay.html +2 -3
  189. package/src/page_payment-details-with-gift-card.html +2 -3
  190. package/src/page_payment-details_with_apple-pay.html +0 -1
  191. package/src/page_payment-details_with_google-pay.html +2 -3
  192. package/src/page_product-details-banner.html +1 -3
  193. package/src/page_product-details-big-wins-disabled-delivery.html +1 -3
  194. package/src/page_product-details-big-wins-non-registered.html +1 -3
  195. package/src/page_product-details-big-wins-out-nearest.html +1 -3
  196. package/src/page_product-details-big-wins-unhappy.html +1 -3
  197. package/src/page_product-details-big-wins.html +1 -3
  198. package/src/page_product-details-billie.html +1 -3
  199. package/src/page_product-details-calculator.html +1 -3
  200. package/src/page_product-details-cashback-v2.html +1 -3
  201. package/src/page_product-details-clearpay.html +1 -3
  202. package/src/page_product-details-cnc-error-notification.html +1 -3
  203. package/src/page_product-details-cnc-success-notification-vat.html +1 -4
  204. package/src/page_product-details-cnc-success-notification.html +1 -3
  205. package/src/page_product-details-default-store.html +1 -3
  206. package/src/page_product-details-energy-efficiency.html +1 -3
  207. package/src/page_product-details-flooring-with-pr-placeholder.html +1 -3
  208. package/src/page_product-details-flooring.html +1 -3
  209. package/src/page_product-details-gallery-actual.html +1 -3
  210. package/src/page_product-details-mfe-calculator.html +1 -3
  211. package/src/page_product-details-mtm-doors.html +1 -3
  212. package/src/page_product-details-only-clearpay.html +1 -3
  213. package/src/page_product-details-paint-mixing.html +1 -3
  214. package/src/page_product-details-ripple-gallery-1-image.html +120 -0
  215. package/src/page_product-details-ripple-gallery-missing-image.html +121 -0
  216. package/src/page_product-details-ripple-gallery.html +121 -0
  217. package/src/page_product-details-saved-pl.html +1 -3
  218. package/src/page_product-details-suite-includes-banners.html +139 -0
  219. package/src/page_product-details-suite-includes-billie.html +128 -0
  220. package/src/page_product-details-suite-includes-klarna.html +120 -0
  221. package/src/page_product-details-suite-includes-vat.html +126 -0
  222. package/src/page_product-details-suite-includes.html +122 -0
  223. package/src/page_product-details-tile-steps-klarna-widget-with-method-ids.html +1 -3
  224. package/src/page_product-details-tile-steps-logout.html +1 -3
  225. package/src/page_product-details-tile-steps-no-new-project-list.html +1 -3
  226. package/src/page_product-details-tile-steps-with-klarna.html +1 -3
  227. package/src/page_product-details-tile-steps.html +1 -3
  228. package/src/page_product-details-v2.html +1 -3
  229. package/src/page_product-details-vat.html +1 -3
  230. package/src/page_product-details-wisdom-mcfc-registered.html +1 -3
  231. package/src/page_product-details-wisdom-mcfc.html +1 -3
  232. package/src/page_product-details-wisdom-oos-registered.html +1 -3
  233. package/src/page_product-details-wisdom-oos.html +1 -3
  234. package/src/page_product-details-wisdom-registered.html +1 -3
  235. package/src/page_product-details-wisdom.html +1 -3
  236. package/src/page_product-details-with-favourite.html +1 -3
  237. package/src/page_product-details-with-global-search-v2.html +6 -9
  238. package/src/page_product-details-with-similar-products-widget.html +132 -0
  239. package/src/page_product-details-with-why-not-add-single.html +2 -1
  240. package/src/page_product-details_no-previous-default.html +1 -3
  241. package/src/scss/common/_loading-button.scss +3 -1
  242. package/src/scss/components/_cards-slider.scss +3 -1
  243. package/src/scss/components/_checkout_order.scss +2 -1
  244. package/src/scss/components/_date-selection-add-new-styles.scss +53 -3
  245. package/src/scss/components/_gift-cards.scss +1 -1
  246. package/src/scss/components/_heavy-banners.scss +216 -0
  247. package/src/scss/components/_image-accordion.scss +54 -0
  248. package/src/scss/components/_kitchen-card.scss +1 -0
  249. package/src/scss/components/_map.scss +38 -0
  250. package/src/scss/components/_package-card.scss +65 -0
  251. package/src/scss/components/_package-plp.scss +88 -0
  252. package/src/scss/components/_postcode-checker.scss +115 -0
  253. package/src/scss/components/_price-badges-critical.scss +10 -0
  254. package/src/scss/components/_price-badges.scss +10 -0
  255. package/src/scss/components/_price-block-critical.scss +1 -0
  256. package/src/scss/components/_price-block.scss +1 -0
  257. package/src/scss/components/_sticky-element-appearance.scss +6 -2
  258. package/src/scss/components/_suite-includes.scss +141 -0
  259. package/src/scss/components/_suite-product-card.scss +98 -0
  260. package/src/scss/components/_thumb-gallery-critical.scss +35 -0
  261. package/src/scss/components/_thumb-gallery.scss +200 -0
  262. package/src/scss/components/bloomreach/_bloomreach.scss +1 -0
  263. package/src/scss/components/bloomreach/_card-shared.scss +24 -0
  264. package/src/scss/components/bloomreach/_complete-card.scss +1 -9
  265. package/src/scss/components/bloomreach/_reviews.scss +0 -2
  266. package/src/scss/components/bloomreach/_why-not-add-card.scss +137 -10
  267. package/src/scss/components/bloomreach/_why-not-add.scss +34 -3
  268. package/src/scss/components/checkout-payment-details-v2.scss +44 -20
  269. package/src/scss/components/checkout-payment-repayment-terms.scss +0 -1
  270. package/src/scss/components/energy-efficiency.scss +2 -2
  271. package/src/scss/components/global-search.scss +6 -2
  272. package/src/scss/components/kitchen/_price.scss +10 -0
  273. package/src/scss/components/kitchen/_strip-stickers.scss +46 -0
  274. package/src/scss/components/my-account/_active-orders.scss +9 -9
  275. package/src/scss/components/price-block-v2-critical.scss +62 -0
  276. package/src/scss/components/price-block-v2.scss +62 -0
  277. package/src/scss/helpers/helpers-pdp-critical/_helpers-critical-pdp.scss +13 -8
  278. package/src/scss/libs/_bootstrap-extracted.scss +5 -0
  279. package/src/scss/main.scss +1 -0
  280. package/src/scss/pages/_checkout_delivery-details.scss +16 -104
  281. package/src/scss/pages/iframe-paypage.scss +9 -11
  282. package/src/scss/pages/page_checkout_delivery-new.scss +256 -164
  283. package/src/scss/pages/page_cms_homepage.scss +10 -4
  284. package/src/scss/pages/page_installation.scss +2 -2
  285. package/src/scss/pages/page_online-exclusive.scss +7 -3
  286. package/src/scss/pages/page_product-details-v2-critical.scss +216 -109
  287. package/src/scss/pages/page_product-details-v2.scss +168 -107
  288. package/src/scss/pages/page_product-details.scss +11 -0
  289. package/src/scss/pages/page_products-list-combined.scss +8 -6
  290. package/src/scss/pages/page_products-list_v2.scss +8 -6
  291. package/src/scss/pages/page_top-rated.scss +38 -23
  292. package/src/scss/pdp-main-critical.scss +1 -0
  293. package/src/scss/pdp-main.scss +6 -0
  294. package/src/scss/plp-main.scss +5 -0
  295. package/src/sitemap.html +31 -6
  296. package/build/css/components/kitchen/strip-stickers.css +0 -1
  297. package/build/css/components/strip-stickers.css +0 -1
  298. package/build/js/page/bloomreach-widget/complete-your-project-widget.js +0 -1100
  299. package/src/js/page/bloomreach-widget/complete-your-project-widget.js +0 -1100
  300. package/src/scss/components/kitchen/strip-stickers.scss +0 -18
  301. package/src/scss/components/strip-stickers.scss +0 -18
@@ -0,0 +1,390 @@
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
+ Wick.BloomreachWidget.removeBlankTargets($container);
60
+
61
+ if (config.initRenderedWidget) {
62
+ config.initRenderedWidget($container, widget);
63
+ }
64
+ });
65
+
66
+ if (config.getViewTargets) {
67
+ tracking.observeView(config.getViewTargets($containers, widget));
68
+ }
69
+ },
70
+ };
71
+
72
+ return widget;
73
+ }
74
+
75
+ Wick.BloomreachWidget = {
76
+ widgets: {},
77
+
78
+ el: {
79
+ loadingButtonText: '.loading-button__text',
80
+ loadingButtonLoader: '.loading-button__loader',
81
+ ratingOverlay: '.rating-overlay',
82
+ starOverlay: '.star-overlay',
83
+ vatInc: '.including-vat-inherit',
84
+ vatExc: '.excluding-vat-inherit',
85
+ },
86
+
87
+ badgeColorMap: {
88
+ blue: '#019ee3',
89
+ gray: '#3e3e3e',
90
+ green: '#9acd32',
91
+ red: '#cf000f',
92
+ yellow: '#f7ca18',
93
+ },
94
+
95
+ getBadgeColor(color) {
96
+ if (!color) {
97
+ return '';
98
+ }
99
+
100
+ return Wick.BloomreachWidget.badgeColorMap[color] || color;
101
+ },
102
+
103
+ getBadge(product) {
104
+ if (!product) {
105
+ return null;
106
+ }
107
+
108
+ const promotion = product.potentialPromotions && product.potentialPromotions[0];
109
+ const promotionAttributes = promotion && promotion.customAttributes;
110
+
111
+ if (promotionAttributes && promotionAttributes.overlayText) {
112
+ return {
113
+ text: promotionAttributes.overlayText,
114
+ textColor: Wick.BloomreachWidget.getBadgeColor(
115
+ promotionAttributes.overlayTextColor
116
+ ),
117
+ color: Wick.BloomreachWidget.getBadgeColor(
118
+ promotionAttributes.overlayBackgroundColor
119
+ ),
120
+ };
121
+ }
122
+
123
+ if (product.badge && product.badge.text) {
124
+ return {
125
+ ...product.badge,
126
+ textColor: Wick.BloomreachWidget.getBadgeColor(product.badge.textColor),
127
+ color: Wick.BloomreachWidget.getBadgeColor(product.badge.color),
128
+ };
129
+ }
130
+
131
+ return product.badge || null;
132
+ },
133
+
134
+ registerWidgets(widgetList) {
135
+ widgetList.forEach(function ({ type, widget }) {
136
+ Wick.BloomreachWidget.widgets[type] = widget;
137
+ });
138
+ },
139
+
140
+ getWidget(type) {
141
+ return Wick.BloomreachWidget.widgets[type];
142
+ },
143
+
144
+ init(type, payloadData, options = {}) {
145
+ const widget = Wick.BloomreachWidget.getWidget(type);
146
+
147
+ if (!widget || typeof widget.init !== 'function') {
148
+ return;
149
+ }
150
+
151
+ widget.init(payloadData, options, Wick.BloomreachWidget);
152
+ },
153
+
154
+ normalizePayload(payloadData) {
155
+ if (Array.isArray(payloadData)) {
156
+ return payloadData;
157
+ }
158
+
159
+ if (payloadData && Array.isArray(payloadData.recommendedProducts)) {
160
+ return payloadData.recommendedProducts;
161
+ }
162
+
163
+ return [];
164
+ },
165
+
166
+ hasRecommendations(payloadData) {
167
+ return Wick.BloomreachWidget.normalizePayload(payloadData).length > 0;
168
+ },
169
+
170
+ removeBlankTargets($root) {
171
+ if (!isApp()) {
172
+ return;
173
+ }
174
+
175
+ $root.find('a[target="_blank"]').removeAttr('target');
176
+ },
177
+
178
+ getDisplayPrice(product) {
179
+ return product.displayPrice || product.price || {};
180
+ },
181
+
182
+ getDisplayPriceExcVat(product) {
183
+ return product.displayPriceExclusiveVat || product.priceExclusiveVat || null;
184
+ },
185
+
186
+ getExcVatFormattedValue(product, displayPrice) {
187
+ const excVat = Wick.BloomreachWidget.getDisplayPriceExcVat(product);
188
+
189
+ if (excVat && excVat.formattedValue) {
190
+ return excVat.formattedValue;
191
+ }
192
+
193
+ if (!displayPrice || typeof displayPrice.value !== 'number') {
194
+ return displayPrice ? displayPrice.formattedValue || '' : '';
195
+ }
196
+
197
+ const vatRate = displayPrice.vatRatePercentage || 20;
198
+
199
+ return Wick.BloomreachWidget.formatPrice(displayPrice.value / (1 + vatRate / 100));
200
+ },
201
+
202
+ getPriceValue(price) {
203
+ return price && typeof price.value === 'number' ? price.value : 0;
204
+ },
205
+
206
+ getPriceFormattedValue(price) {
207
+ if (!price) {
208
+ return '';
209
+ }
210
+
211
+ if (price.formattedValue) {
212
+ return price.formattedValue;
213
+ }
214
+
215
+ if (typeof price.value === 'number') {
216
+ return Wick.BloomreachWidget.formatPrice(price.value);
217
+ }
218
+
219
+ return '';
220
+ },
221
+
222
+ getWasPrice(product) {
223
+ const displayPrice = Wick.BloomreachWidget.getDisplayPrice(product);
224
+
225
+ return displayPrice && displayPrice.wasPrice ? displayPrice.wasPrice : null;
226
+ },
227
+
228
+ getWasPriceFormatted(product) {
229
+ return Wick.BloomreachWidget.formatPromotionalPrice(
230
+ Wick.BloomreachWidget.getWasPrice(product)
231
+ );
232
+ },
233
+
234
+ getExcVatWasPrice(product) {
235
+ const priceExclusiveVat = product.priceExclusiveVat || null;
236
+ const displayPriceExclusiveVat = product.displayPriceExclusiveVat || null;
237
+ const wasPrice =
238
+ (displayPriceExclusiveVat && displayPriceExclusiveVat.wasPrice) ||
239
+ (priceExclusiveVat && priceExclusiveVat.wasPrice);
240
+
241
+ return Wick.BloomreachWidget.formatPromotionalPrice(wasPrice);
242
+ },
243
+
244
+ getProductImage(product, fallbackProduct) {
245
+ const productImages = product.images || [];
246
+ const fallbackImages = fallbackProduct ? fallbackProduct.images || [] : [];
247
+ const images = productImages.length ? productImages : fallbackImages;
248
+
249
+ return (
250
+ images.find(function (item) {
251
+ return item.format === 'product';
252
+ }) ||
253
+ images.find(function (item) {
254
+ return item.imageType === 'PRIMARY';
255
+ }) ||
256
+ images[0] ||
257
+ {}
258
+ );
259
+ },
260
+
261
+ getProductRenderData(product, options = {}) {
262
+ const displayPrice = Wick.BloomreachWidget.getDisplayPrice(product);
263
+ const displayPriceExcVat = Wick.BloomreachWidget.getDisplayPriceExcVat(product);
264
+ const wasPriceFormatted = Wick.BloomreachWidget.getWasPriceFormatted(product);
265
+ const isSwitchVat = !!(window.ACC && window.ACC.app && window.ACC.app.isVatToggleAvailable);
266
+ const incVatFormattedValue = wasPriceFormatted
267
+ ? Wick.BloomreachWidget.formatPromotionalPrice(displayPrice)
268
+ : Wick.BloomreachWidget.getPriceFormattedValue(displayPrice);
269
+ const excVatValue = options.fallbackExcVat
270
+ ? Wick.BloomreachWidget.getExcVatFormattedValue(product, displayPrice)
271
+ : Wick.BloomreachWidget.getPriceFormattedValue(displayPriceExcVat);
272
+ const excVatFormattedValue = wasPriceFormatted
273
+ ? Wick.BloomreachWidget.formatPromotionalPrice(displayPriceExcVat || excVatValue)
274
+ : excVatValue;
275
+
276
+ return {
277
+ ...product,
278
+ badge: Wick.BloomreachWidget.getBadge(product),
279
+ price: displayPrice,
280
+ image:
281
+ options.image ||
282
+ Wick.BloomreachWidget.getProductImage(product, options.fallbackProduct),
283
+ wasPriceFormatted,
284
+ 'switch-vat': isSwitchVat,
285
+ incVatFormattedValue,
286
+ incVatValue: Wick.BloomreachWidget.getPriceValue(displayPrice),
287
+ excVatFormattedValue,
288
+ excVatValue: Wick.BloomreachWidget.getPriceValue(displayPriceExcVat),
289
+ incVatWasPriceFormatted: wasPriceFormatted,
290
+ excVatWasPriceFormatted: Wick.BloomreachWidget.getExcVatWasPrice(product),
291
+ };
292
+ },
293
+
294
+ drawRating($root) {
295
+ const { ratingOverlay, starOverlay } = Wick.BloomreachWidget.el;
296
+
297
+ $root.find(ratingOverlay).each(function () {
298
+ let rating = parseFloat($(this).attr('data-rating')) || 0;
299
+ const $stars = $(this).children(starOverlay);
300
+
301
+ $stars.each(function () {
302
+ const $star = $(this);
303
+
304
+ if (rating >= 1) {
305
+ rating--;
306
+ } else if (rating > 0) {
307
+ const width = Math.asin(2 * rating - 1) / Math.PI + 0.5;
308
+ $star.css('width', width + 'rem');
309
+ rating = 0;
310
+ } else {
311
+ $star.css('width', '0rem');
312
+ }
313
+ });
314
+ });
315
+ },
316
+
317
+ dispatchWidgetEvent(eventName, payload) {
318
+ return new Promise(function (resolve, reject) {
319
+ const eventDetail = { resolve, reject };
320
+ const event = createEvent(eventName, payload, eventDetail);
321
+
322
+ window.dispatchEvent(event);
323
+ });
324
+ },
325
+
326
+ reapplyVatDisplay() {
327
+ if (!Wick.VatToggle || typeof Wick.VatToggle.isActive !== 'function') {
328
+ return;
329
+ }
330
+
331
+ const { vatInc, vatExc } = Wick.BloomreachWidget.el;
332
+ const hiddenClassName = Wick.VatToggle.HIDDEN_CLASS_NAME || 'd-none';
333
+ const isExcVatActive = Wick.VatToggle.isActive();
334
+
335
+ $(vatInc).toggleClass(hiddenClassName, isExcVatActive);
336
+ $(vatExc).toggleClass(hiddenClassName, !isExcVatActive);
337
+ },
338
+
339
+ bindVatToggle(namespace) {
340
+ if (!Wick.VatToggle || !Wick.VatToggle.TOGGLE_VAT_EVENT_NAME) {
341
+ return;
342
+ }
343
+
344
+ const eventName = `${Wick.VatToggle.TOGGLE_VAT_EVENT_NAME}.${namespace}`;
345
+
346
+ $(window).off(eventName).on(eventName, Wick.BloomreachWidget.reapplyVatDisplay);
347
+ },
348
+
349
+ formatPromotionalPrice(price) {
350
+ if (price === null || price === undefined) {
351
+ return '';
352
+ }
353
+
354
+ const rawValue =
355
+ typeof price === 'object'
356
+ ? typeof price.value === 'number'
357
+ ? price.value
358
+ : price.formattedValue
359
+ : price;
360
+
361
+ if (rawValue === null || rawValue === undefined || rawValue === '') {
362
+ return '';
363
+ }
364
+
365
+ const value =
366
+ typeof rawValue === 'number'
367
+ ? rawValue
368
+ : Number(`${rawValue}`.replace(/[,£\s]/g, ''));
369
+
370
+ if (!Number.isFinite(value)) {
371
+ return typeof rawValue === 'string' ? rawValue : '';
372
+ }
373
+
374
+ return new Intl.NumberFormat('en-GB', {
375
+ style: 'currency',
376
+ currency: 'GBP',
377
+ minimumFractionDigits: Math.round(Math.abs(value) * 100) % 100 === 0 ? 0 : 2,
378
+ maximumFractionDigits: 2,
379
+ }).format(value);
380
+ },
381
+
382
+ formatPrice(value) {
383
+ return new Intl.NumberFormat('en-GB', {
384
+ style: 'currency',
385
+ currency: 'GBP',
386
+ minimumFractionDigits: 2,
387
+ maximumFractionDigits: 2,
388
+ }).format(value);
389
+ },
390
+ };
@@ -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,26 @@
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';
7
+ import SimilarProductsWidget from './similar-products-widget';
240
8
 
241
9
  Wick.BloomreachWidget.registerWidgets([
242
10
  {
243
11
  type: 'completeYourProject',
244
- widget: CompleteYourProjectWidget,
12
+ widget: Widget,
245
13
  },
246
14
  {
247
15
  type: 'whyNotAdd',
248
16
  widget: WhyNotAddWidget,
249
17
  },
18
+ {
19
+ type: 'dontForget',
20
+ widget: DontForgetWidget,
21
+ },
22
+ {
23
+ type: 'similarProducts',
24
+ widget: SimilarProductsWidget,
25
+ },
250
26
  ]);