wickes-css2 2.105.0-develop.3 → 2.105.0-develop.4

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 (160) hide show
  1. package/Readme.md +1 -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/page_product_search.css +1 -1
  9. package/build/css/pages/page_products-list-combined.css +1 -1
  10. package/build/css/pages/page_products-list.css +1 -1
  11. package/build/css/pdp-main-before-combine.css +1 -1
  12. package/build/css/pdp-main-non-critical.css +1 -1
  13. package/build/css/pdp-main.css +1 -1
  14. package/build/css/plp-main.css +1 -1
  15. package/build/css/store-locator-main.css +1 -1
  16. package/build/js/basket.min.js +2 -2
  17. package/build/js/bundle.min.js +1 -1
  18. package/build/js/checkout.min.js +2 -2
  19. package/build/js/emulation.min.js +12122 -11594
  20. package/build/js/general.bundle.min.js +1 -1
  21. package/build/js/kitchen/kitchen-plp.min.js +1 -9
  22. package/build/js/merged-checkout.min.js +2 -2
  23. package/build/js/mini-basket-slider.min.js +1 -1
  24. package/build/js/page/basket/basket-update-cart-action.js +59 -56
  25. package/build/js/page/basket/basket-update-cart.js +27 -27
  26. package/build/js/page/basket/basket-utils.js +40 -33
  27. package/build/js/page/basket/mini-basket-total.js +70 -66
  28. package/build/js/page/basket/quantity-change-handler.js +73 -55
  29. package/build/js/page/basket/update-quantity-operation.js +39 -30
  30. package/build/js/page/basket/update-quantity.js +62 -62
  31. package/build/js/page/basket-v2.js +362 -229
  32. package/build/js/page/billie-business-type.js +27 -27
  33. package/build/js/page/checkout-payment-details.js +301 -299
  34. package/build/js/page/components/discounts.js +39 -36
  35. package/build/js/page/components/mini-basket-slider.js +604 -545
  36. package/build/js/page/filters/desktop-nav.js +64 -0
  37. package/build/js/page/filters/mobile-nav.js +93 -0
  38. package/build/js/page/filters/plp-filters-chips.js +92 -0
  39. package/build/js/page/filters/plp-filters-mobile.js +150 -0
  40. package/build/js/page/filters/plp-filters-panel.js +123 -0
  41. package/build/js/page/filters/plp-filters-utils.js +66 -0
  42. package/build/js/page/filters/plp-filters.js +256 -0
  43. package/build/js/page/filters/sort-by.js +172 -0
  44. package/build/js/page/klarna-modal-scroll-disable.js +4 -4
  45. package/build/js/page/online-exclusive.js +28 -30
  46. package/build/js/page/search-filter.js +62 -0
  47. package/build/js/page/utils/helpers.js +14 -9
  48. package/build/js/page/utils/show-more-less.js +273 -0
  49. package/build/js/pdp.bundle.min.js +1 -1
  50. package/build/js/plp-filters.min.js +9 -0
  51. package/build/js/plp.bundle.min.js +1 -1
  52. package/build/js/project-list.min.js +1 -1
  53. package/build/js/search-filter.min.js +1 -0
  54. package/package.json +3 -3
  55. package/src/components/accordion.hbs +2 -2
  56. package/src/components/kitchen/dropdown.hbs +6 -3
  57. package/src/components/kitchen/filter-modal-content-kitchen.hbs +10 -0
  58. package/src/components/kitchen/filter-modal.hbs +10 -13
  59. package/src/components/kitchen/plp-filters.hbs +3 -1
  60. package/src/components/kitchen/sort-by.hbs +1 -1
  61. package/src/components/search-filter-modal-content.hbs +102 -0
  62. package/src/components/search-filter.hbs +121 -112
  63. package/src/data/data_plp_load-more.json +1 -1
  64. package/src/elements/btn.hbs +7 -0
  65. package/src/js/components/general/accordion.js +38 -29
  66. package/src/js/components/general/cart-slider.js +19 -16
  67. package/src/js/components/general/create-popup-slider.js +168 -173
  68. package/src/js/emulation/big-wins.js +1081 -904
  69. package/src/js/emulation/billie-modal.js +23 -19
  70. package/src/js/emulation/checkout-payment-details.js +47 -38
  71. package/src/js/emulation/custom-slider-emulation.js +17 -13
  72. package/src/js/emulation/filters-emulation.js +164 -0
  73. package/src/js/emulation/forms.js +360 -323
  74. package/src/js/emulation/mini-basket-data.js +1051 -923
  75. package/src/js/emulation/paymentLoader.js +17 -17
  76. package/src/js/emulation/pdf-file-loader.js +89 -91
  77. package/src/js/emulation/popover-mini-basket.js +246 -239
  78. package/src/js/emulation/product-counter.js +50 -0
  79. package/src/js/emulation/project-list-pdp.js +321 -316
  80. package/src/js/emulation/repayment-toggle.js +23 -24
  81. package/src/js/emulation/reset-filter-desktop.js +5 -0
  82. package/src/js/emulation/selectable.js +22 -18
  83. package/src/js/emulation/wismo-details.js +23 -31
  84. package/src/js/page/basket/basket-update-cart-action.js +59 -56
  85. package/src/js/page/basket/basket-update-cart.js +27 -27
  86. package/src/js/page/basket/basket-utils.js +40 -33
  87. package/src/js/page/basket/mini-basket-total.js +70 -66
  88. package/src/js/page/basket/quantity-change-handler.js +73 -55
  89. package/src/js/page/basket/update-quantity-operation.js +39 -30
  90. package/src/js/page/basket/update-quantity.js +62 -62
  91. package/src/js/page/basket-v2.js +362 -229
  92. package/src/js/page/billie-business-type.js +27 -27
  93. package/src/js/page/checkout-payment-details.js +301 -299
  94. package/src/js/page/components/discounts.js +39 -36
  95. package/src/js/page/components/mini-basket-slider.js +604 -545
  96. package/src/js/page/filters/desktop-nav.js +64 -0
  97. package/src/js/page/filters/mobile-nav.js +93 -0
  98. package/src/js/page/filters/plp-filters-chips.js +92 -0
  99. package/src/js/page/filters/plp-filters-mobile.js +150 -0
  100. package/src/js/page/filters/plp-filters-panel.js +123 -0
  101. package/src/js/page/filters/plp-filters-utils.js +66 -0
  102. package/src/js/page/filters/plp-filters.js +256 -0
  103. package/src/js/page/filters/sort-by.js +172 -0
  104. package/src/js/page/klarna-modal-scroll-disable.js +4 -4
  105. package/src/js/page/online-exclusive.js +28 -30
  106. package/src/js/page/search-filter.js +62 -0
  107. package/src/js/page/utils/helpers.js +14 -9
  108. package/src/js/page/utils/show-more-less.js +273 -0
  109. package/src/page_empty-shared-project-list-bicester-hub.html +3 -0
  110. package/src/page_kitchen-plp.html +2 -2
  111. package/src/page_plp-with-paint.html +2 -7
  112. package/src/page_plp.html +2 -7
  113. package/src/page_plp_v2-energy-efficiency.html +1 -6
  114. package/src/page_plp_v2-favourite-products.html +6 -7
  115. package/src/page_plp_v2-vat.html +2 -7
  116. package/src/page_plp_v2.html +22 -9
  117. package/src/page_product_search-vat.html +2 -7
  118. package/src/page_product_search.html +2 -7
  119. package/src/page_project-list-with-new-share-popup-android.html +1 -0
  120. package/src/page_project-list-with-new-share-popup-ios.html +1 -0
  121. package/src/page_project-list-with-new-share-popup.html +1 -0
  122. package/src/page_search-results.html +2 -7
  123. package/src/page_shared-project-list-bicester-hub.html +1 -0
  124. package/src/scss/common/_common.scss +5 -4
  125. package/src/scss/components/_accordion.scss +1 -3
  126. package/src/scss/components/_custom-slider.scss +15 -14
  127. package/src/scss/components/_date-selection-add-new-styles.scss +6 -7
  128. package/src/scss/components/_date-selection.scss +1 -1
  129. package/src/scss/components/{kitchen/_filter-modal.scss → _filter-modal.scss} +55 -4
  130. package/src/scss/components/{kitchen/_plp-filters.scss → _plp-filters.scss} +31 -13
  131. package/src/scss/components/_popover-mini-basket.scss +3 -3
  132. package/src/scss/components/_search-filter.scss +95 -15
  133. package/src/scss/components/_sort-by.scss +190 -0
  134. package/src/scss/components/checkout-chip.scss +2 -2
  135. package/src/scss/components/checkout-payment-repayment-terms.scss +1 -1
  136. package/src/scss/globals/_global-components.scss +3 -0
  137. package/src/scss/helpers/_colors-semantic.scss +68 -68
  138. package/src/scss/helpers/_variables.scss +242 -196
  139. package/src/scss/kitchen-plp-main.scss +0 -3
  140. package/src/scss/main.scss +65 -65
  141. package/src/scss/pages/page_product-details-v2.scss +1 -4
  142. package/src/scss/pages/page_product_search.scss +9 -1
  143. package/src/scss/pages/page_products-list-combined.scss +28 -24
  144. package/src/scss/pages/page_products-list.scss +8 -0
  145. package/src/scss/pages/tradePro-rewards.scss +2 -3
  146. package/build/js/page/accordion.js +0 -35
  147. package/build/js/page/kitchen/plp-filters-chips.js +0 -90
  148. package/build/js/page/kitchen/plp-filters-mobile.js +0 -72
  149. package/build/js/page/kitchen/plp-filters-panel.js +0 -119
  150. package/build/js/page/kitchen/plp-filters-utils.js +0 -65
  151. package/build/js/page/kitchen/plp-filters.js +0 -205
  152. package/build/js/page/kitchen/sort-by.js +0 -157
  153. package/src/js/components/general/search-filter.js +0 -21
  154. package/src/js/page/accordion.js +0 -35
  155. package/src/js/page/kitchen/plp-filters-chips.js +0 -90
  156. package/src/js/page/kitchen/plp-filters-mobile.js +0 -72
  157. package/src/js/page/kitchen/plp-filters-panel.js +0 -119
  158. package/src/js/page/kitchen/plp-filters-utils.js +0 -65
  159. package/src/js/page/kitchen/plp-filters.js +0 -205
  160. package/src/js/page/kitchen/sort-by.js +0 -157
@@ -1,935 +1,1112 @@
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');
164
- if (typeof attr !== 'undefined' && attr !== false) {
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
- }
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);
171
123
  }
172
124
 
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);
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
+ }
400
243
  }
401
- });
244
+ closeStoreDetails(this);
245
+ });
402
246
 
403
- if (!bwVar.$ccOrder.length) {
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;
404
258
  if ($(window).width() < 767) {
405
- //disable scroll for modal
406
- bwVar.$body.addClass(bwVar.scrollDisable);
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);
407
265
  }
408
- }
266
+ });
409
267
 
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
- }
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
+ }
470
289
  });
471
290
 
472
- if ($(window).width() < 767) {
473
- //disable scroll for modal
474
- bwVar.$body.addClass(bwVar.scrollDisable);
475
- }
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();
476
295
 
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
- }
296
+ bwVar.$stockList.find(bwVar.storeName).each(function () {
297
+ if ($(this).text() === makeDefValue) {
298
+ $(this).closest(bwVar.$store).find('.store-state').click();
299
+ }
300
+ });
697
301
 
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
- }
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
+ });
730
340
 
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);
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');
772
357
  }
773
- }
774
- }
775
- } else {
776
- $(context).closest(bwVar.$bigWins).find(bwVar.$stockPostcodeEl)
777
- .addClass(bwVar.stockPostcodeInvalid);
778
- }
779
- }
358
+ });
780
359
 
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
- }
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
+ });
825
368
 
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
- }
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
+ });
839
376
 
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
- }
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
+ });
852
384
 
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
- }
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();
860
392
 
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
- }
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
+ }
877
543
 
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);
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');
553
+ 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
+ }
563
+ }
564
+ });
565
+
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);
601
+ }
602
+ });
603
+
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');
609
+ }
610
+ });
611
+
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);
630
+ });
631
+
632
+ //C&C btn
633
+ bwVar.$bigWins.on('click', bwVar.ccBtn, function (e) {
634
+ closeMoreStorestModal(e, this);
635
+
636
+ //hide store info
637
+ $(this).closest(bwVar.$bigWins).find(bwVar.$sDetails).addClass(bwVar.sDetailsHide);
638
+ $(this).closest(bwVar.$pdpPrice).removeClass(bwVar.pdpPriceBW);
639
+
640
+ //show store info
641
+ $(this).closest(bwVar.$bigWins).find(bwVar.$chosen).removeClass(bwVar.chosenHide);
642
+
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);
647
+ }
648
+
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);
654
+
655
+ scrollToBlockMobile(this);
656
+ });
657
+
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
+ }
679
+
680
+ document.execCommand('copy');
681
+ $(this).addClass(bwVar.copyLinkHovered);
682
+ $temp.remove();
683
+ });
684
+
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
+ });
740
+
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
+ }
884
833
  }
885
- }
886
- }
887
834
 
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
- }
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
+ }
905
924
  }
906
- }
907
- })();
908
925
 
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);
926
+ function closeMoreStorestModal(e, context) {
927
+ e.preventDefault();
928
+ //close more block
929
+ $(context).closest(bwVar.$bigWins).find(bwVar.$stock).removeClass(bwVar.stockMore);
913
930
 
914
- $(this).find('#stock-only').attr('id', 'stock-only' + index);
915
- $(this).find('#cc-only').attr('id', 'cc-only' + index);
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
+ }
916
943
 
917
- });
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
+ }
918
973
 
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);
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
+ }
923
988
 
924
- })
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
+ }
925
1048
 
926
- })()
927
- }
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
+ }
928
1058
 
929
- if (!bwVar.$bigWins.length) {
930
- return;
931
- }
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
+ }
932
1106
 
933
- init();
934
- }();
1107
+ if (!bwVar.$bigWins.length) {
1108
+ return;
1109
+ }
935
1110
 
1111
+ init();
1112
+ })();