wickes-css2 2.105.0-develop.6 → 2.105.0-develop.8

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 (209) hide show
  1. package/Readme.md +2 -2
  2. package/build/css/category-main.css +1 -1
  3. package/build/css/homepage-main.css +1 -1
  4. package/build/css/kitchen-plp-main.css +1 -1
  5. package/build/css/main.css +1 -1
  6. package/build/css/my-account-main-v2.css +1 -1
  7. package/build/css/my-account-main.css +1 -1
  8. package/build/css/pages/my-account-v2.css +1 -1
  9. package/build/css/pages/page_discount.css +1 -1
  10. package/build/css/pages/page_product_search.css +1 -1
  11. package/build/css/pages/page_products-list-combined.css +1 -1
  12. package/build/css/pages/page_products-list.css +1 -1
  13. package/build/css/pages/tradePro-rewards.css +1 -1
  14. package/build/css/pdp-main-before-combine.css +1 -1
  15. package/build/css/pdp-main-non-critical.css +1 -1
  16. package/build/css/pdp-main.css +1 -1
  17. package/build/css/plp-main.css +1 -1
  18. package/build/css/store-locator-main.css +1 -1
  19. package/build/js/basket.min.js +2 -2
  20. package/build/js/bundle.min.js +1 -1
  21. package/build/js/checkout.min.js +2 -2
  22. package/build/js/emulation.min.js +10255 -10784
  23. package/build/js/general.bundle.min.js +1 -1
  24. package/build/js/kitchen/kitchen-plp.min.js +9 -1
  25. package/build/js/merged-checkout.min.js +2 -2
  26. package/build/js/mini-basket-slider.min.js +1 -1
  27. package/build/js/my-account.min.js +1 -1
  28. package/build/js/page/accordion.js +35 -0
  29. package/build/js/page/basket/basket-update-cart-action.js +56 -59
  30. package/build/js/page/basket/basket-update-cart.js +27 -27
  31. package/build/js/page/basket/basket-utils.js +33 -40
  32. package/build/js/page/basket/mini-basket-total.js +66 -70
  33. package/build/js/page/basket/quantity-change-handler.js +55 -73
  34. package/build/js/page/basket/update-quantity-operation.js +30 -39
  35. package/build/js/page/basket/update-quantity.js +62 -62
  36. package/build/js/page/basket-v2.js +229 -362
  37. package/build/js/page/billie-business-type.js +27 -27
  38. package/build/js/page/checkout-payment-details.js +299 -301
  39. package/build/js/page/components/discounts.js +36 -39
  40. package/build/js/page/components/mini-basket-slider.js +545 -604
  41. package/build/js/page/kitchen/plp-filters-chips.js +90 -0
  42. package/build/js/page/kitchen/plp-filters-mobile.js +72 -0
  43. package/build/js/page/kitchen/plp-filters-panel.js +119 -0
  44. package/build/js/page/kitchen/plp-filters-utils.js +65 -0
  45. package/build/js/page/kitchen/plp-filters.js +205 -0
  46. package/build/js/page/kitchen/sort-by.js +157 -0
  47. package/build/js/page/klarna-modal-scroll-disable.js +4 -4
  48. package/build/js/page/my-account.js +14 -29
  49. package/build/js/page/online-exclusive.js +30 -28
  50. package/build/js/page/tradePro-rewards.js +39 -69
  51. package/build/js/page/utils/copy-to-clipboard.js +47 -79
  52. package/build/js/page/utils/helpers.js +9 -14
  53. package/build/js/pdp.bundle.min.js +1 -1
  54. package/build/js/plp.bundle.min.js +1 -1
  55. package/build/js/project-list.min.js +85 -143
  56. package/build/js/tradePro-rewards.min.js +1 -1
  57. package/package.json +3 -3
  58. package/src/components/.DS_Store +0 -0
  59. package/src/components/accordion.hbs +2 -2
  60. package/src/components/kitchen/dropdown.hbs +3 -6
  61. package/src/components/kitchen/filter-modal.hbs +13 -10
  62. package/src/components/kitchen/plp-filters.hbs +1 -3
  63. package/src/components/kitchen/sort-by.hbs +1 -1
  64. package/src/components/my-account/barcode.hbs +1 -3
  65. package/src/components/my-account/cards-swap.hbs +10 -0
  66. package/src/components/my-account/clipboard-code-card.hbs +3 -3
  67. package/src/components/my-account/discount.hbs +1 -1
  68. package/src/components/my-account/greetings.hbs +1 -1
  69. package/src/components/search-filter.hbs +112 -121
  70. package/src/data/data_plp_load-more.json +1 -1
  71. package/src/data/my-account/data_my-account.json +9 -0
  72. package/src/js/components/cards-swap.js +72 -0
  73. package/src/js/components/general/accordion.js +33 -44
  74. package/src/js/components/general/cart-slider.js +16 -19
  75. package/src/js/components/general/create-popup-slider.js +173 -168
  76. package/src/js/components/general/search-filter.js +21 -0
  77. package/src/js/components/share-project-list.js +53 -0
  78. package/src/js/emulation/big-wins.js +904 -1081
  79. package/src/js/emulation/billie-modal.js +19 -23
  80. package/src/js/emulation/checkout-payment-details.js +38 -47
  81. package/src/js/emulation/custom-slider-emulation.js +13 -17
  82. package/src/js/emulation/forms.js +323 -360
  83. package/src/js/emulation/mini-basket-data.js +923 -1051
  84. package/src/js/emulation/paymentLoader.js +17 -17
  85. package/src/js/emulation/pdf-file-loader.js +91 -89
  86. package/src/js/emulation/popover-mini-basket.js +239 -246
  87. package/src/js/emulation/project-list-pdp.js +316 -320
  88. package/src/js/emulation/repayment-toggle.js +24 -23
  89. package/src/js/emulation/selectable.js +18 -22
  90. package/src/js/emulation/wismo-details.js +31 -23
  91. package/src/js/page/accordion.js +35 -0
  92. package/src/js/page/basket/basket-update-cart-action.js +56 -59
  93. package/src/js/page/basket/basket-update-cart.js +27 -27
  94. package/src/js/page/basket/basket-utils.js +33 -40
  95. package/src/js/page/basket/mini-basket-total.js +66 -70
  96. package/src/js/page/basket/quantity-change-handler.js +55 -73
  97. package/src/js/page/basket/update-quantity-operation.js +30 -39
  98. package/src/js/page/basket/update-quantity.js +62 -62
  99. package/src/js/page/basket-v2.js +229 -362
  100. package/src/js/page/billie-business-type.js +27 -27
  101. package/src/js/page/checkout-payment-details.js +299 -301
  102. package/src/js/page/components/discounts.js +36 -39
  103. package/src/js/page/components/mini-basket-slider.js +545 -604
  104. package/src/js/page/kitchen/plp-filters-chips.js +90 -0
  105. package/src/js/page/kitchen/plp-filters-mobile.js +72 -0
  106. package/src/js/page/kitchen/plp-filters-panel.js +119 -0
  107. package/src/js/page/kitchen/plp-filters-utils.js +65 -0
  108. package/src/js/page/kitchen/plp-filters.js +205 -0
  109. package/src/js/page/kitchen/sort-by.js +157 -0
  110. package/src/js/page/klarna-modal-scroll-disable.js +4 -4
  111. package/src/js/page/my-account.js +14 -29
  112. package/src/js/page/online-exclusive.js +30 -28
  113. package/src/js/page/tradePro-rewards.js +39 -69
  114. package/src/js/page/utils/copy-to-clipboard.js +47 -79
  115. package/src/js/page/utils/helpers.js +9 -14
  116. package/src/page_empty-shared-project-list-bicester-hub.html +0 -4
  117. package/src/page_empty-shopping-list_guest.html +0 -1
  118. package/src/page_kitchen-plp.html +2 -2
  119. package/src/page_my-account-installer.html +1 -1
  120. package/src/page_my-account-trade-pro-carousel-double.html +127 -0
  121. package/src/page_my-account-trade-pro-carousel.html +134 -0
  122. package/src/page_my-account-trade-pro.html +1 -1
  123. package/src/page_my-shopping-list-add-notes.html +0 -1
  124. package/src/page_my-shopping-list-energy.html +0 -1
  125. package/src/page_my-shopping-list-hide-download.html +1 -2
  126. package/src/page_my-shopping-list-pdf.html +0 -2
  127. package/src/page_my-shopping-list-saved-ref.html +0 -1
  128. package/src/page_my-shopping-list-wisdom-oos-registered.html +0 -1
  129. package/src/page_my-shopping-list-wisdom-oos.html +0 -1
  130. package/src/page_my-shopping-list-wisdom-partial-registered.html +0 -1
  131. package/src/page_my-shopping-list-wisdom-registered.html +0 -1
  132. package/src/page_my-shopping-list-wisdom.html +0 -1
  133. package/src/page_my-shopping-list.html +0 -1
  134. package/src/page_my-shopping-list_not-register.html +0 -3
  135. package/src/page_plp-with-paint.html +7 -2
  136. package/src/page_plp.html +7 -2
  137. package/src/page_plp_v2-energy-efficiency.html +6 -1
  138. package/src/page_plp_v2-favourite-products.html +7 -6
  139. package/src/page_plp_v2-vat.html +7 -2
  140. package/src/page_plp_v2.html +9 -22
  141. package/src/page_product_search-vat.html +7 -2
  142. package/src/page_product_search.html +7 -2
  143. package/src/page_project-list-generate-project-list-ID.html +0 -3
  144. package/src/page_project-list-vat.html +0 -4
  145. package/src/page_project-list-with-new-share-popup-android.html +1 -3
  146. package/src/page_project-list-with-new-share-popup-ios.html +1 -3
  147. package/src/page_project-list-with-new-share-popup.html +1 -2
  148. package/src/page_search-results.html +7 -2
  149. package/src/page_shared-project-list-bicester-hub.html +1 -3
  150. package/src/page_tradepro-discount-app.html +1 -1
  151. package/src/page_tradepro-discount-double.html +109 -0
  152. package/src/page_tradepro-discount.html +36 -2
  153. package/src/scss/common/_common.scss +4 -5
  154. package/src/scss/components/_accordion.scss +3 -1
  155. package/src/scss/components/_custom-slider.scss +14 -15
  156. package/src/scss/components/_date-selection-add-new-styles.scss +7 -6
  157. package/src/scss/components/_date-selection.scss +1 -1
  158. package/src/scss/components/_popover-mini-basket.scss +3 -3
  159. package/src/scss/components/_search-filter.scss +15 -95
  160. package/src/scss/components/checkout-chip.scss +2 -2
  161. package/src/scss/components/checkout-payment-repayment-terms.scss +1 -1
  162. package/src/scss/components/{_filter-modal.scss → kitchen/_filter-modal.scss} +4 -55
  163. package/src/scss/components/{_plp-filters.scss → kitchen/_plp-filters.scss} +13 -31
  164. package/src/scss/components/my-account/_barcode.scss +8 -0
  165. package/src/scss/components/my-account/_cards-swap.scss +58 -0
  166. package/src/scss/components/my-account/_clipboard-code.scss +8 -0
  167. package/src/scss/components/my-account/_discount.scss +10 -0
  168. package/src/scss/globals/_global-components.scss +0 -3
  169. package/src/scss/helpers/_colors-semantic.scss +68 -68
  170. package/src/scss/helpers/_variables.scss +196 -242
  171. package/src/scss/kitchen-plp-main.scss +3 -0
  172. package/src/scss/main.scss +65 -65
  173. package/src/scss/pages/my-account-v2.scss +37 -0
  174. package/src/scss/pages/page_discount.scss +8 -4
  175. package/src/scss/pages/page_product-details-v2.scss +4 -1
  176. package/src/scss/pages/page_product_search.scss +1 -9
  177. package/src/scss/pages/page_products-list-combined.scss +24 -28
  178. package/src/scss/pages/page_products-list.scss +0 -8
  179. package/src/scss/pages/tradePro-rewards.scss +4 -3
  180. package/src/sitemap.html +3 -0
  181. package/build/js/page/filters/desktop-nav.js +0 -64
  182. package/build/js/page/filters/mobile-nav.js +0 -93
  183. package/build/js/page/filters/plp-filters-chips.js +0 -92
  184. package/build/js/page/filters/plp-filters-mobile.js +0 -150
  185. package/build/js/page/filters/plp-filters-panel.js +0 -123
  186. package/build/js/page/filters/plp-filters-utils.js +0 -66
  187. package/build/js/page/filters/plp-filters.js +0 -256
  188. package/build/js/page/filters/sort-by.js +0 -172
  189. package/build/js/page/search-filter.js +0 -62
  190. package/build/js/page/share-project-list.js +0 -57
  191. package/build/js/page/utils/show-more-less.js +0 -273
  192. package/src/components/kitchen/filter-modal-content-kitchen.hbs +0 -10
  193. package/src/components/search-filter-modal-content.hbs +0 -102
  194. package/src/elements/btn.hbs +0 -7
  195. package/src/js/emulation/filters-emulation.js +0 -164
  196. package/src/js/emulation/product-counter.js +0 -50
  197. package/src/js/emulation/reset-filter-desktop.js +0 -5
  198. package/src/js/page/filters/desktop-nav.js +0 -64
  199. package/src/js/page/filters/mobile-nav.js +0 -93
  200. package/src/js/page/filters/plp-filters-chips.js +0 -92
  201. package/src/js/page/filters/plp-filters-mobile.js +0 -150
  202. package/src/js/page/filters/plp-filters-panel.js +0 -123
  203. package/src/js/page/filters/plp-filters-utils.js +0 -66
  204. package/src/js/page/filters/plp-filters.js +0 -256
  205. package/src/js/page/filters/sort-by.js +0 -172
  206. package/src/js/page/search-filter.js +0 -62
  207. package/src/js/page/share-project-list.js +0 -57
  208. package/src/js/page/utils/show-more-less.js +0 -273
  209. package/src/scss/components/_sort-by.scss +0 -190
@@ -1,1112 +1,935 @@
1
- var Wick = (window.Wick = window.Wick || {});
2
-
3
- Wick.BigWinsProto = (function () {
4
- var bwVar = {
5
- $body: $('body'),
6
- $bigWins: $('.bw'),
7
- $bwActions: $('.bw_act'),
8
- $bwChosen: $('.bw__chosen'),
9
- $pdpPrice: $('.pdp-price'),
10
- $defStoreWrap: $('.my-account_default_store'),
11
- $tiTotal: $('.ti__total'),
12
- $stock: $('.stock'),
13
- $stockTabs: $('.stock__tabs'),
14
- $stockTab: $('.stock__tab'),
15
- $defStockTab: $('.def-stock__tab'),
16
- $stockInfo: $('.stock__info'),
17
- $stockAccordion: $('.stock__accordion'),
18
- $stockContent: $('.stock__content'),
19
- $stockMore: $('.stock-more'),
20
- $stockResult: $('.stock__result'),
21
- $stockFind: $('.stock__find'),
22
- $stockFindBtn: $('.stock__find_btn'),
23
- $stockEditBtn: $('.stock__edit_btn'),
24
- $stockQuestions: $('.stock__quest'),
25
- $stockRadio: $('.stock__radio label'),
26
- $stockQuantity: $('.tbx_quantity'),
27
- $stockPostcode: $('.stock__postcode input'),
28
- $stockPostcodeEl: $('.stock__postcode'),
29
- $stockAmount: $('.stock__amount-val'),
30
- $stockDescr: $('.stock__descr'),
31
- $stockPost: $('.stock__descr_post'),
32
- $stockClose: $('.stock__close '),
33
- $stockCancel: $('.stock__cancel-text'),
34
- $storeMoreLink: $('.store__more a'),
35
- $sDetails: $('.s-details'),
36
- $sDetailsClose: $('.s-details__close'),
37
- $sDetailsToggleMap: $('.s-details__tgl-map'),
38
- $sDetailsToggleMapText: $('.s-details__tgl-map_text'),
39
- $sDetailsMap: $('.s-details__map'),
40
- $sDetailsCopy: $('.s-details__copy'),
41
- $sDetailsAddress: $('.s-details__address'),
42
- $chosen: $('.chosen'),
43
- $protoOnlyPopulated: $('.proto-only-populated'),
44
- $storeState: $('.store-state'),
45
- $makeDefault: $('.default-store__make'),
46
- $nameDefault: $('.default-store__name'),
47
- $defaultCurrent: $('.default-store__default'),
48
- $defaultInfo: $('.default-store__det'),
49
- $store: $('.store'),
50
- $chosenItem: $('.chosen__item'),
51
- $storeCount: $('.store__count'),
52
- $stockList: $('.stock__list'),
53
- $stockTarget: $('.stock__target'),
54
- $storeSearch: $('.store-search'),
55
- $storeChange: $('.store-change'),
56
- $addStore: $('.my-account_add-store'),
57
- $addForDelivery: $('.btn-add-to-basket'),
58
- $addClickAndCollect: $('.nearest-store-purchasable'),
59
- $cancelStore: $('.my-account_cancel-store'),
60
- $toDefaultIcon: $('.store__tick'),
61
- $isDefaultIcon: $('.store__marker'),
62
- $currentDefault: $('.default-store__det__current'),
63
- $findStore: $('.my-account_find-store'),
64
- $postCodeErrorMsg: $('.stock__postcode_invalid-msg'),
65
- $ccOrder: $('.cc-order'),
66
- storeState: 'store__state',
67
- storeCount: '.store__count',
68
- ccBtn: '.bw__cc-btn',
69
- pdpPriceBW: 'pdp-price_bw',
70
- tiTotalBW: 'ti__total_bw',
71
- stockTab: '.stock__tab',
72
- active: 'active',
73
- stockMore: 'stock-more',
74
- stockItem: '.stock__item',
75
- stockContentNearest: 'stock__content_nearest',
76
- stockContentMore: 'stock__content_more',
77
- stockResultHide: 'stock__result_hide',
78
- stockResultSuccess: 'stock__result_success',
79
- stockTabsHide: 'stock__tabs_hide',
80
- stockFindHide: 'stock__find_hide',
81
- stockFindBtn: '.stock__find_btn',
82
- stockQuestionInvalid: 'stock__quest_invalid',
83
- stockDescrC: 'stock__descr_c',
84
- stockDescrS: 'stock__descr_s',
85
- stockPostcodeInvalid: 'stock__postcode_invalid',
86
- stockDetailsOpen: 'stock__det-open',
87
- stockBot: 'stock__bot',
88
- pdpPriceDetailsOpen: 'pdp-price__det-open',
89
- sDetailsHide: 's-details_hide',
90
- sDetails: '.s-details',
91
- sDetailsStoreName: '.s-details__s-name',
92
- sDetailsInfo: '.s-details__info',
93
- sDetailsMapHide: 's-details__map_hide',
94
- sDetailsAddress: '.s-details__address',
95
- chosenHide: 'chosen_hide',
96
- chosenNearest: 'chosen__nearest',
97
- chosenSuccess: 'chosen__success',
98
- chosenError: 'chosen__error',
99
- store: '.store',
100
- storeName: '.store__name-text',
101
- defaultStoreName: '.default-store__name-txt',
102
- collapsed: 'collapsed',
103
- show: 'show',
104
- scrollDisable: 'scroll-disable',
105
- bwMinHeight: 'bw_min-h',
106
- copyLinkHovered: 'copy-link_hovered',
107
- protoOnlyPopulated: 'proto-only-populated',
108
- moreStoresPresent: 'more-stores-present',
109
- defStoresPresent: 'def-stores-present',
110
- CLICK_AND_COLLECT: 'FREE Click & Collect within 30 minutes',
111
- CLICK_AND_COLLECT_NOT_AVAILABLE: 'Click & Collect not available',
112
- };
113
-
114
- function init() {
115
- Wick.SnackBar.init();
116
- bwVar.$stockTabs.on('click', bwVar.stockTab, function () {
117
- if (
118
- $(bwVar.ccBtn).attr('disabled') &&
119
- $(bwVar.ccBtn).hasClass('nearest-store-purchasable')
120
- ) {
121
- $(bwVar.ccBtn).removeAttr('disabled');
122
- $(bwVar.ccBtn).find('.btn__text').text(bwVar.CLICK_AND_COLLECT);
123
- }
124
-
125
- if (!$(this).hasClass(bwVar.active)) {
126
- //toggle tabs
127
- $(this).closest(bwVar.$bigWins).find(bwVar.$stockTab).removeClass(bwVar.active);
128
- $(this).addClass(bwVar.active);
129
-
130
- $(this).closest(bwVar.$bigWins).find(bwVar.$stockFindBtn).unbind();
131
-
132
- //show/close modal with more stores
133
- if ($(this).attr('data-stores') === 'more') {
134
- //open block
135
- $(this).closest(bwVar.$bigWins).find(bwVar.$stock).addClass(bwVar.stockBot);
136
- $(this).closest(bwVar.$bigWins).addClass(bwVar.bwMinHeight);
137
-
138
- let self;
139
- if ($(window).width() < 767) {
140
- $(this)
141
- .closest(bwVar.$bigWins)
142
- .find(bwVar.$stock)
143
- .addClass(bwVar.stockMore);
144
- } else {
145
- self = this;
146
- setTimeout(function () {
147
- $(self)
148
- .closest(bwVar.$bigWins)
149
- .find(bwVar.$stock)
150
- .addClass(bwVar.stockMore);
151
- }, 1);
152
- }
153
-
154
- // remove ability collapse block
155
- $(this)
156
- .closest(bwVar.$bigWins)
157
- .find(bwVar.$stockAccordion)
158
- .removeAttr('data-toggle');
159
-
160
- //event to show results
161
- $(this)
162
- .closest(bwVar.$bigWins)
163
- .find(bwVar.$stockFindBtn)
164
- .on('click', function (e) {
165
- showSearchResultMore(e, this);
166
- showSearchResultMoreProto(this);
167
- });
168
-
169
- //delete error validation
170
- $(this)
171
- .closest(bwVar.$bigWins)
172
- .find(bwVar.$stockPostcodeEl)
173
- .removeClass(bwVar.stockPostcodeInvalid);
174
-
175
- if ($(window).width() < 767) {
176
- //disable scroll for modal
177
- bwVar.$body.addClass(bwVar.scrollDisable);
178
- }
179
-
180
- $(this)
181
- .closest(bwVar.$bigWins)
182
- .find(bwVar.stockItem)
183
- .each(function () {
184
- var attr = $(this).find('.stock__radio input').attr('checked');
185
- if (typeof attr !== 'undefined' && attr !== false) {
186
- var value = $(this)
187
- .closest(bwVar.stockItem)
188
- .find('.store__stock_val')
189
- .text();
190
- if (value.match(/^out$/)) {
191
- $(this)
192
- .closest(bwVar.stockItem)
193
- .find('.stock__valid')
194
- .addClass('stock__valid_show');
195
- $(bwVar.ccBtn).attr('disabled', 'disabled');
196
- $(bwVar.ccBtn)
197
- .find('.btn__text')
198
- .text(bwVar.CLICK_AND_COLLECT_NOT_AVAILABLE);
199
- }
200
- }
201
- });
202
- } else if ($(this).attr('data-stores') === 'nearest') {
203
- //close more block
204
- $(this).closest(bwVar.$bigWins).find(bwVar.$stock).removeClass(bwVar.stockMore);
205
- let self;
206
- if ($(window).width() < 767) {
207
- $(this)
208
- .closest(bwVar.$bigWins)
209
- .find(bwVar.$stock)
210
- .removeClass(bwVar.stockBot);
211
- $(this).closest(bwVar.$bigWins).removeClass(bwVar.bwMinHeight);
212
- } else {
213
- self = this;
214
- setTimeout(function () {
215
- $(self)
216
- .closest(bwVar.$bigWins)
217
- .find(bwVar.$stock)
218
- .removeClass(bwVar.stockBot);
219
- $(self).closest(bwVar.$bigWins).removeClass(bwVar.bwMinHeight);
220
- }, 600);
221
- }
222
-
223
- // add ability collapse block
224
- $(this)
225
- .closest(bwVar.$bigWins)
226
- .find(bwVar.$stockAccordion)
227
- .attr('data-toggle', 'collapse');
228
- //event to show results
229
- $(this)
230
- .closest(bwVar.$bigWins)
231
- .find(bwVar.$stockFindBtn)
232
- .on('click', showSearchResultNearest);
233
- //unlock scroll for modal
234
- bwVar.$body.removeClass(bwVar.scrollDisable);
235
- //delete error validation
236
- $(this)
237
- .closest(bwVar.$bigWins)
238
- .find(bwVar.$stockPostcodeEl)
239
- .removeClass(bwVar.stockPostcodeInvalid);
240
-
241
- scrollToBlockMobile(this);
242
- }
243
- }
244
- closeStoreDetails(this);
245
- });
246
-
247
- bwVar.$stockFindBtn.on('click', function () {
248
- showSearchResultNearest(this);
249
- });
250
-
251
- bwVar.$defStockTab.on('click', function (e) {
252
- e.preventDefault();
253
-
254
- bwVar.$stockResult.removeClass('stock__result_hide');
255
- $(this).closest(bwVar.$bigWins).find(bwVar.$stock).addClass(bwVar.stockBot);
256
- $(this).closest(bwVar.$bigWins).addClass(bwVar.bwMinHeight);
257
- let self;
258
- if ($(window).width() < 767) {
259
- $(this).closest(bwVar.$bigWins).find(bwVar.$stock).addClass(bwVar.stockMore);
260
- } else {
261
- self = this;
262
- setTimeout(function () {
263
- $(self).closest(bwVar.$bigWins).find(bwVar.$stock).addClass(bwVar.stockMore);
264
- }, 1);
265
- }
266
- });
267
-
268
- //choose default store in more stores section
269
- bwVar.$storeState.on('click', function (e) {
270
- let defVal = $(this).text().trim(),
271
- toDefault = 'Make this your default store',
272
- isDefault = 'Default store',
273
- selectedStore = $(this).closest(bwVar.$store).html();
274
-
275
- e.preventDefault();
276
-
277
- if (defVal === toDefault) {
278
- bwVar.$storeState.text(toDefault);
279
- $(this).text(isDefault);
280
- bwVar.$bwChosen.find(bwVar.$store).html(selectedStore);
281
- bwVar.$storeState.parent().find(bwVar.$toDefaultIcon).hide();
282
- bwVar.$storeState.parent().find(bwVar.$isDefaultIcon).show();
283
-
284
- $(this).parent().find(bwVar.$isDefaultIcon).hide();
285
- $(this).parent().find(bwVar.$toDefaultIcon).show();
286
- } else {
287
- $(this).click(false);
288
- }
289
- });
290
-
291
- //make store default from main page
292
- bwVar.$nameDefault.on('click', function (e) {
293
- e.preventDefault();
294
- let makeDefValue = $(this).find(bwVar.defaultStoreName).text();
295
-
296
- bwVar.$stockList.find(bwVar.storeName).each(function () {
297
- if ($(this).text() === makeDefValue) {
298
- $(this).closest(bwVar.$store).find('.store-state').click();
299
- }
300
- });
301
-
302
- bwVar.$makeDefault.hide();
303
- bwVar.$defaultInfo.hide();
304
- bwVar.$defaultCurrent.show();
305
- });
306
-
307
- bwVar.$currentDefault.on('click', function (e) {
308
- e.preventDefault();
309
- let makeDefValue = $(this).find(bwVar.defaultStoreName).text();
310
-
311
- bwVar.$stockList.find(bwVar.storeName).each(function () {
312
- if ($(this).text() === makeDefValue) {
313
- $(this).closest(bwVar.$store).find('.store-state').click();
314
- }
315
- });
316
-
317
- bwVar.$makeDefault.hide();
318
- bwVar.$defaultInfo.hide();
319
- bwVar.$defaultCurrent.show();
320
- });
321
-
322
- //my-acc default store component logic
323
- bwVar.$storeSearch.on('click', function (e) {
324
- e.preventDefault();
325
- bwVar.$storeSearch.hide();
326
- bwVar.$stockPostcodeEl.show();
327
- });
328
-
329
- //my-acc scroll to default store component logic
330
- $('.scrollToDefault').on('click', function (e) {
331
- e.preventDefault();
332
- var target = $(this).attr('href');
333
- $('html, body').animate(
334
- {
335
- scrollTop: $(target).offset().top,
336
- },
337
- 'slow'
338
- );
339
- });
340
-
341
- bwVar.$findStore.on('click', function (e) {
342
- e.preventDefault();
343
-
344
- if ($('.stock__input').val().length !== 0) {
345
- bwVar.$stockPostcodeEl.removeClass(bwVar.stockPostcodeInvalid);
346
- bwVar.$postCodeErrorMsg.hide();
347
- bwVar.$bigWins.show();
348
-
349
- if (bwVar.$bigWins.css('display') === 'block') {
350
- bwVar.$bwActions.css('display', 'flex');
351
- } else {
352
- bwVar.$bwActions.hide();
353
- }
354
- } else {
355
- bwVar.$stockPostcodeEl.addClass(bwVar.stockPostcodeInvalid);
356
- bwVar.$postCodeErrorMsg.css('display', 'inherit');
357
- }
358
- });
359
-
360
- bwVar.$addStore.on('click', function (e) {
361
- e.preventDefault();
362
- bwVar.$bigWins.hide();
363
- bwVar.$stockPostcodeEl.hide();
364
- bwVar.$storeChange.css('display', 'block');
365
- bwVar.$bwActions.hide();
366
- bwVar.$addStore.text('Update Default Store');
367
- });
368
-
369
- bwVar.$cancelStore.on('click', function (e) {
370
- e.preventDefault();
371
- bwVar.$bigWins.hide();
372
- bwVar.$bwActions.hide();
373
- bwVar.$stockPostcodeEl.hide();
374
- bwVar.$storeSearch.show();
375
- });
376
-
377
- bwVar.$storeChange.on('click', function (e) {
378
- e.preventDefault();
379
- bwVar.$bigWins.show();
380
- bwVar.$stockPostcodeEl.show();
381
- bwVar.$bwActions.show();
382
- bwVar.$storeChange.hide();
383
- });
384
-
385
- bwVar.$defStoreWrap.find(bwVar.$addStore).on('click', function () {
386
- if ($("input:radio[name='store']").is(':checked')) {
387
- let currentInp = $("input:radio[name='store'][checked='checked']"),
388
- selectedVal = currentInp
389
- .closest(bwVar.stockItem)
390
- .find(bwVar.sDetailsAddress)
391
- .text();
392
-
393
- bwVar.$defStoreWrap.find('.table__content-address').text(selectedVal);
394
- }
395
- });
396
-
397
- //show store details
398
- bwVar.$storeMoreLink.on('click', function (e) {
399
- e.preventDefault();
400
-
401
- console.log($(this).closest('.basket').length);
402
- if (!$(this).closest('.basket').length) {
403
- var storeName = $(this)
404
- .closest('.store')
405
- .find(bwVar.storeName)
406
- .text()
407
- .trim()
408
- .toLowerCase();
409
-
410
- if ($(this).text().trim() === 'Store Info') {
411
- closeStoreDetails(this);
412
- $(this)
413
- .closest(bwVar.$bigWins)
414
- .find(bwVar.$stockRadio)
415
- .find('input')
416
- .removeAttr('checked');
417
- $(this).closest(bwVar.stockItem).find(bwVar.$stockRadio).trigger('click');
418
- $(this)
419
- .closest(bwVar.stockItem)
420
- .find(bwVar.$stockRadio)
421
- .attr('checked', 'checked');
422
-
423
- $(this).text('Hide Info');
424
-
425
- //show pseudoclass
426
- $(this)
427
- .closest(bwVar.$bigWins)
428
- .find(bwVar.$stock)
429
- .addClass(bwVar.stockDetailsOpen);
430
-
431
- //classes only for Price
432
- console.log($(this).closest(bwVar.$pdpPrice).length);
433
-
434
- if ($(this).closest(bwVar.$pdpPrice).length) {
435
- $(this).closest(bwVar.$pdpPrice).addClass(bwVar.stockDetailsOpen);
436
- $(this).closest(bwVar.$pdpPrice).addClass(bwVar.pdpPriceBW);
437
- } else if ($(this).closest(bwVar.$tiTotal).length) {
438
- $(this).closest(bwVar.$tiTotal).addClass(bwVar.stockDetailsOpen);
439
- $(this).closest(bwVar.$tiTotal).addClass(bwVar.tiTotalBW);
440
- }
441
-
442
- $(this)
443
- .closest(bwVar.$bigWins)
444
- .find(bwVar.$sDetails)
445
- .addClass(bwVar.sDetailsHide);
446
- //open tab with current store
447
- $(this)
448
- .closest(bwVar.$bigWins)
449
- .find(bwVar.$sDetails)
450
- .each(function () {
451
- if (
452
- $(this)
453
- .find(bwVar.sDetailsStoreName)
454
- .text()
455
- .trim()
456
- .toLowerCase() === storeName
457
- ) {
458
- $(this).removeClass(bwVar.sDetailsHide);
459
- }
460
- });
461
-
462
- if (!bwVar.$ccOrder.length) {
463
- if ($(window).width() < 767) {
464
- //disable scroll for modal
465
- bwVar.$body.addClass(bwVar.scrollDisable);
466
- }
467
- }
468
- } else if ($(this).text().trim() === 'Hide Info') {
469
- closeStoreDetails(this);
470
- }
471
- }
472
- });
473
-
474
- //hide store details
475
- bwVar.$sDetailsClose.on('click', function (e) {
476
- e.preventDefault();
477
- closeStoreDetails(this);
478
- });
479
-
480
- // show store via radio buttons
481
- bwVar.$stockRadio.on('change', function () {
482
- $(this).closest(bwVar.$bigWins).find('.stock__valid').removeClass('stock__valid_show');
483
- if ($(this).closest(bwVar.$bigWins).find(bwVar.ccBtn).attr('disabled')) {
484
- $(this).closest(bwVar.$bigWins).find(bwVar.ccBtn).removeAttr('disabled');
485
- $(this)
486
- .closest(bwVar.$bigWins)
487
- .find(bwVar.ccBtn)
488
- .find('.btn__text')
489
- .text(bwVar.CLICK_AND_COLLECT);
490
- }
491
-
492
- var openedInfo = false;
493
- $(this)
494
- .closest(bwVar.$bigWins)
495
- .find('.s-details')
496
- .each(function () {
497
- if (!$(this).hasClass('s-details_hide')) {
498
- openedInfo = true;
499
- }
500
- });
501
-
502
- if (openedInfo) {
503
- var storeName = $(this)
504
- .closest('.stock__item')
505
- .find(bwVar.storeName)
506
- .text()
507
- .trim()
508
- .toLowerCase();
509
- $(this).closest(bwVar.$bigWins).find(bwVar.$storeMoreLink).text('Store Info');
510
- $(this).closest('.stock__item').find(bwVar.$storeMoreLink).text('Hide Info');
511
-
512
- //show pseudoclass
513
- $(this).closest(bwVar.$bigWins).find(bwVar.$stock).addClass(bwVar.stockDetailsOpen);
514
- $(this)
515
- .closest(bwVar.$bigWins)
516
- .find(bwVar.$pdpPrice)
517
- .addClass(bwVar.stockDetailsOpen);
518
-
519
- $(this).closest(bwVar.$pdpPrice).addClass(bwVar.pdpPriceBW);
520
-
521
- $(this).closest(bwVar.$bigWins).find(bwVar.$sDetails).addClass(bwVar.sDetailsHide);
522
-
523
- //open tab with current store
524
- $(this)
525
- .closest(bwVar.$bigWins)
526
- .find(bwVar.$sDetails)
527
- .each(function () {
528
- if (
529
- $(this).find(bwVar.sDetailsStoreName).text().trim().toLowerCase() ===
530
- storeName
531
- ) {
532
- $(this).removeClass(bwVar.sDetailsHide);
533
- }
534
- });
535
-
536
- if ($(window).width() < 767) {
537
- //disable scroll for modal
538
- bwVar.$body.addClass(bwVar.scrollDisable);
539
- }
540
- } else {
541
- closeStoreDetails(this);
542
- }
543
-
544
- $(this).trigger('click');
545
- $(this)
546
- .closest(bwVar.$bigWins)
547
- .find(bwVar.$stockRadio)
548
- .find('input')
549
- .removeAttr('checked');
550
- $(this).find('input').attr('checked', 'checked');
551
-
552
- var attr = $(this).find('input').attr('checked');
1
+ var Wick = Wick || {};
2
+ Wick.BigWinsProto = function () {
3
+
4
+ var bwVar = {
5
+ $body: $('body'),
6
+ $bigWins: $('.bw'),
7
+ $bwActions: $('.bw_act'),
8
+ $bwChosen: $('.bw__chosen'),
9
+ $pdpPrice: $('.pdp-price'),
10
+ $defStoreWrap: $('.my-account_default_store'),
11
+ $tiTotal: $('.ti__total'),
12
+ $stock: $('.stock'),
13
+ $stockTabs: $('.stock__tabs'),
14
+ $stockTab: $('.stock__tab'),
15
+ $defStockTab: $('.def-stock__tab'),
16
+ $stockInfo: $('.stock__info'),
17
+ $stockAccordion: $('.stock__accordion'),
18
+ $stockContent: $('.stock__content'),
19
+ $stockMore: $('.stock-more'),
20
+ $stockResult: $('.stock__result'),
21
+ $stockFind: $('.stock__find'),
22
+ $stockFindBtn: $('.stock__find_btn'),
23
+ $stockEditBtn: $('.stock__edit_btn'),
24
+ $stockQuestions: $('.stock__quest'),
25
+ $stockRadio: $('.stock__radio label'),
26
+ $stockQuantity: $('.tbx_quantity'),
27
+ $stockPostcode: $('.stock__postcode input'),
28
+ $stockPostcodeEl: $('.stock__postcode'),
29
+ $stockAmount: $('.stock__amount-val'),
30
+ $stockDescr: $('.stock__descr'),
31
+ $stockPost: $('.stock__descr_post'),
32
+ $stockClose: $('.stock__close '),
33
+ $stockCancel: $('.stock__cancel-text'),
34
+ $storeMoreLink: $('.store__more a'),
35
+ $sDetails: $('.s-details'),
36
+ $sDetailsClose: $('.s-details__close'),
37
+ $sDetailsToggleMap: $('.s-details__tgl-map'),
38
+ $sDetailsToggleMapText: $('.s-details__tgl-map_text'),
39
+ $sDetailsMap: $('.s-details__map'),
40
+ $sDetailsCopy: $('.s-details__copy'),
41
+ $sDetailsAddress: $('.s-details__address'),
42
+ $chosen: $('.chosen'),
43
+ $protoOnlyPopulated: $('.proto-only-populated'),
44
+ $storeState: $('.store-state'),
45
+ $makeDefault: $('.default-store__make'),
46
+ $nameDefault: $('.default-store__name'),
47
+ $defaultCurrent: $('.default-store__default'),
48
+ $defaultInfo: $('.default-store__det'),
49
+ $store: $('.store'),
50
+ $chosenItem: $('.chosen__item'),
51
+ $storeCount: $('.store__count'),
52
+ $stockList: $('.stock__list'),
53
+ $stockTarget: $('.stock__target'),
54
+ $storeSearch: $('.store-search'),
55
+ $storeChange: $('.store-change'),
56
+ $addStore: $('.my-account_add-store'),
57
+ $addForDelivery: $('.btn-add-to-basket'),
58
+ $addClickAndCollect: $('.nearest-store-purchasable'),
59
+ $cancelStore: $('.my-account_cancel-store'),
60
+ $toDefaultIcon: $('.store__tick'),
61
+ $isDefaultIcon: $('.store__marker'),
62
+ $currentDefault: $('.default-store__det__current'),
63
+ $findStore: $('.my-account_find-store'),
64
+ $postCodeErrorMsg: $('.stock__postcode_invalid-msg'),
65
+ $ccOrder: $('.cc-order'),
66
+ storeState: 'store__state',
67
+ storeCount: '.store__count',
68
+ ccBtn: '.bw__cc-btn',
69
+ pdpPriceBW: 'pdp-price_bw',
70
+ tiTotalBW: 'ti__total_bw',
71
+ stockTab: '.stock__tab',
72
+ active: 'active',
73
+ stockMore: 'stock-more',
74
+ stockItem: '.stock__item',
75
+ stockContentNearest: 'stock__content_nearest',
76
+ stockContentMore: 'stock__content_more',
77
+ stockResultHide: 'stock__result_hide',
78
+ stockResultSuccess: 'stock__result_success',
79
+ stockTabsHide: 'stock__tabs_hide',
80
+ stockFindHide: 'stock__find_hide',
81
+ stockFindBtn: '.stock__find_btn',
82
+ stockQuestionInvalid: 'stock__quest_invalid',
83
+ stockDescrC: 'stock__descr_c',
84
+ stockDescrS: 'stock__descr_s',
85
+ stockPostcodeInvalid: 'stock__postcode_invalid',
86
+ stockDetailsOpen: 'stock__det-open',
87
+ stockBot: 'stock__bot',
88
+ pdpPriceDetailsOpen: 'pdp-price__det-open',
89
+ sDetailsHide: 's-details_hide',
90
+ sDetails: '.s-details',
91
+ sDetailsStoreName: '.s-details__s-name',
92
+ sDetailsInfo: '.s-details__info',
93
+ sDetailsMapHide: 's-details__map_hide',
94
+ sDetailsAddress: '.s-details__address',
95
+ chosenHide: 'chosen_hide',
96
+ chosenNearest: 'chosen__nearest',
97
+ chosenSuccess: 'chosen__success',
98
+ chosenError: 'chosen__error',
99
+ store: '.store',
100
+ storeName: '.store__name-text',
101
+ defaultStoreName: '.default-store__name-txt',
102
+ collapsed: 'collapsed',
103
+ show: 'show',
104
+ scrollDisable: 'scroll-disable',
105
+ bwMinHeight: 'bw_min-h',
106
+ copyLinkHovered: 'copy-link_hovered',
107
+ protoOnlyPopulated: 'proto-only-populated',
108
+ moreStoresPresent: 'more-stores-present',
109
+ defStoresPresent: 'def-stores-present',
110
+ CLICK_AND_COLLECT: 'FREE Click & Collect within 30 minutes',
111
+ CLICK_AND_COLLECT_NOT_AVAILABLE: 'Click & Collect not available',
112
+ };
113
+
114
+ function init() {
115
+ Wick.SnackBar.init();
116
+ bwVar.$stockTabs.on('click', bwVar.stockTab, function () {
117
+ if ($(bwVar.ccBtn).attr('disabled') && $(bwVar.ccBtn).hasClass('nearest-store-purchasable')) {
118
+ $(bwVar.ccBtn).removeAttr('disabled');
119
+ $(bwVar.ccBtn).find('.btn__text').text(bwVar.CLICK_AND_COLLECT);
120
+ }
121
+
122
+ if (!$(this).hasClass(bwVar.active)) {
123
+ //toggle tabs
124
+ $(this).closest(bwVar.$bigWins).find(bwVar.$stockTab).removeClass(bwVar.active);
125
+ $(this).addClass(bwVar.active);
126
+
127
+ $(this).closest(bwVar.$bigWins).find(bwVar.$stockFindBtn).unbind();
128
+
129
+ //show/close modal with more stores
130
+ if ($(this).attr('data-stores') === 'more') {
131
+
132
+ //open block
133
+ $(this).closest(bwVar.$bigWins).find(bwVar.$stock).addClass(bwVar.stockBot);
134
+ $(this).closest(bwVar.$bigWins).addClass(bwVar.bwMinHeight);
135
+
136
+ if ($(window).width() < 767) {
137
+ $(this).closest(bwVar.$bigWins).find(bwVar.$stock).addClass(bwVar.stockMore);
138
+ } else {
139
+ var self = this;
140
+ setTimeout(function () {
141
+ $(self).closest(bwVar.$bigWins).find(bwVar.$stock).addClass(bwVar.stockMore);
142
+ }, 1);
143
+ }
144
+
145
+ // remove ability collapse block
146
+ $(this).closest(bwVar.$bigWins).find(bwVar.$stockAccordion).removeAttr('data-toggle');
147
+
148
+ //event to show results
149
+ $(this).closest(bwVar.$bigWins).find(bwVar.$stockFindBtn).on('click', function (e) {
150
+ showSearchResultMore(e, this);
151
+ showSearchResultMoreProto(this);
152
+ });
153
+
154
+ //delete error validation
155
+ $(this).closest(bwVar.$bigWins).find(bwVar.$stockPostcodeEl).removeClass(bwVar.stockPostcodeInvalid);
156
+
157
+ if ($(window).width() < 767) {
158
+ //disable scroll for modal
159
+ bwVar.$body.addClass(bwVar.scrollDisable);
160
+ }
161
+
162
+ $(this).closest(bwVar.$bigWins).find(bwVar.stockItem).each(function () {
163
+ var attr = $(this).find('.stock__radio input').attr('checked');
553
164
  if (typeof attr !== 'undefined' && attr !== false) {
554
- var value = $(this).closest('.stock__item').find('.store__stock_val').text();
555
- if (!value.match(/^-{0,1}\d+$/)) {
556
- $(this)
557
- .closest('.stock__item')
558
- .find('.stock__valid')
559
- .addClass('stock__valid_show');
560
- $(bwVar.ccBtn).attr('disabled', 'disabled');
561
- $(bwVar.ccBtn).find('.btn__text').text(bwVar.CLICK_AND_COLLECT_NOT_AVAILABLE);
562
- }
165
+ var value = $(this).closest(bwVar.stockItem).find('.store__stock_val').text();
166
+ if (value.match(/^out$/)) {
167
+ $(this).closest(bwVar.stockItem).find('.stock__valid').addClass('stock__valid_show');
168
+ $(bwVar.ccBtn).attr('disabled', 'disabled');
169
+ $(bwVar.ccBtn).find('.btn__text').text(bwVar.CLICK_AND_COLLECT_NOT_AVAILABLE);
170
+ }
563
171
  }
564
- });
565
172
 
566
- //toggle map
567
- bwVar.$sDetailsToggleMap.on('click', function (e) {
568
- e.preventDefault();
569
- $(this).closest(bwVar.$bigWins).find(bwVar.$pdpPrice).removeClass(bwVar.pdpPriceBW);
570
-
571
- if (
572
- $(this)
573
- .closest(bwVar.sDetailsInfo)
574
- .find(bwVar.$sDetailsToggleMapText)
575
- .text()
576
- .trim() === 'Hide Map'
577
- ) {
578
- $(this)
579
- .closest(bwVar.sDetailsInfo)
580
- .find(bwVar.$sDetailsToggleMapText)
581
- .text('Show Map');
582
- $(this)
583
- .closest(bwVar.sDetailsInfo)
584
- .find(bwVar.$sDetailsMap)
585
- .addClass(bwVar.sDetailsMapHide);
586
- } else if (
587
- $(this)
588
- .closest(bwVar.sDetailsInfo)
589
- .find(bwVar.$sDetailsToggleMapText)
590
- .text()
591
- .trim() === 'Show Map'
592
- ) {
593
- $(this)
594
- .closest(bwVar.sDetailsInfo)
595
- .find(bwVar.$sDetailsToggleMapText)
596
- .text('Hide Map');
597
- $(this)
598
- .closest(bwVar.sDetailsInfo)
599
- .find(bwVar.$sDetailsMap)
600
- .removeClass(bwVar.sDetailsMapHide);
173
+ })
174
+
175
+ } else if ($(this).attr('data-stores') === 'nearest') {
176
+ //close more block
177
+ $(this).closest(bwVar.$bigWins).find(bwVar.$stock).removeClass(bwVar.stockMore);
178
+
179
+ if ($(window).width() < 767) {
180
+ $(this).closest(bwVar.$bigWins).find(bwVar.$stock).removeClass(bwVar.stockBot);
181
+ $(this).closest(bwVar.$bigWins).removeClass(bwVar.bwMinHeight);
182
+ } else {
183
+ var self = this;
184
+ setTimeout(function () {
185
+ $(self).closest(bwVar.$bigWins).find(bwVar.$stock).removeClass(bwVar.stockBot);
186
+ $(self).closest(bwVar.$bigWins).removeClass(bwVar.bwMinHeight);
187
+ }, 600);
188
+ }
189
+
190
+ // add ability collapse block
191
+ $(this).closest(bwVar.$bigWins).find(bwVar.$stockAccordion).attr('data-toggle', 'collapse');
192
+ //event to show results
193
+ $(this).closest(bwVar.$bigWins).find(bwVar.$stockFindBtn).on('click', showSearchResultNearest);
194
+ //unlock scroll for modal
195
+ bwVar.$body.removeClass(bwVar.scrollDisable);
196
+ //delete error validation
197
+ $(this).closest(bwVar.$bigWins).find(bwVar.$stockPostcodeEl).removeClass(bwVar.stockPostcodeInvalid);
198
+
199
+ scrollToBlockMobile(this);
200
+ }
201
+ }
202
+ closeStoreDetails(this);
203
+ });
204
+
205
+ bwVar.$stockFindBtn.on('click', function () {
206
+ showSearchResultNearest(this);
207
+ });
208
+
209
+ bwVar.$defStockTab.on('click', function (e) {
210
+ e.preventDefault();
211
+
212
+ bwVar.$stockResult.removeClass('stock__result_hide')
213
+ $(this).closest(bwVar.$bigWins).find(bwVar.$stock).addClass(bwVar.stockBot);
214
+ $(this).closest(bwVar.$bigWins).addClass(bwVar.bwMinHeight);
215
+
216
+ if ($(window).width() < 767) {
217
+ $(this).closest(bwVar.$bigWins).find(bwVar.$stock).addClass(bwVar.stockMore);
218
+ } else {
219
+ var self = this;
220
+ setTimeout(function () {
221
+ $(self).closest(bwVar.$bigWins).find(bwVar.$stock).addClass(bwVar.stockMore);
222
+ }, 1);
223
+ }
224
+ });
225
+
226
+ //choose default store in more stores section
227
+ bwVar.$storeState.on('click', function (e) {
228
+ let defVal = $(this).text().trim(),
229
+ toDefault = 'Make this your default store',
230
+ isDefault = 'Default store',
231
+ selectedStore = $(this).closest(bwVar.$store).html();
232
+
233
+ e.preventDefault();
234
+
235
+ if (defVal === toDefault) {
236
+ bwVar.$storeState.text(toDefault)
237
+ $(this).text(isDefault)
238
+ bwVar.$bwChosen.find(bwVar.$store).html(selectedStore);
239
+ bwVar.$storeState.parent().find(bwVar.$toDefaultIcon).hide()
240
+ bwVar.$storeState.parent().find(bwVar.$isDefaultIcon).show()
241
+
242
+ $(this).parent().find(bwVar.$isDefaultIcon).hide()
243
+ $(this).parent().find(bwVar.$toDefaultIcon).show()
244
+ }
245
+ else {
246
+ $(this).click(false)
247
+ }
248
+ });
249
+
250
+ //make store default from main page
251
+ bwVar.$nameDefault.on('click', function (e) {
252
+ e.preventDefault();
253
+ let makeDefValue = $(this).find(bwVar.defaultStoreName).text();
254
+
255
+ bwVar.$stockList.find(bwVar.storeName).each(function () {
256
+ if ($(this).text() === makeDefValue) {
257
+ $(this).closest(bwVar.$store).find('.store-state').click()
258
+ }
259
+ })
260
+
261
+ bwVar.$makeDefault.hide();
262
+ bwVar.$defaultInfo.hide();
263
+ bwVar.$defaultCurrent.show();
264
+
265
+ });
266
+
267
+ bwVar.$currentDefault.on('click', function (e) {
268
+ e.preventDefault();
269
+ let makeDefValue = $(this).find(bwVar.defaultStoreName).text();
270
+
271
+ bwVar.$stockList.find(bwVar.storeName).each(function () {
272
+ if ($(this).text() === makeDefValue) {
273
+ $(this).closest(bwVar.$store).find('.store-state').click()
274
+ }
275
+ })
276
+
277
+ bwVar.$makeDefault.hide();
278
+ bwVar.$defaultInfo.hide();
279
+ bwVar.$defaultCurrent.show();
280
+
281
+ });
282
+
283
+ //my-acc default store component logic
284
+ bwVar.$storeSearch.on('click', function (e) {
285
+ e.preventDefault();
286
+ bwVar.$storeSearch.hide();
287
+ bwVar.$stockPostcodeEl.show();
288
+ })
289
+
290
+ //my-acc scroll to default store component logic
291
+ $(".scrollToDefault").on('click', function(e) {
292
+ e.preventDefault();
293
+ var target = $(this).attr('href');
294
+ $('html, body').animate({
295
+ scrollTop: ($(target).offset().top)
296
+ }, 'slow');
297
+ });
298
+
299
+ bwVar.$findStore.on('click', function (e) {
300
+ e.preventDefault();
301
+
302
+ if($('.stock__input').val().length !== 0) {
303
+ bwVar.$stockPostcodeEl.removeClass(bwVar.stockPostcodeInvalid);
304
+ bwVar.$postCodeErrorMsg.hide();
305
+ bwVar.$bigWins.show();
306
+
307
+ if(bwVar.$bigWins.css('display') === 'block') {
308
+ bwVar.$bwActions.css('display', 'flex')
309
+ } else {
310
+ bwVar.$bwActions.hide()
311
+ }
312
+ } else {
313
+ bwVar.$stockPostcodeEl.addClass(bwVar.stockPostcodeInvalid);
314
+ bwVar.$postCodeErrorMsg.css('display', 'inherit');
315
+ }
316
+ })
317
+
318
+ bwVar.$addStore.on('click', function (e) {
319
+ e.preventDefault();
320
+ bwVar.$bigWins.hide();
321
+ bwVar.$stockPostcodeEl.hide();
322
+ bwVar.$storeChange.css('display', 'block');
323
+ bwVar.$bwActions.hide();
324
+ bwVar.$addStore.text('Update Default Store')
325
+ })
326
+
327
+ bwVar.$cancelStore.on('click', function (e) {
328
+ e.preventDefault();
329
+ bwVar.$bigWins.hide();
330
+ bwVar.$bwActions.hide();
331
+ bwVar.$stockPostcodeEl.hide();
332
+ bwVar.$storeSearch.show();
333
+ })
334
+
335
+ bwVar.$storeChange.on('click', function (e) {
336
+ e.preventDefault();
337
+ bwVar.$bigWins.show();
338
+ bwVar.$stockPostcodeEl.show();
339
+ bwVar.$bwActions.show();
340
+ bwVar.$storeChange.hide();
341
+ })
342
+
343
+ bwVar.$defStoreWrap.find(bwVar.$addStore).on('click', function (e) {
344
+ if($("input:radio[name='store']").is(":checked")) {
345
+ let currentInp = $("input:radio[name='store'][checked='checked']"),
346
+ selectedVal = currentInp.closest(bwVar.stockItem).find(bwVar.sDetailsAddress).text();
347
+
348
+ bwVar.$defStoreWrap.find('.table__content-address').text(selectedVal)
349
+ }
350
+ })
351
+
352
+ //show store details
353
+ bwVar.$storeMoreLink.on('click', function (e) {
354
+ e.preventDefault();
355
+
356
+ console.log($(this).closest('.basket').length);
357
+ if(!$(this).closest('.basket').length) {
358
+ var storeName = $(this)
359
+ .closest('.store')
360
+ .find(bwVar.storeName)
361
+ .text()
362
+ .trim()
363
+ .toLowerCase();
364
+
365
+ if ($(this).text().trim() === 'Store Info') {
366
+ closeStoreDetails(this);
367
+ $(this).closest(bwVar.$bigWins).find(bwVar.$stockRadio).find('input').removeAttr('checked');
368
+ $(this).closest(bwVar.stockItem).find(bwVar.$stockRadio).trigger('click');
369
+ $(this).closest(bwVar.stockItem).find(bwVar.$stockRadio).attr('checked', 'checked');
370
+
371
+ $(this).text('Hide Info');
372
+
373
+ //show pseudoclass
374
+ $(this).closest(bwVar.$bigWins).find(bwVar.$stock).addClass(bwVar.stockDetailsOpen);
375
+
376
+ //classes only for Price
377
+ console.log($(this).closest(bwVar.$pdpPrice).length);
378
+
379
+ if ($(this).closest(bwVar.$pdpPrice).length) {
380
+ $(this).closest(bwVar.$pdpPrice)
381
+ .addClass(bwVar.stockDetailsOpen);
382
+ $(this).closest(bwVar.$pdpPrice)
383
+ .addClass(bwVar.pdpPriceBW);
384
+ } else if ($(this).closest(bwVar.$tiTotal).length) {
385
+ $(this).closest(bwVar.$tiTotal)
386
+ .addClass(bwVar.stockDetailsOpen);
387
+ $(this).closest(bwVar.$tiTotal)
388
+ .addClass(bwVar.tiTotalBW);
389
+ }
390
+
391
+ $(this).closest(bwVar.$bigWins).find(bwVar.$sDetails).addClass(bwVar.sDetailsHide);
392
+ //open tab with current store
393
+ $(this).closest(bwVar.$bigWins).find(bwVar.$sDetails).each(function () {
394
+ if ($(this)
395
+ .find(bwVar.sDetailsStoreName)
396
+ .text()
397
+ .trim()
398
+ .toLowerCase() === storeName) {
399
+ $(this).removeClass(bwVar.sDetailsHide);
601
400
  }
602
- });
401
+ });
603
402
 
604
- bwVar.$stockQuestions.find('input').on('click', function () {
605
- if ($(this).attr('checked') === 'checked') {
606
- $(this).removeAttr('checked');
607
- } else {
608
- $(this).attr('checked', 'checked');
403
+ if (!bwVar.$ccOrder.length) {
404
+ if ($(window).width() < 767) {
405
+ //disable scroll for modal
406
+ bwVar.$body.addClass(bwVar.scrollDisable);
609
407
  }
610
- });
408
+ }
611
409
 
612
- bwVar.$stockClose.on('click', function (e) {
613
- closeMoreStorestModal(e, this);
614
- closeStoreDetails(this);
615
- });
616
-
617
- //come back to search tab
618
- bwVar.$stockEditBtn.on('click', function () {
619
- closeStoreDetails(this);
620
- $(this)
621
- .closest(bwVar.$bigWins)
622
- .find(bwVar.$stockResult)
623
- .addClass(bwVar.stockResultHide);
624
- $(this).closest(bwVar.$bigWins).find(bwVar.$stockTabs).removeClass(bwVar.stockTabsHide);
625
- $(this).closest(bwVar.$bigWins).find(bwVar.$stockFind).removeClass(bwVar.stockFindHide);
626
- });
627
-
628
- bwVar.$stockCancel.on('click', function (e) {
629
- closeMoreStorestModal(e, this);
410
+ } else if ($(this).text().trim() === 'Hide Info') {
411
+ closeStoreDetails(this);
412
+ }
413
+ }
414
+ });
415
+
416
+ //hide store details
417
+ bwVar.$sDetailsClose.on('click', function (e) {
418
+ e.preventDefault();
419
+ closeStoreDetails(this);
420
+ });
421
+
422
+ // show store via radio buttons
423
+ bwVar.$stockRadio.on('change', function () {
424
+ $(this).closest(bwVar.$bigWins).find('.stock__valid')
425
+ .removeClass('stock__valid_show');
426
+ if ( $(this).closest(bwVar.$bigWins).find(bwVar.ccBtn)
427
+ .attr('disabled')) {
428
+ $(this).closest(bwVar.$bigWins).find(bwVar.ccBtn)
429
+ .removeAttr('disabled');
430
+ $(this).closest(bwVar.$bigWins).find(bwVar.ccBtn)
431
+ .find('.btn__text').text(bwVar.CLICK_AND_COLLECT);
432
+ }
433
+
434
+ var openedInfo = false;
435
+ $(this).closest(bwVar.$bigWins).find('.s-details').each(function () {
436
+ if (!$(this).hasClass('s-details_hide')) {
437
+ openedInfo = true
438
+ }
439
+ });
440
+
441
+ if (openedInfo) {
442
+ var storeName = $(this)
443
+ .closest('.stock__item')
444
+ .find(bwVar.storeName)
445
+ .text()
446
+ .trim()
447
+ .toLowerCase();
448
+ $(this).closest(bwVar.$bigWins).find(bwVar.$storeMoreLink).text('Store Info');
449
+ $(this).closest('.stock__item').find(bwVar.$storeMoreLink).text('Hide Info');
450
+
451
+ //show pseudoclass
452
+ $(this).closest(bwVar.$bigWins).find(bwVar.$stock).addClass(bwVar.stockDetailsOpen);
453
+ $(this).closest(bwVar.$bigWins).find(bwVar.$pdpPrice).addClass(bwVar.stockDetailsOpen);
454
+
455
+ $(this).closest(bwVar.$pdpPrice).addClass(bwVar.pdpPriceBW);
456
+
457
+ $(this).closest(bwVar.$bigWins).find(bwVar.$sDetails)
458
+ .addClass(bwVar.sDetailsHide);
459
+
460
+ //open tab with current store
461
+ $(this).closest(bwVar.$bigWins).find(bwVar.$sDetails)
462
+ .each(function () {
463
+ if ($(this)
464
+ .find(bwVar.sDetailsStoreName)
465
+ .text()
466
+ .trim()
467
+ .toLowerCase() === storeName) {
468
+ $(this).removeClass(bwVar.sDetailsHide);
469
+ }
630
470
  });
631
471
 
632
- //C&C btn
633
- bwVar.$bigWins.on('click', bwVar.ccBtn, function (e) {
634
- closeMoreStorestModal(e, this);
472
+ if ($(window).width() < 767) {
473
+ //disable scroll for modal
474
+ bwVar.$body.addClass(bwVar.scrollDisable);
475
+ }
635
476
 
636
- //hide store info
637
- $(this).closest(bwVar.$bigWins).find(bwVar.$sDetails).addClass(bwVar.sDetailsHide);
638
- $(this).closest(bwVar.$pdpPrice).removeClass(bwVar.pdpPriceBW);
477
+ } else {
478
+ closeStoreDetails(this)
479
+ }
480
+
481
+ $(this).trigger('click');
482
+ $(this).closest(bwVar.$bigWins).find(bwVar.$stockRadio).find('input').removeAttr('checked');
483
+ $(this).find('input').attr('checked', 'checked');
484
+
485
+ var attr = $(this).find('input').attr('checked');
486
+ if (typeof attr !== 'undefined' && attr !== false) {
487
+ var value = $(this).closest('.stock__item').find('.store__stock_val').text();
488
+ if (!value.match(/^-{0,1}\d+$/)) {
489
+ $(this).closest('.stock__item').find('.stock__valid').addClass('stock__valid_show');
490
+ $(bwVar.ccBtn).attr('disabled', 'disabled');
491
+ $(bwVar.ccBtn).find('.btn__text').text(bwVar.CLICK_AND_COLLECT_NOT_AVAILABLE);
492
+ }
493
+ }
494
+ });
495
+
496
+ //toggle map
497
+ bwVar.$sDetailsToggleMap.on('click', function (e) {
498
+ e.preventDefault();
499
+ $(this).closest(bwVar.$bigWins).find(bwVar.$pdpPrice).removeClass(bwVar.pdpPriceBW);
500
+
501
+ if ($(this)
502
+ .closest(bwVar.sDetailsInfo)
503
+ .find(bwVar.$sDetailsToggleMapText)
504
+ .text()
505
+ .trim() === 'Hide Map'
506
+ ) {
507
+ $(this)
508
+ .closest(bwVar.sDetailsInfo)
509
+ .find(bwVar.$sDetailsToggleMapText)
510
+ .text('Show Map');
511
+ $(this)
512
+ .closest(bwVar.sDetailsInfo)
513
+ .find(bwVar.$sDetailsMap)
514
+ .addClass(bwVar.sDetailsMapHide);
515
+ } else if ($(this)
516
+ .closest(bwVar.sDetailsInfo)
517
+ .find(bwVar.$sDetailsToggleMapText)
518
+ .text()
519
+ .trim() === 'Show Map'
520
+ ) {
521
+ $(this)
522
+ .closest(bwVar.sDetailsInfo)
523
+ .find(bwVar.$sDetailsToggleMapText)
524
+ .text('Hide Map');
525
+ $(this)
526
+ .closest(bwVar.sDetailsInfo)
527
+ .find(bwVar.$sDetailsMap)
528
+ .removeClass(bwVar.sDetailsMapHide);
529
+ }
530
+ });
531
+
532
+ bwVar.$stockQuestions.find('input').on('click', function () {
533
+ if ($(this).attr('checked') === 'checked') {
534
+ $(this).removeAttr('checked')
535
+ } else {
536
+ $(this).attr('checked', 'checked');
537
+ }
538
+ });
539
+
540
+ bwVar.$stockClose.on('click', function (e) {
541
+ closeMoreStorestModal(e, this);
542
+ closeStoreDetails(this);
543
+ });
544
+
545
+ //come back to search tab
546
+ bwVar.$stockEditBtn.on('click', function () {
547
+ closeStoreDetails(this);
548
+ $(this).closest(bwVar.$bigWins).find(bwVar.$stockResult)
549
+ .addClass(bwVar.stockResultHide);
550
+ $(this).closest(bwVar.$bigWins).find(bwVar.$stockTabs)
551
+ .removeClass(bwVar.stockTabsHide);
552
+ $(this).closest(bwVar.$bigWins).find(bwVar.$stockFind)
553
+ .removeClass(bwVar.stockFindHide);
554
+ });
555
+
556
+ bwVar.$stockCancel.on('click', function (e) {
557
+ closeMoreStorestModal(e, this);
558
+ });
559
+
560
+ //C&C btn
561
+ bwVar.$bigWins.on('click', bwVar.ccBtn, function (e) {
562
+ closeMoreStorestModal(e, this);
563
+
564
+ //hide store info
565
+ $(this).closest(bwVar.$bigWins).find(bwVar.$sDetails)
566
+ .addClass(bwVar.sDetailsHide);
567
+ $(this).closest(bwVar.$pdpPrice).removeClass(bwVar.pdpPriceBW);
568
+
569
+ //show store info
570
+ $(this).closest(bwVar.$bigWins).find(bwVar.$chosen).removeClass(bwVar.chosenHide);
571
+
572
+ if ($(this).closest(bwVar.$bigWins).hasClass('bw_unhappy')) {
573
+ $(this).closest(bwVar.$bigWins).find(bwVar.$chosen).addClass(bwVar.chosenError);
574
+ } else {
575
+ $(this).closest(bwVar.$bigWins).find(bwVar.$chosen).addClass(bwVar.chosenSuccess);
576
+ }
577
+
578
+
579
+ //hide pseudoclass
580
+ $(this).closest(bwVar.$bigWins).find(bwVar.$stock).removeClass(bwVar.stockDetailsOpen);
581
+
582
+ //unlock scroll for modal
583
+ bwVar.$body.removeClass(bwVar.scrollDisable);
584
+
585
+ scrollToBlockMobile(this);
586
+ });
587
+
588
+ bwVar.$sDetailsCopy.on('click', function (e) {
589
+ e.preventDefault();
590
+ var $temp = $('<input>');
591
+ $(this.parentElement).append($temp);//workaround for iPad scrolling
592
+ var text = $(this).closest(bwVar.sDetails).find(bwVar.$sDetailsAddress).text().trim();
593
+ var str = text.replace(/(^\w|\s\w)/g, function (m) {
594
+ return m.toUpperCase()
595
+ });
596
+ var textFiltered = str.split(' ').filter(function (value) {
597
+ return value !== ''
598
+ });
599
+ var textTrimmed = textFiltered.join(' ');
600
+ $temp.val(textTrimmed);
601
+ if (navigator.userAgent.match(/TradeProMobile_iOS|DIYMobile_iOS/i)) {
602
+ iosCopyToClipboard($temp);
603
+ } else if (navigator.userAgent.match(/ipad|ipod|iphone/i)) {
604
+ $temp.select();
605
+ $temp.setSelectionRange(0, 999999);
606
+ } else {
607
+ $temp.select();
608
+ }
609
+
610
+ document.execCommand("copy");
611
+ $(this).addClass(bwVar.copyLinkHovered);
612
+ $temp.remove();
613
+ });
614
+
615
+ // bwVar.$addForDelivery.on('click', function () {
616
+ // Wick.SnackBar.show(
617
+ // {
618
+ // text: 'Notification success message for Delivery with Close Btn',
619
+ // type: Wick.SnackBar.types.SUCCESS
620
+ // }
621
+ // );
622
+ // Wick.SnackBar.show(
623
+ // {
624
+ // text: 'Notification warning message for Delivery with Close Btn',
625
+ // type: Wick.SnackBar.types.WARNING
626
+ // }
627
+ // );
628
+ // Wick.SnackBar.show(
629
+ // {
630
+ // text: 'Notification error message for Delivery with Close Btn',
631
+ // type: Wick.SnackBar.types.ERROR
632
+ // }
633
+ // );
634
+ // Wick.SnackBar.show(
635
+ // {
636
+ // text: 'Notification success message for Delivery with Autoclose',
637
+ // type: Wick.SnackBar.types.SUCCESS,
638
+ // withCloseButton: false,
639
+ // autoClose: true,
640
+ // delayBeforeClose: 3000
641
+ // }
642
+ // );
643
+ // });
644
+
645
+ bwVar.$addClickAndCollect.on('click', function (e) {
646
+ e.stopPropagation();
647
+ Wick.SnackBar.show(
648
+ {
649
+ text: 'Notification success message for Click & Collect with Close Btn',
650
+ type: Wick.SnackBar.types.SUCCESS,
651
+ withCloseButton: true,
652
+ }
653
+ );
654
+ Wick.SnackBar.show(
655
+ {
656
+ text: 'Notification warning message for Click & Collect with Close Btn',
657
+ type: Wick.SnackBar.types.WARNING,
658
+ withCloseButton: true,
659
+ }
660
+ );
661
+ Wick.SnackBar.show(
662
+ {
663
+ text: 'Notification error message for Click & Collect with Close Btn',
664
+ type: Wick.SnackBar.types.ERROR,
665
+ withCloseButton: true,
666
+ }
667
+ );
668
+ Wick.SnackBar.show(
669
+ {
670
+ text: 'Notification success message for Click & Collect with Autoclose',
671
+ type: Wick.SnackBar.types.SUCCESS,
672
+ withCloseButton: false,
673
+ autoClose: true,
674
+ delayBeforeClose: 3000
675
+ }
676
+ );
677
+ })
678
+
679
+ //func to show results
680
+ function showSearchResultMore(e, context) {
681
+ e.preventDefault();
682
+ var postcodeLength = $(context).closest(bwVar.$bigWins).find(bwVar.$stockPostcode).val().length;
683
+
684
+ $(context).closest(bwVar.$bigWins).find(bwVar.$stockPostcodeEl).removeClass(bwVar.stockPostcodeInvalid);
685
+
686
+ if (postcodeLength >= 5) {
687
+ if ($(window).width() < 767) {
688
+ bwVar.$body.addClass(bwVar.scrollDisable);
689
+ }
690
+ //open new section
691
+ if (!$(context).closest(bwVar.$bigWins).find(bwVar.$stockTabs).hasClass('more-stores-present')) {
692
+ $(context).closest(bwVar.$bigWins).find(bwVar.$stockResult).removeClass(bwVar.stockResultHide);
693
+ } else {
694
+ $(context).closest(bwVar.$bigWins).find(bwVar.$stockTabs).addClass(bwVar.stockTabsHide);
695
+ $(context).closest(bwVar.$bigWins).find(bwVar.$stockFind).addClass(bwVar.stockFindHide);
696
+ }
639
697
 
640
- //show store info
641
- $(this).closest(bwVar.$bigWins).find(bwVar.$chosen).removeClass(bwVar.chosenHide);
698
+ //clean classes for descr
699
+ $(context).closest(bwVar.$bigWins).find(bwVar.$stockDescr).removeClass(bwVar.stockDescrS);
700
+ $(context).closest(bwVar.$bigWins).find(bwVar.$stockDescr).removeClass(bwVar.stockDescrC);
701
+
702
+ var quantity = $(context).closest(bwVar.$bigWins).find(bwVar.$stockQuantity).val(),
703
+ postcode = $(context).closest(bwVar.$bigWins).find(bwVar.$stockPostcode).val(),
704
+ onlyStock = $(context).closest(bwVar.$bigWins)
705
+ .find(bwVar.$stockQuestions)
706
+ .find('input[name="stock-only"]')
707
+ .attr('checked') === 'checked',
708
+ onlyCC = $(context).closest(bwVar.$bigWins)
709
+ .find(bwVar.$stockQuestions)
710
+ .find('input[name="cc-only"]')
711
+ .attr('checked') === 'checked';
712
+
713
+ //amend text in info block
714
+ $(context).closest(bwVar.$bigWins).find(bwVar.$stockAmount).text(quantity);
715
+ $(context).closest(bwVar.$bigWins).find(bwVar.$stockPost).text(postcode);
716
+
717
+ if (onlyCC !== onlyStock) {
718
+ if (onlyStock) {
719
+ $(context).closest(bwVar.$bigWins).find(bwVar.$stockDescr).addClass(bwVar.stockDescrS)
720
+ } else if (onlyCC) {
721
+ $(context).closest(bwVar.$bigWins).find(bwVar.$stockDescr).addClass(bwVar.stockDescrC)
722
+ }
723
+ } else if (onlyStock === false && onlyCC === false) {
724
+ $(context).closest(bwVar.$bigWins).find(bwVar.$stockDescr).addClass(bwVar.stockDescrS)
725
+ }
726
+ } else {
727
+ $(context).closest(bwVar.$bigWins).find(bwVar.$stockPostcodeEl).addClass(bwVar.stockPostcodeInvalid);
728
+ }
729
+ }
642
730
 
643
- if ($(this).closest(bwVar.$bigWins).hasClass('bw_unhappy')) {
644
- $(this).closest(bwVar.$bigWins).find(bwVar.$chosen).addClass(bwVar.chosenError);
645
- } else {
646
- $(this).closest(bwVar.$bigWins).find(bwVar.$chosen).addClass(bwVar.chosenSuccess);
731
+ function showSearchResultNearest(context) {
732
+ var postcodeLength = $(context).closest(bwVar.$bigWins).find(bwVar.$stockPostcode).val().length;
733
+
734
+ if (postcodeLength >= 5) {
735
+ closeStoreDetails(context);
736
+ $(context).closest(bwVar.$bigWins).find(bwVar.$stockPostcodeEl)
737
+ .removeClass(bwVar.stockPostcodeInvalid);
738
+ $(context).closest(bwVar.$bigWins).find(bwVar.$chosen)
739
+ .removeClass(bwVar.chosenHide);
740
+ $(context).closest(bwVar.$bigWins).find(bwVar.$chosen)
741
+ .addClass(bwVar.chosenNearest);
742
+
743
+ scrollToBlockMobile(context);
744
+
745
+ var value = $(context).closest(bwVar.$bigWins).find('.chosen__nearest')
746
+ .find('.store__stock_val').text();
747
+ if (value.match(/^out$/)) {
748
+ $(context).closest(bwVar.$bigWins).find('.chosen__nearest')
749
+ .find('.stock__valid').addClass('stock__valid_show');
750
+ $(context).closest(bwVar.$bigWins).find(bwVar.ccBtn)
751
+ .attr('disabled', 'disabled');
752
+ $(context).closest(bwVar.$bigWins).find(bwVar.ccBtn)
753
+ .find('.btn__text').text(bwVar.CLICK_AND_COLLECT_NOT_AVAILABLE);
754
+ } else {
755
+ if ($(context).closest(bwVar.$bigWins)
756
+ .find('#isCnCForProductAndStoreDisabled').val() === "true") {
757
+ $(context).closest(bwVar.$bigWins).find('.chosen__nearest')
758
+ .find('.stock__valid').addClass('stock__valid_show');
759
+ $(context).closest(bwVar.$bigWins).find(bwVar.ccBtn)
760
+ .attr('disabled', 'disabled');
761
+ $(context).closest(bwVar.$bigWins).find(bwVar.ccBtn)
762
+ .find('.btn__text').text(bwVar.CLICK_AND_COLLECT_NOT_AVAILABLE);
763
+ } else {
764
+ $(context).closest(bwVar.$bigWins).find('.chosen__nearest')
765
+ .find('.stock__valid').removeClass('stock__valid_show');
766
+ if ($(context).closest(bwVar.$bigWins).find(bwVar.ccBtn)
767
+ .attr('disabled')) {
768
+ $(context).closest(bwVar.$bigWins).find(bwVar.ccBtn)
769
+ .removeAttr('disabled');
770
+ $(context).closest(bwVar.$bigWins).find(bwVar.ccBtn)
771
+ .find('.btn__text').text(bwVar.CLICK_AND_COLLECT);
647
772
  }
773
+ }
774
+ }
775
+ } else {
776
+ $(context).closest(bwVar.$bigWins).find(bwVar.$stockPostcodeEl)
777
+ .addClass(bwVar.stockPostcodeInvalid);
778
+ }
779
+ }
648
780
 
649
- //hide pseudoclass
650
- $(this).closest(bwVar.$bigWins).find(bwVar.$stock).removeClass(bwVar.stockDetailsOpen);
651
-
652
- //unlock scroll for modal
653
- bwVar.$body.removeClass(bwVar.scrollDisable);
781
+ function closeMoreStorestModal(e, context) {
782
+ e.preventDefault();
783
+ //close more block
784
+ $(context).closest(bwVar.$bigWins).find(bwVar.$stock)
785
+ .removeClass(bwVar.stockMore);
786
+
787
+ if ($(window).width() < 767) {
788
+ $(context).closest(bwVar.$bigWins).find(bwVar.$stock)
789
+ .removeClass(bwVar.stockBot);
790
+ $(context).closest(bwVar.$bigWins).removeClass(bwVar.bwMinHeight);
791
+ } else {
792
+ setTimeout(function () {
793
+ $(context).closest(bwVar.$bigWins).find(bwVar.$stock)
794
+ .removeClass(bwVar.stockBot);
795
+ $(context).closest(bwVar.$bigWins)
796
+ .removeClass(bwVar.bwMinHeight);
797
+ }, 600);
798
+ }
799
+
800
+ //bind nearestStore event
801
+ $(context).closest(bwVar.$bigWins).find(bwVar.$stockFindBtn)
802
+ .unbind();
803
+ $(context).closest(bwVar.$bigWins).find(bwVar.$stockFindBtn)
804
+ .on('click', showSearchResultNearest);
805
+
806
+ //toggle tabs to nearest
807
+ $(context).closest(bwVar.$bigWins).find(bwVar.$stock)
808
+ .removeClass(bwVar.stockMore);
809
+ $(context).closest(bwVar.$bigWins).find(bwVar.$stockTab)
810
+ .removeClass(bwVar.active);
811
+ $(context).closest(bwVar.$bigWins).find(bwVar.$stockTab)
812
+ .first().addClass(bwVar.active);
813
+
814
+ $(context).closest(bwVar.$bigWins).find(bwVar.$stockResult)
815
+ .addClass(bwVar.stockResultHide);
816
+ $(context).closest(bwVar.$bigWins).find(bwVar.$stockTabs)
817
+ .removeClass(bwVar.stockTabsHide);
818
+ $(context).closest(bwVar.$bigWins).find(bwVar.$stockFind)
819
+ .removeClass(bwVar.stockFindHide);
820
+
821
+ bwVar.$body.removeClass(bwVar.scrollDisable);
822
+
823
+ scrollToBlockMobile(context);
824
+ }
654
825
 
655
- scrollToBlockMobile(this);
656
- });
826
+ function closeStoreDetails(context) {
827
+ bwVar.$storeMoreLink.text('Store Info');
828
+ //hide pseudoclass
829
+ $(context).closest(bwVar.$bigWins).find(bwVar.$stock)
830
+ .removeClass(bwVar.stockDetailsOpen);
831
+ $(context).closest(bwVar.$bigWins).find(bwVar.$sDetails)
832
+ .addClass(bwVar.sDetailsHide);
833
+ bwVar.$pdpPrice.removeClass(bwVar.pdpPriceBW);
834
+ bwVar.$tiTotal.removeClass(bwVar.tiTotalBW);
835
+ bwVar.$body.removeClass(bwVar.scrollDisable);
836
+
837
+ scrollToBlockMobile(context);
838
+ }
657
839
 
658
- bwVar.$sDetailsCopy.on('click', function (e) {
659
- e.preventDefault();
660
- var $temp = $('<input>');
661
- $(this.parentElement).append($temp); //workaround for iPad scrolling
662
- var text = $(this).closest(bwVar.sDetails).find(bwVar.$sDetailsAddress).text().trim();
663
- var str = text.replace(/(^\w|\s\w)/g, function (m) {
664
- return m.toUpperCase();
665
- });
666
- var textFiltered = str.split(' ').filter(function (value) {
667
- return value !== '';
668
- });
669
- var textTrimmed = textFiltered.join(' ');
670
- $temp.val(textTrimmed);
671
- if (navigator.userAgent.match(/TradeProMobile_iOS|DIYMobile_iOS/i)) {
672
- iosCopyToClipboard($temp);
673
- } else if (navigator.userAgent.match(/ipad|ipod|iphone/i)) {
674
- $temp.select();
675
- $temp.setSelectionRange(0, 999999);
676
- } else {
677
- $temp.select();
678
- }
840
+ function showSearchResultMoreProto(context) {
841
+ if ($(context).closest(bwVar.$bigWins).find('.stock__tab.active').attr('data-stores') === 'more') {
842
+ var postcodeLength;
843
+
844
+ if ($(context).closest(bwVar.$bigWins).find(bwVar.$bwChosen).hasClass(bwVar.protoOnlyPopulated)) {
845
+ postcodeLength = $(context).closest(bwVar.$bigWins)
846
+ .find(bwVar.$protoOnlyPopulated)
847
+ .find(bwVar.storeName)
848
+ .text().length;
849
+ } else {
850
+ postcodeLength = $(context).closest(bwVar.$bigWins).find(bwVar.$stockPostcode).val().length;
851
+ }
679
852
 
680
- document.execCommand('copy');
681
- $(this).addClass(bwVar.copyLinkHovered);
682
- $temp.remove();
683
- });
853
+ if (postcodeLength >= 5) {
854
+ if ($(context).closest(bwVar.$bigWins).find(bwVar.$stockTabs).hasClass(bwVar.moreStoresPresent || bwVar.defStoresPresent)) {
855
+ $(context).closest(bwVar.$bigWins).find(bwVar.$stockResult).removeClass(bwVar.stockResultHide);
856
+ }
857
+ }
858
+ }
859
+ }
684
860
 
685
- // bwVar.$addForDelivery.on('click', function () {
686
- // Wick.SnackBar.show(
687
- // {
688
- // text: 'Notification success message for Delivery with Close Btn',
689
- // type: Wick.SnackBar.types.SUCCESS
690
- // }
691
- // );
692
- // Wick.SnackBar.show(
693
- // {
694
- // text: 'Notification warning message for Delivery with Close Btn',
695
- // type: Wick.SnackBar.types.WARNING
696
- // }
697
- // );
698
- // Wick.SnackBar.show(
699
- // {
700
- // text: 'Notification error message for Delivery with Close Btn',
701
- // type: Wick.SnackBar.types.ERROR
702
- // }
703
- // );
704
- // Wick.SnackBar.show(
705
- // {
706
- // text: 'Notification success message for Delivery with Autoclose',
707
- // type: Wick.SnackBar.types.SUCCESS,
708
- // withCloseButton: false,
709
- // autoClose: true,
710
- // delayBeforeClose: 3000
711
- // }
712
- // );
713
- // });
714
-
715
- bwVar.$addClickAndCollect.on('click', function (e) {
716
- e.stopPropagation();
717
- Wick.SnackBar.show({
718
- text: 'Notification success message for Click & Collect with Close Btn',
719
- type: Wick.SnackBar.types.SUCCESS,
720
- withCloseButton: true,
721
- });
722
- Wick.SnackBar.show({
723
- text: 'Notification warning message for Click & Collect with Close Btn',
724
- type: Wick.SnackBar.types.WARNING,
725
- withCloseButton: true,
726
- });
727
- Wick.SnackBar.show({
728
- text: 'Notification error message for Click & Collect with Close Btn',
729
- type: Wick.SnackBar.types.ERROR,
730
- withCloseButton: true,
731
- });
732
- Wick.SnackBar.show({
733
- text: 'Notification success message for Click & Collect with Autoclose',
734
- type: Wick.SnackBar.types.SUCCESS,
735
- withCloseButton: false,
736
- autoClose: true,
737
- delayBeforeClose: 3000,
738
- });
739
- });
861
+ function iosCopyToClipboard($input) {
862
+ var el = $input.get(0);
863
+ var editable = el.contentEditable;
864
+ var readOnly = el.readOnly;
865
+
866
+ el.contentEditable = true;
867
+ el.readOnly = false;
868
+ var range = document.createRange();
869
+ range.selectNodeContents(el);
870
+ var sel = window.getSelection();
871
+ sel.removeAllRanges();
872
+ sel.addRange(range);
873
+ el.setSelectionRange(0, 999999);
874
+ el.contentEditable = editable;
875
+ el.readOnly = readOnly;
876
+ }
740
877
 
741
- //func to show results
742
- function showSearchResultMore(e, context) {
743
- e.preventDefault();
744
- var postcodeLength = $(context)
745
- .closest(bwVar.$bigWins)
746
- .find(bwVar.$stockPostcode)
747
- .val().length;
748
-
749
- $(context)
750
- .closest(bwVar.$bigWins)
751
- .find(bwVar.$stockPostcodeEl)
752
- .removeClass(bwVar.stockPostcodeInvalid);
753
-
754
- if (postcodeLength >= 5) {
755
- if ($(window).width() < 767) {
756
- bwVar.$body.addClass(bwVar.scrollDisable);
757
- }
758
- //open new section
759
- if (
760
- !$(context)
761
- .closest(bwVar.$bigWins)
762
- .find(bwVar.$stockTabs)
763
- .hasClass('more-stores-present')
764
- ) {
765
- $(context)
766
- .closest(bwVar.$bigWins)
767
- .find(bwVar.$stockResult)
768
- .removeClass(bwVar.stockResultHide);
769
- } else {
770
- $(context)
771
- .closest(bwVar.$bigWins)
772
- .find(bwVar.$stockTabs)
773
- .addClass(bwVar.stockTabsHide);
774
- $(context)
775
- .closest(bwVar.$bigWins)
776
- .find(bwVar.$stockFind)
777
- .addClass(bwVar.stockFindHide);
778
- }
779
-
780
- //clean classes for descr
781
- $(context)
782
- .closest(bwVar.$bigWins)
783
- .find(bwVar.$stockDescr)
784
- .removeClass(bwVar.stockDescrS);
785
- $(context)
786
- .closest(bwVar.$bigWins)
787
- .find(bwVar.$stockDescr)
788
- .removeClass(bwVar.stockDescrC);
789
-
790
- var quantity = $(context).closest(bwVar.$bigWins).find(bwVar.$stockQuantity).val(),
791
- postcode = $(context).closest(bwVar.$bigWins).find(bwVar.$stockPostcode).val(),
792
- onlyStock =
793
- $(context)
794
- .closest(bwVar.$bigWins)
795
- .find(bwVar.$stockQuestions)
796
- .find('input[name="stock-only"]')
797
- .attr('checked') === 'checked',
798
- onlyCC =
799
- $(context)
800
- .closest(bwVar.$bigWins)
801
- .find(bwVar.$stockQuestions)
802
- .find('input[name="cc-only"]')
803
- .attr('checked') === 'checked';
804
-
805
- //amend text in info block
806
- $(context).closest(bwVar.$bigWins).find(bwVar.$stockAmount).text(quantity);
807
- $(context).closest(bwVar.$bigWins).find(bwVar.$stockPost).text(postcode);
808
-
809
- if (onlyCC !== onlyStock) {
810
- if (onlyStock) {
811
- $(context)
812
- .closest(bwVar.$bigWins)
813
- .find(bwVar.$stockDescr)
814
- .addClass(bwVar.stockDescrS);
815
- } else if (onlyCC) {
816
- $(context)
817
- .closest(bwVar.$bigWins)
818
- .find(bwVar.$stockDescr)
819
- .addClass(bwVar.stockDescrC);
820
- }
821
- } else if (onlyStock === false && onlyCC === false) {
822
- $(context)
823
- .closest(bwVar.$bigWins)
824
- .find(bwVar.$stockDescr)
825
- .addClass(bwVar.stockDescrS);
826
- }
827
- } else {
828
- $(context)
829
- .closest(bwVar.$bigWins)
830
- .find(bwVar.$stockPostcodeEl)
831
- .addClass(bwVar.stockPostcodeInvalid);
832
- }
878
+ function scrollToBlockMobile (context) {
879
+ if ($(window).width() < 767) {
880
+ if($(context).closest(bwVar.$tiTotal).length) {
881
+ window.scroll(0, bwVar.$tiTotal.offset().top - 60);
882
+ } else if ($(context).closest(bwVar.$pdpPrice).length) {
883
+ window.scroll(0, bwVar.$bigWins.offset().top - 60);
833
884
  }
885
+ }
886
+ }
834
887
 
835
- function showSearchResultNearest(context) {
836
- var postcodeLength = $(context)
837
- .closest(bwVar.$bigWins)
838
- .find(bwVar.$stockPostcode)
839
- .val().length;
840
-
841
- if (postcodeLength >= 5) {
842
- closeStoreDetails(context);
843
- $(context)
844
- .closest(bwVar.$bigWins)
845
- .find(bwVar.$stockPostcodeEl)
846
- .removeClass(bwVar.stockPostcodeInvalid);
847
- $(context)
848
- .closest(bwVar.$bigWins)
849
- .find(bwVar.$chosen)
850
- .removeClass(bwVar.chosenHide);
851
- $(context)
852
- .closest(bwVar.$bigWins)
853
- .find(bwVar.$chosen)
854
- .addClass(bwVar.chosenNearest);
855
-
856
- scrollToBlockMobile(context);
857
-
858
- var value = $(context)
859
- .closest(bwVar.$bigWins)
860
- .find('.chosen__nearest')
861
- .find('.store__stock_val')
862
- .text();
863
- if (value.match(/^out$/)) {
864
- $(context)
865
- .closest(bwVar.$bigWins)
866
- .find('.chosen__nearest')
867
- .find('.stock__valid')
868
- .addClass('stock__valid_show');
869
- $(context)
870
- .closest(bwVar.$bigWins)
871
- .find(bwVar.ccBtn)
872
- .attr('disabled', 'disabled');
873
- $(context)
874
- .closest(bwVar.$bigWins)
875
- .find(bwVar.ccBtn)
876
- .find('.btn__text')
877
- .text(bwVar.CLICK_AND_COLLECT_NOT_AVAILABLE);
878
- } else {
879
- if (
880
- $(context)
881
- .closest(bwVar.$bigWins)
882
- .find('#isCnCForProductAndStoreDisabled')
883
- .val() === 'true'
884
- ) {
885
- $(context)
886
- .closest(bwVar.$bigWins)
887
- .find('.chosen__nearest')
888
- .find('.stock__valid')
889
- .addClass('stock__valid_show');
890
- $(context)
891
- .closest(bwVar.$bigWins)
892
- .find(bwVar.ccBtn)
893
- .attr('disabled', 'disabled');
894
- $(context)
895
- .closest(bwVar.$bigWins)
896
- .find(bwVar.ccBtn)
897
- .find('.btn__text')
898
- .text(bwVar.CLICK_AND_COLLECT_NOT_AVAILABLE);
899
- } else {
900
- $(context)
901
- .closest(bwVar.$bigWins)
902
- .find('.chosen__nearest')
903
- .find('.stock__valid')
904
- .removeClass('stock__valid_show');
905
- if ($(context).closest(bwVar.$bigWins).find(bwVar.ccBtn).attr('disabled')) {
906
- $(context)
907
- .closest(bwVar.$bigWins)
908
- .find(bwVar.ccBtn)
909
- .removeAttr('disabled');
910
- $(context)
911
- .closest(bwVar.$bigWins)
912
- .find(bwVar.ccBtn)
913
- .find('.btn__text')
914
- .text(bwVar.CLICK_AND_COLLECT);
915
- }
916
- }
917
- }
918
- } else {
919
- $(context)
920
- .closest(bwVar.$bigWins)
921
- .find(bwVar.$stockPostcodeEl)
922
- .addClass(bwVar.stockPostcodeInvalid);
923
- }
888
+ (function checkStoreProductsNearest() {
889
+ var value = $('.chosen__item').find('.store__stock_val').text();
890
+ if (value.match(/^out$/)) {
891
+ $('.chosen').find('.stock__valid').addClass('stock__valid_show');
892
+ $(bwVar.ccBtn).attr('disabled', 'disabled');
893
+ $(bwVar.ccBtn).find('.btn__text').text(bwVar.CLICK_AND_COLLECT_NOT_AVAILABLE);
894
+ } else {
895
+ if ($('#isCnCForProductAndStoreDisabled').val() === "true") {
896
+ $('.chosen__nearest').find('.stock__valid').addClass('stock__valid_show')
897
+ $(bwVar.ccBtn).attr('disabled', 'disabled');
898
+ $(bwVar.ccBtn).find('.btn__text').text(bwVar.CLICK_AND_COLLECT_NOT_AVAILABLE);
899
+ } else {
900
+ $('.chosen__nearest').find('.stock__valid').removeClass('stock__valid_show');
901
+ if ($(bwVar.ccBtn).attr('disabled')) {
902
+ $(bwVar.ccBtn).removeAttr('disabled');
903
+ $(bwVar.ccBtn).find('.btn__text').text(bwVar.CLICK_AND_COLLECT);
904
+ }
924
905
  }
906
+ }
907
+ })();
925
908
 
926
- function closeMoreStorestModal(e, context) {
927
- e.preventDefault();
928
- //close more block
929
- $(context).closest(bwVar.$bigWins).find(bwVar.$stock).removeClass(bwVar.stockMore);
909
+ (function getCorrectIdToCheckbox() {
910
+ bwVar.$stockQuestions.each(function (index) {
911
+ $(this).find("label[for='stock-only']").attr('for', 'stock-only' + index);
912
+ $(this).find("label[for='cc-only']").attr('for', 'cc-only' + index);
930
913
 
931
- if ($(window).width() < 767) {
932
- $(context).closest(bwVar.$bigWins).find(bwVar.$stock).removeClass(bwVar.stockBot);
933
- $(context).closest(bwVar.$bigWins).removeClass(bwVar.bwMinHeight);
934
- } else {
935
- setTimeout(function () {
936
- $(context)
937
- .closest(bwVar.$bigWins)
938
- .find(bwVar.$stock)
939
- .removeClass(bwVar.stockBot);
940
- $(context).closest(bwVar.$bigWins).removeClass(bwVar.bwMinHeight);
941
- }, 600);
942
- }
914
+ $(this).find('#stock-only').attr('id', 'stock-only' + index);
915
+ $(this).find('#cc-only').attr('id', 'cc-only' + index);
943
916
 
944
- //bind nearestStore event
945
- $(context).closest(bwVar.$bigWins).find(bwVar.$stockFindBtn).unbind();
946
- $(context)
947
- .closest(bwVar.$bigWins)
948
- .find(bwVar.$stockFindBtn)
949
- .on('click', showSearchResultNearest);
950
-
951
- //toggle tabs to nearest
952
- $(context).closest(bwVar.$bigWins).find(bwVar.$stock).removeClass(bwVar.stockMore);
953
- $(context).closest(bwVar.$bigWins).find(bwVar.$stockTab).removeClass(bwVar.active);
954
- $(context).closest(bwVar.$bigWins).find(bwVar.$stockTab).first().addClass(bwVar.active);
955
-
956
- $(context)
957
- .closest(bwVar.$bigWins)
958
- .find(bwVar.$stockResult)
959
- .addClass(bwVar.stockResultHide);
960
- $(context)
961
- .closest(bwVar.$bigWins)
962
- .find(bwVar.$stockTabs)
963
- .removeClass(bwVar.stockTabsHide);
964
- $(context)
965
- .closest(bwVar.$bigWins)
966
- .find(bwVar.$stockFind)
967
- .removeClass(bwVar.stockFindHide);
968
-
969
- bwVar.$body.removeClass(bwVar.scrollDisable);
970
-
971
- scrollToBlockMobile(context);
972
- }
917
+ });
973
918
 
974
- function closeStoreDetails(context) {
975
- bwVar.$storeMoreLink.text('Store Info');
976
- //hide pseudoclass
977
- $(context)
978
- .closest(bwVar.$bigWins)
979
- .find(bwVar.$stock)
980
- .removeClass(bwVar.stockDetailsOpen);
981
- $(context).closest(bwVar.$bigWins).find(bwVar.$sDetails).addClass(bwVar.sDetailsHide);
982
- bwVar.$pdpPrice.removeClass(bwVar.pdpPriceBW);
983
- bwVar.$tiTotal.removeClass(bwVar.tiTotalBW);
984
- bwVar.$body.removeClass(bwVar.scrollDisable);
985
-
986
- scrollToBlockMobile(context);
987
- }
919
+ bwVar.$stockRadio.each(function (index) {
920
+ var currentName = $(this).attr('for');
921
+ $(this).attr('for', currentName + index);
922
+ $(this).find('input').attr('id', currentName + index);
988
923
 
989
- function showSearchResultMoreProto(context) {
990
- if (
991
- $(context)
992
- .closest(bwVar.$bigWins)
993
- .find('.stock__tab.active')
994
- .attr('data-stores') === 'more'
995
- ) {
996
- var postcodeLength;
997
-
998
- if (
999
- $(context)
1000
- .closest(bwVar.$bigWins)
1001
- .find(bwVar.$bwChosen)
1002
- .hasClass(bwVar.protoOnlyPopulated)
1003
- ) {
1004
- postcodeLength = $(context)
1005
- .closest(bwVar.$bigWins)
1006
- .find(bwVar.$protoOnlyPopulated)
1007
- .find(bwVar.storeName)
1008
- .text().length;
1009
- } else {
1010
- postcodeLength = $(context)
1011
- .closest(bwVar.$bigWins)
1012
- .find(bwVar.$stockPostcode)
1013
- .val().length;
1014
- }
1015
-
1016
- if (postcodeLength >= 5) {
1017
- if (
1018
- $(context)
1019
- .closest(bwVar.$bigWins)
1020
- .find(bwVar.$stockTabs)
1021
- .hasClass(bwVar.moreStoresPresent || bwVar.defStoresPresent)
1022
- ) {
1023
- $(context)
1024
- .closest(bwVar.$bigWins)
1025
- .find(bwVar.$stockResult)
1026
- .removeClass(bwVar.stockResultHide);
1027
- }
1028
- }
1029
- }
1030
- }
1031
-
1032
- function iosCopyToClipboard($input) {
1033
- var el = $input.get(0);
1034
- var editable = el.contentEditable;
1035
- var readOnly = el.readOnly;
1036
-
1037
- el.contentEditable = true;
1038
- el.readOnly = false;
1039
- var range = document.createRange();
1040
- range.selectNodeContents(el);
1041
- var sel = window.getSelection();
1042
- sel.removeAllRanges();
1043
- sel.addRange(range);
1044
- el.setSelectionRange(0, 999999);
1045
- el.contentEditable = editable;
1046
- el.readOnly = readOnly;
1047
- }
924
+ })
1048
925
 
1049
- function scrollToBlockMobile(context) {
1050
- if ($(window).width() < 767) {
1051
- if ($(context).closest(bwVar.$tiTotal).length) {
1052
- window.scroll(0, bwVar.$tiTotal.offset().top - 60);
1053
- } else if ($(context).closest(bwVar.$pdpPrice).length) {
1054
- window.scroll(0, bwVar.$bigWins.offset().top - 60);
1055
- }
1056
- }
1057
- }
926
+ })()
927
+ }
1058
928
 
1059
- (function checkStoreProductsNearest() {
1060
- var value = $('.chosen__item').find('.store__stock_val').text();
1061
- if (value.match(/^out$/)) {
1062
- $('.chosen').find('.stock__valid').addClass('stock__valid_show');
1063
- $(bwVar.ccBtn).attr('disabled', 'disabled');
1064
- $(bwVar.ccBtn).find('.btn__text').text(bwVar.CLICK_AND_COLLECT_NOT_AVAILABLE);
1065
- } else {
1066
- if ($('#isCnCForProductAndStoreDisabled').val() === 'true') {
1067
- $('.chosen__nearest').find('.stock__valid').addClass('stock__valid_show');
1068
- $(bwVar.ccBtn).attr('disabled', 'disabled');
1069
- $(bwVar.ccBtn).find('.btn__text').text(bwVar.CLICK_AND_COLLECT_NOT_AVAILABLE);
1070
- } else {
1071
- $('.chosen__nearest').find('.stock__valid').removeClass('stock__valid_show');
1072
- if ($(bwVar.ccBtn).attr('disabled')) {
1073
- $(bwVar.ccBtn).removeAttr('disabled');
1074
- $(bwVar.ccBtn).find('.btn__text').text(bwVar.CLICK_AND_COLLECT);
1075
- }
1076
- }
1077
- }
1078
- })();
1079
-
1080
- (function getCorrectIdToCheckbox() {
1081
- bwVar.$stockQuestions.each(function (index) {
1082
- $(this)
1083
- .find("label[for='stock-only']")
1084
- .attr('for', 'stock-only' + index);
1085
- $(this)
1086
- .find("label[for='cc-only']")
1087
- .attr('for', 'cc-only' + index);
1088
-
1089
- $(this)
1090
- .find('#stock-only')
1091
- .attr('id', 'stock-only' + index);
1092
- $(this)
1093
- .find('#cc-only')
1094
- .attr('id', 'cc-only' + index);
1095
- });
1096
-
1097
- bwVar.$stockRadio.each(function (index) {
1098
- var currentName = $(this).attr('for');
1099
- $(this).attr('for', currentName + index);
1100
- $(this)
1101
- .find('input')
1102
- .attr('id', currentName + index);
1103
- });
1104
- })();
1105
- }
929
+ if (!bwVar.$bigWins.length) {
930
+ return;
931
+ }
1106
932
 
1107
- if (!bwVar.$bigWins.length) {
1108
- return;
1109
- }
933
+ init();
934
+ }();
1110
935
 
1111
- init();
1112
- })();