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.
@@ -3443,6 +3443,52 @@ Wick.BigWinsProto = function () {
3443
3443
  }();
3444
3444
 
3445
3445
 
3446
+ (function () {
3447
+ const ORDER = ["30", "30_60", "30_90", "30_60_90"];
3448
+
3449
+ const COPY = {
3450
+ "30": {
3451
+ heading: "Buy now, pay within 30 days",
3452
+ repayment: "From the point of collection / delivery of goods you’ll have 30 days to pay",
3453
+ },
3454
+ "30_60": {
3455
+ heading: "Buy now and choose to pay within 30 or 60 days",
3456
+ repayment: "From the point of collection / delivery of goods, you'll have until the end of your chosen repayment term to pay",
3457
+ },
3458
+ "30_90": {
3459
+ heading: "Buy now and choose to pay within 30 or 90 days",
3460
+ repayment: "From the point of collection / delivery of goods, you'll have until the end of your chosen repayment term to pay",
3461
+ },
3462
+ "30_60_90": {
3463
+ heading: "Buy now and choose to pay within 30, 60 or 90 days",
3464
+ repayment: "From the point of collection / delivery of goods, you'll have until the end of your chosen repayment term to pay",
3465
+ },
3466
+ };
3467
+
3468
+ let index = -1;
3469
+
3470
+ function nextTerms() {
3471
+ index = (index + 1) % ORDER.length;
3472
+ return ORDER[index];
3473
+ }
3474
+
3475
+ function applyBillieTerms(terms) {
3476
+ const copy = COPY[terms] || COPY["30"];
3477
+ const $modal = $("#billieLearnMoreModal");
3478
+
3479
+ $modal.find(".js-billie-terms-heading").text(copy.heading);
3480
+ $modal.find(".js-billie-repayment-line").text(copy.repayment);
3481
+ $modal.attr("data-billie-terms", terms);
3482
+ }
3483
+
3484
+ $(document).on("click", ".billie__link", function (e) {
3485
+ e.preventDefault();
3486
+
3487
+ const terms = nextTerms();
3488
+ applyBillieTerms(terms);
3489
+ });
3490
+ })();
3491
+
3446
3492
  var Wick = Wick || {};
3447
3493
  Wick.ChatBot = (function () {
3448
3494
  let $backToTop = $('#back-to-top'),
@@ -3520,21 +3566,21 @@ Wick.DeliveryDetails = (function () {
3520
3566
 
3521
3567
  var Wick = Wick || {};
3522
3568
 
3523
- Wick.PaymentDetails = (function () {
3569
+ Wick.PaymentDetails = (function() {
3524
3570
  var $btnEnterDetails = $('.btn-enter-details'),
3525
3571
  $form = $btnEnterDetails.parents('form'),
3526
3572
  isGuestPage = $('.page_checkout-payment-details_guest').length;
3527
3573
 
3528
- function bindEvents () {
3529
- $btnEnterDetails.on('click', function(){
3530
- if ($form.find('#card-name').val().length &&
3574
+ function bindEvents() {
3575
+ $btnEnterDetails.on('click', function() {
3576
+ if ($form.find('#card-name').val()?.length &&
3531
3577
  $form.find('#first-line-address').val().length &&
3532
3578
  $form.find('#address-line-1').val().length &&
3533
3579
  $form.find('#town-city').val().length &&
3534
- $form.find('#postcode_additional').val().length){
3580
+ $form.find('#postcode_additional').val().length) {
3535
3581
  $('.checkout-payment-details__card-details').removeClass('checkout-payment-details__card-details_hidden');
3536
3582
  $('html, body').animate({
3537
- scrollTop: $('.checkout-payment-details__card-details').offset().top - 15
3583
+ scrollTop: $('.checkout-payment-details__card-details').offset().top - 15,
3538
3584
  }, 700);
3539
3585
  return false;
3540
3586
  }
@@ -3542,14 +3588,14 @@ Wick.PaymentDetails = (function () {
3542
3588
  return false;
3543
3589
  });
3544
3590
 
3545
- $('.checkout-payment-details__card-details').on('submit', function(){
3591
+ $('.checkout-payment-details__card-details').on('submit', function() {
3546
3592
  var $form = $(this);
3547
3593
  if ($form.find('#card-type').val() &&
3548
3594
  $form.find('#card-name1').val().length &&
3549
3595
  $form.find('#card-number').val().length &&
3550
3596
  $form.find('#month').val() &&
3551
3597
  $form.find('#year').val() &&
3552
- $form.find('#security-code').val()){
3598
+ $form.find('#security-code').val()) {
3553
3599
  window.location.href = isGuestPage
3554
3600
  ? './page_checkout_confirmation_guest.html'
3555
3601
  : './page_checkout_confirmation.html';
@@ -4009,7 +4055,7 @@ Wick.FooterСurrentYear = (function () {
4009
4055
  })();
4010
4056
 
4011
4057
  var Wick = Wick || {};
4012
- Wick.Forms = (function(){
4058
+ Wick.Forms = (function() {
4013
4059
  var fieldRow = '.form-row[data-row-required]',
4014
4060
  field = '.form-row__field',
4015
4061
  fieldError = '.form-row__error',
@@ -4019,43 +4065,44 @@ Wick.Forms = (function(){
4019
4065
  // validationError = '<div class="form-row__error">Error message here</div>',
4020
4066
  $forgotPassword = $('.link-forgot-password'),
4021
4067
  scenarios = [{
4022
- condition: function(){
4023
- // fill in the valid returning customer's details
4024
- // Email: responsive@test.com; Password: 123456
4025
- return $('#login-email').val() === 'responsive@test.com' && $('#password').val() === '123456';
4026
- },
4027
- action: function(){
4028
- // redirected to the homepage
4029
- Wick.User.login();
4030
- window.location.href = './';
4031
- }
4068
+ condition: function() {
4069
+ // fill in the valid returning customer's details
4070
+ // Email: responsive@test.com; Password: 123456
4071
+ return $('#login-email').val() === 'responsive@test.com' && $('#password').val() === '123456';
4032
4072
  },
4073
+ action: function() {
4074
+ // redirected to the homepage
4075
+ Wick.User.login();
4076
+ window.location.href = './';
4077
+ },
4078
+ },
4033
4079
  {
4034
- condition: function(){
4080
+ condition: function() {
4035
4081
  // continue as a new user with "test+random@user.com"
4036
4082
  return $('#registration-email').val().length;
4037
4083
  // return $('#registration-email').val() === 'test+random@user.com';
4038
4084
  },
4039
- action: function(){
4085
+ action: function() {
4040
4086
  // redirected to the register form
4041
4087
  window.location.href = './page_registration.html';
4042
- }
4088
+ },
4043
4089
  },
4044
4090
  {
4045
- condition: function(){
4091
+ condition: function() {
4046
4092
  // When I click forgotten password link
4047
4093
  },
4048
- action: function(){
4094
+ action: function() {
4049
4095
  // redirected on the "Forgotten Password" page
4050
4096
  window.location.href = './page_forgotten-password.html';
4051
- }
4052
- }
4053
- ];
4097
+ },
4098
+ },
4099
+ ],
4054
4100
 
4055
- validationError = function (errorMsg) {
4056
- return `<div class="form-row__error"> ${errorMsg || 'Error message here'}</div>`
4057
- }
4058
- function isElementInViewport (el) {
4101
+ validationError = function(errorMsg) {
4102
+ return `<div class="form-row__error"> ${errorMsg || 'Error message here'}</div>`;
4103
+ };
4104
+
4105
+ function isElementInViewport(el) {
4059
4106
  if (typeof jQuery === 'function' && el instanceof jQuery) {
4060
4107
  el = el[0];
4061
4108
  }
@@ -4068,15 +4115,21 @@ Wick.Forms = (function(){
4068
4115
  );
4069
4116
  }
4070
4117
 
4071
- var showValidationErrors = function (form, errorMsg) {
4118
+ var showValidationErrors = function(form, errorMsg) {
4072
4119
  var $form = $(form);
4073
4120
  if (!$form.hasClass(formInvalid)) {
4074
4121
  $form.find('.form-row__error').remove();
4075
- $form.addClass(formInvalid).find(fieldRow).append(validationError(errorMsg)).addClass(rowValidationError);
4122
+ var $rows = $form.find(fieldRow).filter(function() {
4123
+ return $(this).is(':visible');
4124
+ });
4125
+
4126
+ $rows.append(validationError(errorMsg)).addClass(rowValidationError);
4076
4127
  }
4077
4128
 
4078
- var $firstMsg = $form.find(fieldRow).first();
4079
- if($firstMsg.length && !isElementInViewport($firstMsg)){
4129
+ var $firstMsg = $form.find(fieldRow).filter(function() {
4130
+ return $(this).is(':visible');
4131
+ }).first();
4132
+ if ($firstMsg.length && !isElementInViewport($firstMsg)) {
4080
4133
  var inModal = $firstMsg.closest('.modal').length,
4081
4134
  $scrollableEl = inModal ? $firstMsg.closest('.modal') : $('html, body'),
4082
4135
  y = inModal ? 0 : $firstMsg.offset().top - 30;
@@ -4085,22 +4138,26 @@ Wick.Forms = (function(){
4085
4138
  }
4086
4139
  };
4087
4140
 
4088
- var clearValidationErrors = function (form) {
4141
+ var clearValidationErrors = function(form) {
4089
4142
  var $form = $(form);
4090
- if ($form.hasClass(formInvalid)) {
4091
- $form.removeClass(formInvalid)
4092
- .find(fieldRow).removeClass(rowValidationError)
4093
- .find(fieldError).remove();
4094
- }
4143
+
4144
+ $form.removeClass(formInvalid);
4145
+
4146
+ $form.find(fieldRow)
4147
+ .removeClass(rowValidationError)
4148
+ .find(fieldError).remove();
4149
+
4150
+ $form.find(fieldError).remove();
4095
4151
  };
4096
4152
 
4097
- var handleSmoothScroll = function () {
4153
+
4154
+ var handleSmoothScroll = function() {
4098
4155
  $('html, body').animate({
4099
- scrollTop: $('.cards-store-list').offset().top - 60
4156
+ scrollTop: $('.cards-store-list').offset().top - 60,
4100
4157
  }, 300);
4101
4158
  };
4102
4159
 
4103
- var handleFormSubmit = function () {
4160
+ var handleFormSubmit = function() {
4104
4161
  var form = this;
4105
4162
 
4106
4163
  if ($(form).is('#form-login') || $(form).is('#form-register')) {
@@ -4114,21 +4171,21 @@ Wick.Forms = (function(){
4114
4171
  }
4115
4172
 
4116
4173
  if ($(form).is('#form-forgotten-password')) {
4117
- if ($(form).find('#email').val().length){
4174
+ if ($(form).find('#email').val().length) {
4118
4175
  window.location.href = './page_upd-pass.html';
4119
4176
  return false;
4120
4177
  }
4121
4178
  }
4122
4179
 
4123
4180
  if ($(form).is('#form-forgotten-password-popup')) {
4124
- if ($(form).find('#email').val().length){
4181
+ if ($(form).find('#email').val().length) {
4125
4182
  window.location.href = './page_checkout_sign-in.html';
4126
4183
  return false;
4127
4184
  }
4128
4185
  }
4129
4186
 
4130
4187
  if ($(form).is('#checkout-form-forgotten-password-popup')) {
4131
- if ($(form).find('#email').val().length){
4188
+ if ($(form).find('#email').val().length) {
4132
4189
  $('.modal-reset-wrap').addClass('d-block');
4133
4190
  $('.request-pass').addClass('d-none');
4134
4191
  $('.modal-title').text('Password Reset');
@@ -4137,7 +4194,7 @@ Wick.Forms = (function(){
4137
4194
  }
4138
4195
 
4139
4196
  if ($(form).is('.update-pass')) {
4140
- if ($(form).find('#new-password').val().length && $(form).find('#confirmed-password').val().length){
4197
+ if ($(form).find('#new-password').val().length && $(form).find('#confirmed-password').val().length) {
4141
4198
  window.location.href = './page_login.html';
4142
4199
  return false;
4143
4200
  }
@@ -4146,7 +4203,7 @@ Wick.Forms = (function(){
4146
4203
  if ($(form).is('.change-email')) {
4147
4204
  if ($(form).find('#new-email').val().length &&
4148
4205
  $(form).find('#confirm-new-email').val().length &&
4149
- $(form).find('#password').val().length){
4206
+ $(form).find('#password').val().length) {
4150
4207
  window.location.href = './page_my-account.html';
4151
4208
  return false;
4152
4209
  }
@@ -4155,7 +4212,7 @@ Wick.Forms = (function(){
4155
4212
  if ($(form).is('.form-change-password')) {
4156
4213
  if ($(form).find('#current-password').val().length &&
4157
4214
  $(form).find('#new-password').val().length &&
4158
- $(form).find('#confirm-password').val().length){
4215
+ $(form).find('#confirm-password').val().length) {
4159
4216
  window.location.href = './page_my-account.html';
4160
4217
  return false;
4161
4218
  }
@@ -4167,14 +4224,14 @@ Wick.Forms = (function(){
4167
4224
  $(form).find('#postcode').val().length &&
4168
4225
  $(form).find('#email').val().length &&
4169
4226
  $(form).find('#password').val().length &&
4170
- $(form).find('#confirm-password').val().length){
4227
+ $(form).find('#confirm-password').val().length) {
4171
4228
  window.location.href = './page_my-account.html';
4172
4229
  return false;
4173
4230
  }
4174
4231
  }
4175
4232
 
4176
4233
  if ($(form).is('.form-personal-details')) {
4177
- if ($(form).find('#first-name').val().length && $(form).find('#surname').val().length){
4234
+ if ($(form).find('#first-name').val().length && $(form).find('#surname').val().length) {
4178
4235
  window.location.href = './page_my-account.html';
4179
4236
  return false;
4180
4237
  }
@@ -4182,26 +4239,26 @@ Wick.Forms = (function(){
4182
4239
 
4183
4240
  if ($(form).is('.form-address-details')) {
4184
4241
  if ($(form).find('#first-name').val().length &&
4185
- $(form).find('#second-name').val().length &&
4186
- $(form).find('#address1').val().length &&
4187
- $(form).find('#town-city').val().length &&
4188
- $(form).find('#mobile-telephone').val().length) {
4242
+ $(form).find('#second-name').val().length &&
4243
+ $(form).find('#address1').val().length &&
4244
+ $(form).find('#town-city').val().length &&
4245
+ $(form).find('#mobile-telephone').val().length) {
4189
4246
  window.location.href = './page_my-account_address-book.html';
4190
4247
  return false;
4191
4248
  }
4192
4249
  }
4193
4250
 
4194
4251
  if ($(form).is('.form-locator')) {
4195
- if ($(form).find('#store-id').val()){
4252
+ if ($(form).find('#store-id').val()) {
4196
4253
  window.location.href = './page_store-locator-details.html';
4197
4254
  return false;
4198
4255
  }
4199
4256
  }
4200
4257
 
4201
4258
  if ($(form).is('.form-locator-list')) {
4202
- if ($(form).find('#postcode-town').val().length){
4259
+ if ($(form).find('#postcode-town').val().length) {
4203
4260
  var actionAfterSubmit = $(form).attr('data-action');
4204
- if (actionAfterSubmit === 'scroll-to-list'){
4261
+ if (actionAfterSubmit === 'scroll-to-list') {
4205
4262
  clearValidationErrors(this);
4206
4263
  handleSmoothScroll();
4207
4264
  } else {
@@ -4212,7 +4269,7 @@ Wick.Forms = (function(){
4212
4269
  }
4213
4270
 
4214
4271
  if ($(form).is('#form-mini-basket')) {
4215
- if (Wick.User.isLoggedIn()){
4272
+ if (Wick.User.isLoggedIn()) {
4216
4273
  window.location.href = './page_checkout_delivery-address.html';
4217
4274
  } else {
4218
4275
  window.location.href = './page_checkout_sign-in.html';
@@ -4220,13 +4277,31 @@ Wick.Forms = (function(){
4220
4277
  return false;
4221
4278
  }
4222
4279
 
4223
- function isNotEmpty(field){
4224
- return !!$(field).val();
4280
+ function isNotEmpty(field) {
4281
+ var $field = $(field);
4282
+ var type = ($field.attr('type') || '').toLowerCase();
4283
+
4284
+ if (type === 'checkbox') {
4285
+ return $field.is(':checked');
4286
+ }
4287
+
4288
+ if (type === 'radio') {
4289
+ var name = $field.attr('name');
4290
+ if (!name) return false;
4291
+
4292
+ var $scope = $field.closest('[data-row-required]');
4293
+ if (!$scope.length) $scope = $field.closest('form');
4294
+
4295
+ return $scope.find('input[type="radio"][name="' + name.replace(/"/g, '\\"') + '"]').is(':checked');
4296
+ }
4297
+
4298
+ return !!$field.val();
4225
4299
  }
4226
4300
 
4301
+
4227
4302
  if ($(form).is('#form-checkout-your-details')) {
4228
4303
  var requiredFields = $(form).find('[data-row-required]:visible :input');
4229
- if (_.every(requiredFields, isNotEmpty)){
4304
+ if (_.every(requiredFields, isNotEmpty)) {
4230
4305
  window.location.href = $(form).attr('data-action');
4231
4306
  return false;
4232
4307
  }
@@ -4234,7 +4309,7 @@ Wick.Forms = (function(){
4234
4309
 
4235
4310
  if ($(form).is('#checkout-your-details-modal')) {
4236
4311
  var requiredFields = $(form).find('[data-row-required]:visible :input');
4237
- if (_.every(requiredFields, isNotEmpty)){
4312
+ if (_.every(requiredFields, isNotEmpty)) {
4238
4313
  $('#modalDeliveryEdit').modal('hide');
4239
4314
  return false;
4240
4315
  }
@@ -4248,15 +4323,15 @@ Wick.Forms = (function(){
4248
4323
  }
4249
4324
  }
4250
4325
 
4251
- if ($(form).is('.checkout-register')){
4326
+ if ($(form).is('.checkout-register')) {
4252
4327
  if ($(form).find('#password').val().length &&
4253
- $(form).find('#confirm-password').val().length) {
4328
+ $(form).find('#confirm-password').val().length) {
4254
4329
  window.location.href = './page_my-account.html';
4255
4330
  return false;
4256
4331
  }
4257
4332
  }
4258
4333
 
4259
- if ($(form).is('#form-checkout-voucher')){
4334
+ if ($(form).is('#form-checkout-voucher')) {
4260
4335
  if ($(form).find('#voucher-code').val().length) {
4261
4336
  return false;
4262
4337
  }
@@ -4268,11 +4343,11 @@ Wick.Forms = (function(){
4268
4343
  }
4269
4344
  }
4270
4345
 
4271
- if ($(form).is('.header-search')){
4346
+ if ($(form).is('.header-search')) {
4272
4347
  window.location.href = './page_search-results.html';
4273
4348
  }
4274
4349
 
4275
- if ($(form).is('.click-and-collect__locator-form')){
4350
+ if ($(form).is('.click-and-collect__locator-form')) {
4276
4351
  var $form = $(form);
4277
4352
  if ($form.find('#click-and-collect-town').val().length) {
4278
4353
  clearValidationErrors(this);
@@ -4285,24 +4360,24 @@ Wick.Forms = (function(){
4285
4360
  return false;
4286
4361
  }
4287
4362
 
4288
- if($(form).is('.form-track-order')) {
4289
- var $form = $(form);
4363
+ if ($(form).is('.form-track-order')) {
4364
+ var $form = $(form);
4290
4365
 
4291
- if ($form.find('#order').val().length &&
4292
- $form.find('#tel').val().length &&
4293
- $form.find('#email').val().length &&
4294
- $form.find('#postcode').val().length) {
4295
- clearValidationErrors(this);
4296
- } else if (!$form.hasClass(formInvalid)) {
4297
- $form.addClass(formInvalid);
4366
+ if ($form.find('#order').val().length &&
4367
+ $form.find('#tel').val().length &&
4368
+ $form.find('#email').val().length &&
4369
+ $form.find('#postcode').val().length) {
4370
+ clearValidationErrors(this);
4371
+ } else if (!$form.hasClass(formInvalid)) {
4372
+ $form.addClass(formInvalid);
4298
4373
 
4299
- $(fieldRow).each(function() {
4300
- $(this).addClass(rowValidationError)
4301
- .append('<div class="form-row__error">' + $(this).data('message') + '</div>');
4302
- });
4303
- }
4374
+ $(fieldRow).each(function() {
4375
+ $(this).addClass(rowValidationError)
4376
+ .append('<div class="form-row__error">' + $(this).data('message') + '</div>');
4377
+ });
4378
+ }
4304
4379
 
4305
- return false;
4380
+ return false;
4306
4381
  }
4307
4382
 
4308
4383
  if ($(form).is('#edit-billing-address')) {
@@ -4318,28 +4393,28 @@ Wick.Forms = (function(){
4318
4393
  };
4319
4394
 
4320
4395
  var scrollLocatorListPage = function() {
4321
- var isLocatorListPage = $('.cards-store-list').length;
4322
- var isScrollNeeded = window.location.hash === "#stores-list";
4323
- if (isLocatorListPage && isScrollNeeded) {
4324
- handleSmoothScroll();
4325
- }
4396
+ var isLocatorListPage = $('.cards-store-list').length;
4397
+ var isScrollNeeded = window.location.hash === '#stores-list';
4398
+ if (isLocatorListPage && isScrollNeeded) {
4399
+ handleSmoothScroll();
4400
+ }
4326
4401
  };
4327
4402
 
4328
- let bindEvents = function () {
4403
+ let bindEvents = function() {
4329
4404
  let selector = excludedClassesForForm.reduce((acc, className) => {
4330
4405
  return acc + ':not([class^="' + className + '"])';
4331
4406
  }, 'form');
4332
4407
  $(document).on('submit', selector, handleFormSubmit);
4333
4408
  $forgotPassword.on('click', scenarios[2].action);
4334
- $('.btn-cancel').on('click', function(){
4409
+ $('.btn-cancel').on('click', function() {
4335
4410
  window.location.href = './page_my-account.html';
4336
4411
  });
4337
- $('.btn-previous').on('click', function(){
4412
+ $('.btn-previous').on('click', function() {
4338
4413
  window.location.href = './page_login.html';
4339
4414
  });
4340
4415
  };
4341
4416
 
4342
- var init = function () {
4417
+ var init = function() {
4343
4418
  bindEvents();
4344
4419
  scrollLocatorListPage();
4345
4420
  };
@@ -4348,8 +4423,8 @@ Wick.Forms = (function(){
4348
4423
 
4349
4424
  return {
4350
4425
  showValidationErrors: showValidationErrors,
4351
- clearValidationErrors: clearValidationErrors
4352
- }
4426
+ clearValidationErrors: clearValidationErrors,
4427
+ };
4353
4428
  })();
4354
4429
 
4355
4430
  var Wick = Wick || {};
@@ -11782,6 +11857,8 @@ $(document).ready(function () {
11782
11857
  initMyOrdersEvent();
11783
11858
  });
11784
11859
 
11860
+ var Wick = Wick || {};
11861
+
11785
11862
  const paymentLoader= '.payment-loader';
11786
11863
  const paymentLoaderHideClass= 'payment-loader--hidden';
11787
11864
  const paymentLoaderModal = '.payment-loader__modal'
@@ -11789,11 +11866,10 @@ const paymentTypeSelectors = {
11789
11866
  apple: '.apple__button',
11790
11867
  google: '.google__button',
11791
11868
  clearpay: '#checkout-payment-details-clearpay',
11792
- billie: '#checkout-payment-details-billie, .billie__button',
11793
11869
  paypal: '#checkout-payment-details-paypal'
11794
11870
  };
11795
11871
 
11796
- function showPaymentLoader(paymentType) {
11872
+ Wick.showPaymentLoader = function(paymentType) {
11797
11873
  $(paymentLoader).find(`${paymentLoaderModal} > div`).hide();
11798
11874
  $(`.${paymentType}-checkout-logo`).show();
11799
11875
  $(`${paymentLoader} .spinner`).show();
@@ -11805,7 +11881,7 @@ function showPaymentLoader(paymentType) {
11805
11881
  }
11806
11882
 
11807
11883
  Object.entries(paymentTypeSelectors).forEach(([type, triggerSelector]) => {
11808
- $(document).on('click', triggerSelector, () => showPaymentLoader(type));
11884
+ $(document).on('click', triggerSelector, () => Wick.showPaymentLoader(type));
11809
11885
  });
11810
11886
 
11811
11887
  var Wick = Wick || {};
@@ -12836,6 +12912,42 @@ Wick.ReferenceField = (function () {
12836
12912
  init();
12837
12913
  })();
12838
12914
 
12915
+ var Wick = Wick || {};
12916
+
12917
+ Wick.RepaymentToggle = (function () {
12918
+ const SELECTORS = {
12919
+ repaymentRadio: 'input[name="repaymentTerms"]',
12920
+ term: '.billie-info .term',
12921
+ paymentMethod: '[name="payment-method"]'
12922
+ };
12923
+
12924
+ function updateTerm(value) {
12925
+ const $term = $(SELECTORS.term);
12926
+ if (!$term.length) return;
12927
+
12928
+ $term.text(value);
12929
+ }
12930
+
12931
+ function bindEvents () {
12932
+ $(document).on('change', SELECTORS.repaymentRadio, function () {
12933
+ const value = $(this).val();
12934
+ if (!value) return;
12935
+
12936
+ updateTerm(value);
12937
+
12938
+ const currentMethod = $(SELECTORS.paymentMethod + ':checked').val();
12939
+ if (currentMethod !== 'billie') return;
12940
+
12941
+ if (typeof Wick.showPaymentLoader === 'function') {
12942
+ Wick.showPaymentLoader('billie');
12943
+ }
12944
+
12945
+ });
12946
+ }
12947
+
12948
+ bindEvents();
12949
+ })();
12950
+
12839
12951
  var Wick = Wick || {};
12840
12952
  Wick.Selectable = (function(){
12841
12953
  $selectable = $('.js-selectable'),
@@ -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
  }