wickes-css2 2.104.0-develop.1 → 2.104.0-develop.2

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.
@@ -1,3 +1,5 @@
1
+ var Wick = Wick || {};
2
+
1
3
  const paymentLoader= '.payment-loader';
2
4
  const paymentLoaderHideClass= 'payment-loader--hidden';
3
5
  const paymentLoaderModal = '.payment-loader__modal'
@@ -5,11 +7,10 @@ const paymentTypeSelectors = {
5
7
  apple: '.apple__button',
6
8
  google: '.google__button',
7
9
  clearpay: '#checkout-payment-details-clearpay',
8
- billie: '#checkout-payment-details-billie, .billie__button',
9
10
  paypal: '#checkout-payment-details-paypal'
10
11
  };
11
12
 
12
- function showPaymentLoader(paymentType) {
13
+ Wick.showPaymentLoader = function(paymentType) {
13
14
  $(paymentLoader).find(`${paymentLoaderModal} > div`).hide();
14
15
  $(`.${paymentType}-checkout-logo`).show();
15
16
  $(`${paymentLoader} .spinner`).show();
@@ -21,5 +22,5 @@ function showPaymentLoader(paymentType) {
21
22
  }
22
23
 
23
24
  Object.entries(paymentTypeSelectors).forEach(([type, triggerSelector]) => {
24
- $(document).on('click', triggerSelector, () => showPaymentLoader(type));
25
+ $(document).on('click', triggerSelector, () => Wick.showPaymentLoader(type));
25
26
  });
@@ -0,0 +1,35 @@
1
+ var Wick = Wick || {};
2
+
3
+ Wick.RepaymentToggle = (function () {
4
+ const SELECTORS = {
5
+ repaymentRadio: 'input[name="repaymentTerms"]',
6
+ term: '.billie-info .term',
7
+ paymentMethod: '[name="payment-method"]'
8
+ };
9
+
10
+ function updateTerm(value) {
11
+ const $term = $(SELECTORS.term);
12
+ if (!$term.length) return;
13
+
14
+ $term.text(value);
15
+ }
16
+
17
+ function bindEvents () {
18
+ $(document).on('change', SELECTORS.repaymentRadio, function () {
19
+ const value = $(this).val();
20
+ if (!value) return;
21
+
22
+ updateTerm(value);
23
+
24
+ const currentMethod = $(SELECTORS.paymentMethod + ':checked').val();
25
+ if (currentMethod !== 'billie') return;
26
+
27
+ if (typeof Wick.showPaymentLoader === 'function') {
28
+ Wick.showPaymentLoader('billie');
29
+ }
30
+
31
+ });
32
+ }
33
+
34
+ bindEvents();
35
+ })();
@@ -3,27 +3,32 @@ var Wick = window.Wick || {};
3
3
  Wick.BusinessType = {
4
4
  el: {
5
5
  radios: 'input[name="businessType"]',
6
- panels: '.radio-expanded-content'
6
+ panels: '.radio-expanded-content',
7
+ hiddenClass: 'd-none',
7
8
  },
8
9
 
9
10
  refreshPanels() {
10
11
  const $radios = $(this.el.radios);
11
12
  const $panels = $(this.el.panels);
12
- const selectedValue = $radios.filter(':checked').val();
13
+ const $checked = $radios.filter(':checked');
13
14
 
14
- $panels.hide();
15
- $(`#${selectedValue}-fields`).show();
15
+ $panels.addClass(this.el.hiddenClass);
16
+ if (!$checked.length) {
17
+ return;
18
+ }
19
+
20
+ const selectedValue = $checked.val();
21
+ $(`#${selectedValue}-fields`).removeClass(this.el.hiddenClass);
16
22
  },
17
23
 
18
24
  bindEvents() {
19
- $(this.el.radios).on('change', this.refreshPanels.bind(this));
25
+ $(document).on('change', this.el.radios, this.refreshPanels.bind(this));
20
26
  },
21
27
 
22
28
  init() {
23
29
  if (!$(this.el.radios).length) {
24
30
  return;
25
31
  }
26
-
27
32
  this.refreshPanels();
28
33
  this.bindEvents();
29
34
  }
@@ -1,107 +1,203 @@
1
1
  var Wick = Wick || {};
2
2
  Wick.CheckoutPaymentDetails = (function() {
3
3
  const $modal = $('#modal-terms-and-conditions');
4
+
5
+ let prevPaymentMethod = null;
4
6
  let prevClearableMethod;
7
+
5
8
  let detailsLabel = {
6
- inputName: 'card-name',
7
- buttonName: 'btn-enter-details',
9
+ inputName: 'card-name', buttonName: 'btn-enter-details',
8
10
  };
9
11
 
10
12
  const elements = {
13
+ $billieRepaymentTerms: $('.js-billie-repayment-terms'),
14
+ $billieInfoBlock: $('.checkout-payment-details__billie'),
11
15
  $wrapperPaymentInput: $('.checkout-payment-details__row'),
12
16
  paymentInputName: '[name=payment-method]',
13
17
  $cardDetails: $('.checkout-payment-details__card-details'),
14
18
  $placeOrder: $('.checkout-payment-details__place-order'),
15
19
  $billingAddress: $('.billing-address'),
16
20
  hiddenCardDetailsClass: 'checkout-payment-details__card-details_hidden',
21
+ $billieBusiness: $('[data-billie-business]'),
22
+ businessTypeName: '[name="businessType"]',
23
+ $unregisteredFields: $('#unregistered-fields'),
24
+ $registeredFields: $('#registered-fields'),
17
25
  hiddenClass: 'd-none',
18
- }
26
+ };
19
27
 
20
28
  function preparePage() {
21
- var modalOpened = $(".modal.show").length;
22
- if (!modalOpened) {
23
- return;
24
- }
29
+ var modalOpened = $('.modal.show').length;
30
+ if (!modalOpened) return;
31
+
25
32
  var modalContent = $modal.find('.modal-content').clone();
26
- $modal.modal("hide");
27
- modalContent.addClass("print-area");
28
- $("body")
29
- .addClass("print-mode")
33
+ $modal.modal('hide');
34
+ modalContent.addClass('print-area');
35
+
36
+ $('body')
37
+ .addClass('print-mode')
30
38
  .append(modalContent);
31
39
  }
32
40
 
33
41
  function resetPage() {
34
- var modalPrintModeActive = $("body.print-mode").length;
35
- if (!modalPrintModeActive) {
36
- return;
37
- }
38
- $("body").removeClass("print-mode");
39
- $(".print-area").remove();
40
- $modal.modal("show");
42
+ var modalPrintModeActive = $('body.print-mode').length;
43
+ if (!modalPrintModeActive) return;
44
+
45
+ $('body').removeClass('print-mode');
46
+ $('.print-area').remove();
47
+ $modal.modal('show');
41
48
  }
42
49
 
43
50
  function getPaymentMethods() {
44
51
  return $(elements.paymentInputName)
45
52
  .map((_, item) => $(item).val())
46
- .get()
53
+ .get();
47
54
  }
48
55
 
49
56
  function togglePaymentBlocks(paymentMethods, checkedMethod) {
50
57
  paymentMethods.forEach(method => {
51
- $(`[data-${method}]`).toggle(checkedMethod === method)
52
- })
58
+ $(`[data-${method}]`).toggle(checkedMethod === method);
59
+ });
60
+ }
61
+
62
+ function resetAllCheckoutForms(keepPaymentMethod) {
63
+ const $container = elements.$wrapperPaymentInput.closest('.checkout-payment-details');
64
+ if (!$container.length) return;
65
+
66
+ $container.find('form').each(function() {
67
+ if (Wick.Forms && typeof Wick.Forms.clearValidationErrors === 'function') {
68
+ Wick.Forms.clearValidationErrors(this);
69
+ }
70
+ });
71
+
72
+ $container
73
+ .find('input[type="text"], input[type="email"], input[type="tel"], input[type="number"], input[type="password"], textarea')
74
+ .val('');
75
+
76
+ $container.find('select').each(function() {
77
+ this.selectedIndex = 0;
78
+ });
79
+
80
+ $container.find('input[type="checkbox"]').prop('checked', false);
81
+
82
+ $container.find('input[type="radio"]').each(function() {
83
+ const $radio = $(this);
84
+ const name = $radio.attr('name');
85
+ const val = $radio.val();
86
+
87
+ if (name === 'payment-method') {
88
+ $radio.prop('checked', val === keepPaymentMethod);
89
+ } else {
90
+ $radio.prop('checked', false);
91
+ }
92
+ });
93
+
94
+ $container.find('.radio-expanded-content').hide();
95
+ }
96
+
97
+ function setBillingDetailsRowVisibility(isVisible) {
98
+ const $row = elements.$billingAddress.find('.checkout-payment-details__row');
99
+ $row.toggle(isVisible);
100
+ $row.find(':input').prop('disabled', !isVisible);
101
+ }
102
+
103
+ function setBillieStepVisibility(isReady) {
104
+ setBillingDetailsRowVisibility(isReady);
105
+ elements.$billieInfoBlock.toggle(isReady);
106
+ }
107
+
108
+ function resetBillieRepaymentSelection() {
109
+ elements.$billieRepaymentTerms
110
+ .find('input[name="repaymentTerms"]')
111
+ .prop('checked', false);
112
+ }
113
+
114
+ function showBillieBusiness() {
115
+ elements.$billieBusiness.removeClass(elements.hiddenClass);
116
+ }
117
+
118
+ function hideBillieBusiness() {
119
+ elements.$billieBusiness.addClass(elements.hiddenClass);
120
+
121
+ elements.$unregisteredFields
122
+ .addClass(elements.hiddenClass)
123
+ .removeAttr('style');
124
+
125
+ elements.$registeredFields
126
+ .addClass(elements.hiddenClass)
127
+ .removeAttr('style');
128
+
129
+ elements.$billieBusiness.find('input[type="radio"]').prop('checked', false);
130
+ elements.$billieBusiness.find('input.tbx').val('');
53
131
  }
54
132
 
133
+ function toggleBusinessTypeFields(type) {
134
+ const isUnregistered = type === 'unregistered';
135
+ const isRegistered = type === 'registered';
136
+
137
+ elements.$unregisteredFields.toggleClass(elements.hiddenClass, !isUnregistered);
138
+ elements.$registeredFields.toggleClass(elements.hiddenClass, !isRegistered);
139
+ }
140
+
141
+
55
142
  function changeDetailsBlock(checkedMethod) {
56
- switch(checkedMethod) {
143
+ if (checkedMethod !== 'billie') {
144
+ setBillingDetailsRowVisibility(true);
145
+ }
146
+
147
+ switch (checkedMethod) {
57
148
  case 'paypal':
58
149
  hideCardDetails();
59
150
  showPlaceOrder();
60
151
  hideBillingAddres();
61
152
  break;
153
+
62
154
  case 'klarna':
63
155
  hideBillingAddres();
64
156
  break;
157
+
65
158
  case 'billie':
66
159
  detailsLabel = {
67
- ...detailsLabel,
68
- labelText: 'Name on Billie account',
69
- buttonText: 'Pay with Billie'
70
- }
160
+ ...detailsLabel, labelText: 'Name on Billie account', buttonText: 'Pay with Billie',
161
+ };
71
162
  changeLabelText(detailsLabel);
163
+
164
+ setBillieStepVisibility(false);
165
+ resetBillieRepaymentSelection();
166
+ showBillieBusiness();
72
167
  break;
168
+
73
169
  case 'clearpay':
74
170
  detailsLabel = {
75
- ...detailsLabel,
76
- labelText: 'Name on Clearpay account',
77
- buttonText: 'Pay with Clearpay'
78
- }
171
+ ...detailsLabel, labelText: 'Name on Clearpay account', buttonText: 'Pay with Clearpay',
172
+ };
79
173
  prevClearableMethod === 'card' && clearInputFields();
80
174
  changeLabelText(detailsLabel);
81
175
  prevClearableMethod = checkedMethod;
82
176
  break;
177
+
83
178
  case 'apple':
84
- hideCardDetails()
85
- hidePlaceOrder()
86
- hideBillingAddres()
179
+ hideCardDetails();
180
+ hidePlaceOrder();
181
+ hideBillingAddres();
87
182
  break;
183
+
88
184
  case 'google':
89
- hideCardDetails()
90
- hidePlaceOrder()
91
- hideBillingAddres()
185
+ hideCardDetails();
186
+ hidePlaceOrder();
187
+ hideBillingAddres();
92
188
  break;
189
+
93
190
  case 'card':
94
191
  detailsLabel = {
95
- ...detailsLabel,
96
- labelText: 'Name on card',
97
- buttonText: 'Enter card details'
98
- }
192
+ ...detailsLabel, labelText: 'Name on card', buttonText: 'Enter card details',
193
+ };
99
194
  prevClearableMethod === 'clearpay' && clearInputFields();
100
195
  changeLabelText(detailsLabel);
101
196
  prevClearableMethod = checkedMethod;
102
197
  break;
198
+
103
199
  default:
104
- showPlaceOrder()
200
+ showPlaceOrder();
105
201
  }
106
202
  }
107
203
 
@@ -115,9 +211,11 @@ Wick.CheckoutPaymentDetails = (function() {
115
211
 
116
212
  function changeLabelText(params) {
117
213
  const { inputName, labelText, buttonName, buttonText } = params;
214
+
118
215
  elements.$billingAddress.removeClass(elements.hiddenClass);
216
+
119
217
  let labelElement = elements.$billingAddress.find('[for="' + inputName + '"]');
120
- let buttonElement = elements.$billingAddress.find("." + buttonName + " .btn__text");
218
+ let buttonElement = elements.$billingAddress.find('.' + buttonName + ' .btn__text');
121
219
 
122
220
  labelElement && labelElement.text(labelText);
123
221
  buttonElement && buttonElement.text(buttonText);
@@ -135,14 +233,43 @@ Wick.CheckoutPaymentDetails = (function() {
135
233
  elements.$placeOrder.addClass(elements.hiddenClass);
136
234
  }
137
235
 
236
+ function initBillieBusinessTypeToggle() {
237
+ $(document).on('change', elements.businessTypeName, function () {
238
+ toggleBusinessTypeFields($(this).val());
239
+ });
240
+ }
241
+
138
242
  function init() {
139
243
  const paymentMethods = getPaymentMethods();
244
+ initBillieBusinessTypeToggle();
245
+ hideBillieBusiness();
246
+
247
+ $(document).on('change', 'input[name="repaymentTerms"]', function() {
248
+ const currentMethod = $(elements.paymentInputName + ':checked').val();
249
+ if (currentMethod !== 'billie') return;
250
+
251
+ const hasSelection = $('input[name="repaymentTerms"]:checked').length > 0;
252
+ setBillieStepVisibility(hasSelection);
253
+
254
+ const $row = $(this).closest('.form-row[data-row-required]');
255
+ $row.removeClass('form-row_validation-error')
256
+ .find('.form-row__error').remove();
257
+ });
140
258
 
141
259
  elements.$wrapperPaymentInput.on('change', elements.paymentInputName, function() {
142
260
  const checkedMethod = $(this).val();
143
261
 
144
- togglePaymentBlocks(paymentMethods, checkedMethod)
145
- changeDetailsBlock(checkedMethod)
262
+ if (prevPaymentMethod && prevPaymentMethod !== checkedMethod) {
263
+ resetAllCheckoutForms(checkedMethod);
264
+ } else {
265
+ const form = $(this).closest('form')[0];
266
+ form && Wick.Forms && Wick.Forms.clearValidationErrors && Wick.Forms.clearValidationErrors(form);
267
+ }
268
+
269
+ togglePaymentBlocks(paymentMethods, checkedMethod);
270
+ changeDetailsBlock(checkedMethod);
271
+
272
+ prevPaymentMethod = checkedMethod;
146
273
  });
147
274
 
148
275
  $('.btn-new-card').on('click', function() {
@@ -157,17 +284,14 @@ Wick.CheckoutPaymentDetails = (function() {
157
284
  return false;
158
285
  });
159
286
 
160
- // do not subscribe if no T&C modal on a current page
161
- if (!$modal.length) {
162
- return;
163
- }
287
+ prevPaymentMethod = $(elements.paymentInputName + ':checked').val() || null;
288
+
289
+ if (!$modal.length) return;
164
290
 
165
- if (typeof(window.onbeforeprint) !== 'undefined') {
166
- // subscriptions for browsers
291
+ if (typeof (window.onbeforeprint) !== 'undefined') {
167
292
  window.onbeforeprint = preparePage;
168
293
  window.onafterprint = resetPage;
169
294
  } else if (window.matchMedia) {
170
- // subscriptions for iOS devices
171
295
  var mediaQueryList = window.matchMedia('print');
172
296
  mediaQueryList.addListener(function(mql) {
173
297
  if (mql.matches) {
@@ -35,7 +35,6 @@
35
35
  title=my_account.diy.activeOrders.sectionTitle
36
36
  linkText='View all orders'
37
37
  orders=my_account.diy.activeOrders.orderList
38
- billieText="Payment due 30 days from Dispatch or Collection Date"
39
38
  }}
40
39
  </div>
41
40
  </div>
@@ -0,0 +1,65 @@
1
+ @import '../helpers/variables';
2
+
3
+ .checkout-chip {
4
+ position: relative;
5
+ flex: 0 0 auto;
6
+
7
+ &__input {
8
+ position: absolute;
9
+ opacity: 0;
10
+ width: 1px;
11
+ height: 1px;
12
+ pointer-events: none;
13
+
14
+ &:checked + .checkout-chip__label {
15
+ border-color: $blue;
16
+
17
+ .checkout-chip__label-top,
18
+ .checkout-chip__label-bottom {
19
+ color: $blue;
20
+ }
21
+ }
22
+
23
+ &:focus-visible + .checkout-chip__label {
24
+ outline: 2px solid $blue;
25
+ outline-offset: 2px;
26
+ }
27
+ }
28
+
29
+ &__label {
30
+ background: $white;
31
+ border: 1px solid $gray;
32
+ border-radius: 16px;
33
+ padding: 6px 4px 4px;
34
+ display: flex;
35
+ flex-direction: column;
36
+ align-items: center;
37
+ justify-content: center;
38
+ gap: 4px;
39
+ cursor: pointer;
40
+ user-select: none;
41
+ transition: border-color .2s;
42
+ width: 78px;
43
+ }
44
+
45
+ &__label-top {
46
+ font-family: Roboto, sans-serif;
47
+ font-weight: 700;
48
+ font-size: 1rem;
49
+ line-height: 20px;
50
+ }
51
+
52
+ &__label-bottom {
53
+ font-family: Roboto, sans-serif;
54
+ font-weight: 400;
55
+ font-size: 0.87rem;
56
+ line-height: 22px;
57
+ text-align: center;
58
+ }
59
+ }
60
+
61
+ .form-row_validation-error {
62
+ .checkout-chip__label {
63
+ border: 1px solid $red;
64
+ }
65
+ }
@@ -0,0 +1,39 @@
1
+ @import '../helpers/variables';
2
+
3
+ .repayment-terms {
4
+ background: $gray-bg;
5
+ display: flex;
6
+ flex-direction: column;
7
+ gap: 16px;
8
+
9
+ &__title {
10
+ display: flex;
11
+ gap: 4px;
12
+ align-items: flex-start;
13
+ font-family: Roboto, sans-serif;
14
+ font-weight: 500;
15
+ font-size: 1rem;
16
+ line-height: 24px;
17
+ }
18
+
19
+ &__asterisk {
20
+ color: $red;
21
+ }
22
+
23
+ &__chips {
24
+ display: flex;
25
+ gap: 8px;
26
+ align-items: center;
27
+ width: 100%;
28
+ }
29
+
30
+ &__body {
31
+ display: flex;
32
+ flex-direction: column;
33
+ gap: 20px;
34
+ }
35
+
36
+ &__divider {
37
+ padding: 10px 0;
38
+ }
39
+ }
@@ -90,6 +90,8 @@
90
90
  @import 'components/cards-slider';
91
91
  @import 'components/sticky-element-appearance';
92
92
  @import 'components/voucher-accordion';
93
+ @import 'components/checkout-chip';
94
+ @import 'components/checkout-payment-repayment-terms';
93
95
 
94
96
  // Pages
95
97
  @import 'pages/contact-us';