wickes-css2 2.97.0-IM-1593-code-width.1 → 2.97.0-develop.1

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 (102) hide show
  1. package/build/css/category-main.css +1 -1
  2. package/build/css/components/tile-calculator.css +1 -1
  3. package/build/css/main.css +1 -1
  4. package/build/css/my-account-main-v2.css +1 -1
  5. package/build/css/my-account-main.css +1 -1
  6. package/build/css/pages/page_address-book.css +1 -0
  7. package/build/css/pages/page_change-password.css +1 -0
  8. package/build/css/pages/page_ti.css +1 -1
  9. package/build/css/pages/tradePro-rewards.css +1 -1
  10. package/build/css/pdp-main-before-combine.css +1 -1
  11. package/build/css/pdp-main-critical.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/js/account-members.min.js +1 -1
  15. package/build/js/add-project-list-id.min.js +1 -1
  16. package/build/js/address-book.min.js +1 -0
  17. package/build/js/basket.min.js +2 -2
  18. package/build/js/bundle.min.js +1 -1
  19. package/build/js/change-password.min.js +1 -0
  20. package/build/js/checkout.min.js +2 -2
  21. package/build/js/emulation.min.js +7 -10
  22. package/build/js/energy-efficiency.min.js +1 -1
  23. package/build/js/general.bundle.min.js +1 -1
  24. package/build/js/global-search.min.js +1 -1
  25. package/build/js/merged-checkout.min.js +2 -2
  26. package/build/js/page/address-book.js +193 -0
  27. package/build/js/page/change-password.js +118 -0
  28. package/build/js/page/utils/errorMesages.js +14 -0
  29. package/build/js/page/utils/helpers.js +18 -0
  30. package/build/js/page/utils/validation.js +5 -1
  31. package/build/js/pdp.bundle.min.js +1 -1
  32. package/build/js/personal-details.min.js +1 -1
  33. package/build/js/plp.bundle.min.js +1 -1
  34. package/build/js/project-list.min.js +6 -2
  35. package/build/js/pstrength.min.js +161 -0
  36. package/build/js/quiz.min.js +1 -1
  37. package/build/js/track-my-order.min.js +1 -1
  38. package/package.json +10 -2
  39. package/src/components/address-card.hbs +40 -0
  40. package/src/components/base/link.hbs +13 -0
  41. package/src/components/leave-modal.hbs +13 -0
  42. package/src/components/my-account/delete-address-modal.hbs +23 -0
  43. package/src/components/my-account/leave-modal.hbs +1 -1
  44. package/src/components/pdp-info-v2.hbs +37 -0
  45. package/src/components/price-block-order.hbs +0 -1
  46. package/src/components/shopping-list-pdf.hbs +7 -37
  47. package/src/components/ti-header.hbs +34 -0
  48. package/src/components/ti-radio.hbs +57 -0
  49. package/src/components/ti-total-area.hbs +32 -0
  50. package/src/components/ti.hbs +791 -0
  51. package/src/components/tile-banner.hbs +13 -0
  52. package/src/components/tile-why-wickes.hbs +32 -0
  53. package/src/components/voucher.hbs +7 -6
  54. package/src/data/data_flooring-installation.json +186 -0
  55. package/src/data/data_voucher_tradePro.json +1 -1
  56. package/src/data/my-account/data_address-book.json +225 -0
  57. package/src/data/my-account/data_change-password.json +85 -0
  58. package/src/elements/form-row.hbs +11 -2
  59. package/src/js/components/general/switchVat.js +0 -11
  60. package/src/js/components/leave-event.js +2 -0
  61. package/src/js/components/pwdstrength.js +21 -0
  62. package/src/js/components/toggle-password-visibility.js +58 -0
  63. package/src/js/emulation/checkout_your-details.js +5 -5
  64. package/src/js/emulation/forms.js +1 -1
  65. package/src/js/emulation/project-list-print.js +1 -4
  66. package/src/js/libs/jquery.pstrength.custom-1.2.0.js +161 -0
  67. package/src/js/page/address-book.js +193 -0
  68. package/src/js/page/change-password.js +118 -0
  69. package/src/js/page/utils/errorMesages.js +14 -0
  70. package/src/js/page/utils/helpers.js +18 -0
  71. package/src/js/page/utils/validation.js +5 -1
  72. package/src/layouts/base.hbs +1 -1
  73. package/src/page_my-account_address-book-form.html +94 -0
  74. package/src/page_my-account_address-book.html +47 -24
  75. package/src/page_my-account_address-book_tradePro.html +45 -18
  76. package/src/page_my-account_change-password.html +62 -29
  77. package/src/page_personal-details-installer.html +6 -4
  78. package/src/page_personal-details.html +2 -0
  79. package/src/partials/header.hbs +1 -1
  80. package/src/scss/common/_common.scss +8 -0
  81. package/src/scss/components/_cards-slider.scss +0 -26
  82. package/src/scss/components/_leave-modal.scss +75 -0
  83. package/src/scss/components/_price-block-critical.scss +3 -3
  84. package/src/scss/components/_price-block.scss +8 -3
  85. package/src/scss/components/_rewards.scss +0 -20
  86. package/src/scss/components/_ti-header.scss +43 -0
  87. package/src/scss/components/_ti-radio.scss +142 -0
  88. package/src/scss/components/_ti-total-area.scss +53 -0
  89. package/src/scss/components/_tile-banner.scss +141 -0
  90. package/src/scss/components/_tile-why-wickes.scss +57 -0
  91. package/src/scss/components/tile-calculator.scss +4 -1
  92. package/src/scss/helpers/_mixins.scss +8 -0
  93. package/src/scss/libs/_pstrength.scss +34 -0
  94. package/src/scss/pages/_my-account_change-password.scss +0 -2
  95. package/src/scss/pages/page_address-book.scss +356 -0
  96. package/src/scss/pages/page_change-password.scss +147 -0
  97. package/src/scss/pages/page_ti.scss +719 -3
  98. package/src/scss/pages/tradePro-rewards.scss +1 -0
  99. package/src/sitemap.html +3 -4
  100. package/src/page_activate-trade-pro-api-flow.html +0 -62
  101. package/src/page_my-shopping-list-pdf-vat.html +0 -7
  102. /package/src/components/{button.hbs → base/button.hbs} +0 -0
@@ -0,0 +1,58 @@
1
+ var Wick = window.Wick || {};
2
+
3
+ Wick.TogglePasswordVisibility = {
4
+ el: {
5
+ $toggleShow: $('[data-show-content] .toggle-show'),
6
+ inputWrap: $('.form-row[data-show-content] .input-wrap'),
7
+ toggleIcon: '.toggle-show',
8
+ },
9
+
10
+ updateIconVisibility(inputField, toggleIcon) {
11
+ const valueLength = inputField.val().length;
12
+ if (valueLength > 0) {
13
+ toggleIcon.show();
14
+ } else {
15
+ toggleIcon.hide();
16
+ }
17
+ },
18
+
19
+ attachInputListener(inputField, toggleIcon) {
20
+ inputField.on('input', function () {
21
+ Wick.TogglePasswordVisibility.updateIconVisibility($(this), toggleIcon);
22
+ });
23
+ },
24
+
25
+ attachToggleClickListener(inputField, toggleIcon) {
26
+ toggleIcon.on('click', function () {
27
+ const isPasswordType = inputField.attr('type') === 'password';
28
+ const iconSvg = $(this).find('svg');
29
+
30
+ if (isPasswordType) {
31
+ inputField.attr('type', 'text');
32
+ iconSvg.removeClass('fa-eye-slash').addClass('fa-eye');
33
+ } else {
34
+ inputField.attr('type', 'password');
35
+ iconSvg.removeClass('fa-eye').addClass('fa-eye-slash');
36
+ }
37
+ });
38
+ },
39
+
40
+ init() {
41
+ Wick.TogglePasswordVisibility.el.inputWrap.each(function () {
42
+ const inputField = $(this).find('input');
43
+ const toggleIcon = $(this).find(Wick.TogglePasswordVisibility.el.toggleIcon);
44
+
45
+ Wick.TogglePasswordVisibility.attachInputListener(inputField, toggleIcon);
46
+ Wick.TogglePasswordVisibility.updateIconVisibility(inputField, toggleIcon);
47
+ Wick.TogglePasswordVisibility.attachToggleClickListener(inputField, toggleIcon);
48
+ });
49
+ },
50
+ };
51
+
52
+ $(document).ready(function () {
53
+ if (!Wick.TogglePasswordVisibility.el.$toggleShow.length) {
54
+ return;
55
+ }
56
+
57
+ Wick.TogglePasswordVisibility.init();
58
+ });
@@ -2,12 +2,12 @@ var Wick = Wick || {};
2
2
  Wick.YourDetails = (function(){
3
3
  var $self = $('.checkout-your-details');
4
4
  let closeBlock = $('.close-block'),
5
- $firstLineAddrRow = closeBlock.find("#first-line-address").parents(".form-row"),
6
- $firstLineAddrLable = closeBlock.find("#first-line-address").closest(".form-row__label"),
7
- $firstLineAddrField = closeBlock.find("#first-line-address").parents(".form-row__field"),
5
+ $firstLineAddrRow = closeBlock.find("#address-lookup-query").parents(".form-row"),
6
+ $firstLineAddrLable = closeBlock.find("#address-lookup-query").closest(".form-row__label"),
7
+ $firstLineAddrField = closeBlock.find("#address-lookup-query").parents(".form-row__field"),
8
8
  formError = ".form-row__error",
9
9
  listElement = $('.close-block').find('li'),
10
- firstLineAddress = $('.close-block #first-line-address');
10
+ firstLineAddress = $('.close-block #address-lookup-query');
11
11
 
12
12
  var bindEvents = function () {
13
13
  $(document).on('click', '.btn-edit-manually', function(){
@@ -66,7 +66,7 @@ Wick.YourDetails = (function(){
66
66
  })
67
67
  //end -> fix for ONLINE-2616
68
68
 
69
- $(document).on('blur', '.close-block #first-line-address', function() {
69
+ $(document).on('blur', '.close-block #address-lookup-query', function() {
70
70
  if( $(this).val() ) {
71
71
  $('.close-block [data-manually]').removeClass('d-none');
72
72
  $('.close-block [data-manually]').addClass('d-block');
@@ -5,7 +5,7 @@ Wick.Forms = (function(){
5
5
  fieldError = '.form-row__error',
6
6
  formInvalid = 'form_invalid',
7
7
  rowValidationError = 'form-row_validation-error',
8
- excludedClassesForForm = ['header', 'quiz-modal__form', 'search-store', 'track-order-form'],
8
+ excludedClassesForForm = ['header', 'quiz-modal__form', 'search-store', 'track-order-form', 'change-password__form', 'address-book__form'],
9
9
  // validationError = '<div class="form-row__error">Error message here</div>',
10
10
  $forgotPassword = $('.link-forgot-password'),
11
11
  scenarios = [{
@@ -1,5 +1,3 @@
1
- var Wick = window.Wick || {};
2
-
3
1
  function initProjectShadowList() {
4
2
  $('.download-pdf').on('click', emulateDownloadAction);
5
3
  }
@@ -9,8 +7,7 @@ function emulateDownloadAction(e) {
9
7
 
10
8
  let currentUrl = window.location.href;
11
9
  let baseUrl = currentUrl.substring(0, currentUrl.lastIndexOf('/') + 1);
12
- let pageName = Wick.VatToggle.isToggleVatAvailable() ? 'page_my-shopping-list-pdf-vat.html' : 'page_my-shopping-list-pdf.html';
13
- let pageShoppingListPDF = baseUrl + pageName;
10
+ let pageShoppingListPDF = baseUrl + 'page_my-shopping-list-pdf.html';
14
11
 
15
12
  $.ajax({
16
13
  type: 'get',
@@ -0,0 +1,161 @@
1
+ /* jQuery Password Strength Plugin (pstrength) - A jQuery plugin to provide accessibility functions
2
+ * Author: Tane Piper (digitalspaghetti@gmail.com)
3
+ * Website: http://digitalspaghetti.me.uk
4
+ * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
5
+ * This code uses a modified version of Steve Moitozo's algorithm (http://www.geekwisdom.com/dyn/passwdmeter)
6
+ *
7
+ * === Changelog ===
8
+ * Version 1.2 (03/09/2007)
9
+ * Added more options for colors and common words
10
+ * Added common words checked to see if words like 'password' or 'qwerty' are being entered
11
+ * Added minimum characters required for password
12
+ * Re-worked scoring system to give better results
13
+ *
14
+ * Version 1.1 (20/08/2007)
15
+ * Changed code to be more jQuery-like
16
+ *
17
+ * Version 1.0 (20/07/2007)
18
+ * Initial version.
19
+ */
20
+ (function($){
21
+ $.extend($.fn, {
22
+ pstrength : function(options) {
23
+ var options = $.extend({
24
+ verdicts: ["Very Weak","Weak","Medium","Strong","Very strong"],
25
+ colors: ["red", "red", "orange", "green", "green"],
26
+ scores: [10,15,30,40],
27
+ minchar: 6,
28
+ tooShort: "Too Short!",
29
+ minCharText: "Minimum length is %d characters"
30
+ },options);
31
+ return this.each(function(){
32
+ var infoarea = $(this).attr('id');
33
+ let parentElement = $(this).closest('.form-row__field');
34
+
35
+ var strengthDivs = `<div class="pstrength-bars" id="${infoarea}_bars" style="display: none">
36
+ <div class="pstrength-bar gray"></div>
37
+ <div class="pstrength-bar gray"></div>
38
+ <div class="pstrength-bar gray"></div>
39
+ <div class="pstrength-bar gray"></div>
40
+ </div>`;
41
+ parentElement.append(strengthDivs);
42
+ parentElement.append('<div class="pstrength-info" id="' + infoarea + '_text" style="display: none"></div>');
43
+
44
+ // Bind keyup event
45
+ $(this).on("keyup", function() {
46
+ $.fn.runPassword($(this).val(), infoarea, options);
47
+ });
48
+ });
49
+ },
50
+ runPassword : function (password, infoarea, options){
51
+ var nPerc = $.fn.checkPassword(password, options);
52
+
53
+ var numBars = 0;
54
+ var strColor = "";
55
+ var strText = "";
56
+
57
+ if (nPerc < 0) {
58
+ strColor = "#ccc";
59
+ strText = options.tooShort;
60
+ numBars = 0;
61
+ } else if (nPerc <= options.scores[0]) {
62
+ strColor = options.colors[0];
63
+ strText = options.verdicts[0];
64
+ numBars = 1;
65
+ } else if (nPerc > options.scores[0] && nPerc <= options.scores[1]) {
66
+ strColor = options.colors[1];
67
+ strText = options.verdicts[1];
68
+ numBars = 1;
69
+ } else if (nPerc > options.scores[1] && nPerc <= options.scores[2]) {
70
+ strColor = options.colors[2];
71
+ strText = options.verdicts[2];
72
+ numBars = 2;
73
+ } else if (nPerc > options.scores[2] && nPerc <= options.scores[3]) {
74
+ strColor = options.colors[3];
75
+ strText = options.verdicts[3];
76
+ numBars = 3;
77
+ } else {
78
+ strColor = options.colors[4];
79
+ strText = options.verdicts[4];
80
+ numBars = 4;
81
+ }
82
+
83
+ var $ctlBarsText = $("#" + infoarea + "_text");
84
+ var $ctlBars = $("#" + infoarea + "_bars");
85
+ var $ctlBarsChild = $("#" + infoarea + "_bars .pstrength-bar");
86
+ $ctlBarsText.show();
87
+ $ctlBars.show();
88
+ $ctlBarsChild.removeClass("red orange green").addClass("gray");
89
+ for (let i = 0; i < numBars; i++) {
90
+ $ctlBarsChild.eq(i).removeClass("gray").addClass(strColor);
91
+ }
92
+
93
+ var $ctlText = $("#" + infoarea + "_text");
94
+ $ctlText.html("<span>" + strText + "</span>");
95
+ },
96
+ checkPassword : function(password, options)
97
+ {
98
+ var intScore = 0;
99
+ var strVerdict = options.verdicts[0];
100
+ // PASSWORD LENGTH
101
+ if (password.length < options.minchar) // Password too short
102
+ {
103
+ intScore = (intScore - 100);
104
+ }
105
+ else if (password.length >= options.minchar && password.length <= (options.minchar + 2)) // Password Short
106
+ {
107
+ intScore = (intScore + 6);
108
+ }
109
+ else if (password.length >= (options.minchar + 3) && password.length <= (options.minchar + 4))// Password Medium
110
+ {
111
+ intScore = (intScore + 12);
112
+ }
113
+ else if (password.length >= (options.minchar + 5)) // Password Large
114
+ {
115
+ intScore = (intScore + 18);
116
+ }
117
+ if (password.match(/[a-z]/)) // [verified] at least one lower case letter
118
+ {
119
+ intScore = (intScore + 1);
120
+ }
121
+ if (password.match(/[A-Z]/)) // [verified] at least one upper case letter
122
+ {
123
+ intScore = (intScore + 5);
124
+ }
125
+ // NUMBERS
126
+ if (password.match(/\d+/)) // [verified] at least one number
127
+ {
128
+ intScore = (intScore + 5);
129
+ }
130
+ if (password.match(/(.*[0-9].*[0-9].*[0-9])/)) // [verified] at least three numbers
131
+ {
132
+ intScore = (intScore + 7);
133
+ }
134
+ // SPECIAL CHAR
135
+ if (password.match(/.[!,@,#,$,%,^,&,*,?,_,~]/)) // [verified] at least one special character
136
+ {
137
+ intScore = (intScore + 5);
138
+ }
139
+ // [verified] at least two special characters
140
+ if (password.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/))
141
+ {
142
+ intScore = (intScore + 7);
143
+ }
144
+ // COMBOS
145
+ if (password.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)) // [verified] both upper and lower case
146
+ {
147
+ intScore = (intScore + 2);
148
+ }
149
+ if (password.match(/([a-zA-Z])/) && password.match(/([0-9])/)) // [verified] both letters and numbers
150
+ {
151
+ intScore = (intScore + 3);
152
+ }
153
+ // [verified] letters, numbers, and special characters
154
+ if (password.match(/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/))
155
+ {
156
+ intScore = (intScore + 3);
157
+ }
158
+ return intScore;
159
+ }
160
+ });
161
+ })(jQuery);
@@ -0,0 +1,193 @@
1
+ import {
2
+ isValidFieldSize,
3
+ isValidInputTextField,
4
+ isValidPhoneNumber,
5
+ isValidPostcodeField,
6
+ updateStylingError
7
+ } from "./utils/validation";
8
+ import errorMessages from "./utils/errorMesages";
9
+ import {scrollToElement, trimFields} from "./utils/helpers";
10
+
11
+ var Wick = window.Wick || {};
12
+
13
+ Wick.AddressBook = {
14
+ el: {
15
+ $addressBook: $('.address-book'),
16
+ addressCard: '.address-card',
17
+ addressCardInformation: '.address-card__information',
18
+ deleteAddressModal: '.delete-modal',
19
+ deleteAddressLink: '.link--delete',
20
+ deleteModalContent: '.delete-modal .address-info__data',
21
+ deleteModalContinue: '.delete-modal .btn-continue',
22
+ addressForm: '.address-book__form',
23
+ btnCancel: '.address-book__form [data-action="cancel-form"]',
24
+ btnSaveForm: '.address-book__form [data-action="save-form"]',
25
+ $firstName: $('#firstName'),
26
+ $surName: $('#lastName'),
27
+ $addressLookupQuery: $('#address-lookup-query'),
28
+ $addressLine1: $('#address-line-1'),
29
+ $addressLine2: $('#address-line-2'),
30
+ $townCity: $('#town-city'),
31
+ $postCode: $('#postcode_additional'),
32
+ $mobilePhone: $('#mobile-telephone'),
33
+ $homePhone: $('#home-telephone'),
34
+ formRow: '.form-row',
35
+ formRowError: '.form-row__error'
36
+ },
37
+ getFieldsConfigurations: function () {
38
+ return [
39
+ {
40
+ input: Wick.AddressBook.el.$firstName,
41
+ validator: [isValidFieldSize, isValidInputTextField],
42
+ error: errorMessages.errorName,
43
+ },
44
+ {
45
+ input: Wick.AddressBook.el.$surName,
46
+ validator: [isValidFieldSize, isValidInputTextField],
47
+ error: errorMessages.errorSurname,
48
+ },
49
+ {
50
+ input: Wick.AddressBook.el.$addressLookupQuery,
51
+ validator: isValidFieldSize,
52
+ error: errorMessages.errorAddress,
53
+ },
54
+ {
55
+ input: Wick.AddressBook.el.$addressLine1,
56
+ validator: [isValidFieldSize, isValidInputTextField],
57
+ error: errorMessages.errorAddressLine1,
58
+ },
59
+ {
60
+ input: Wick.AddressBook.el.$addressLine2,
61
+ validator: isValidInputTextField,
62
+ error: errorMessages.errorAddressLine2,
63
+ required: false
64
+ },
65
+ {
66
+ input: Wick.AddressBook.el.$townCity,
67
+ validator: [isValidFieldSize, isValidInputTextField],
68
+ error: errorMessages.errorTown,
69
+ },
70
+ {
71
+ input: Wick.AddressBook.el.$postCode,
72
+ validator: [isValidFieldSize, isValidPostcodeField],
73
+ error: errorMessages.errorPostcode,
74
+ },
75
+ {
76
+ input: Wick.AddressBook.el.$mobilePhone,
77
+ validator: [isValidFieldSize, isValidPhoneNumber],
78
+ error: [errorMessages.errorMobilePhoneEmpty, errorMessages.errorMobilePhone],
79
+ },
80
+ {
81
+ input: Wick.AddressBook.el.$homePhone,
82
+ validator: isValidPhoneNumber,
83
+ error: errorMessages.errorHomePhone,
84
+ required: false
85
+ }
86
+ ];
87
+ },
88
+ validateInput: function (input, validatorFunction, errorMsg) {
89
+ const value = $(input).val();
90
+ let isValid = true;
91
+
92
+ const validators = Array.isArray(validatorFunction) ? validatorFunction : [validatorFunction];
93
+ const errors = Array.isArray(errorMsg) ? errorMsg : [errorMsg];
94
+
95
+ for (let index = 0; index < validators.length; index++) {
96
+ const validator = validators[index];
97
+ const isFieldValid = validator(value);
98
+
99
+ if (!isFieldValid) {
100
+ const currentErrorMessage = index < errors.length ? errors[index] : errors[0];
101
+ updateStylingError(input, isFieldValid, currentErrorMessage);
102
+
103
+ isValid = false;
104
+ break;
105
+ }
106
+ }
107
+
108
+ if (isValid) {
109
+ updateStylingError(input, true, '');
110
+ }
111
+
112
+ return isValid;
113
+ },
114
+ validateForm: function () {
115
+ trimFields();
116
+ let isValid = true;
117
+ const fields = Wick.AddressBook.getFieldsConfigurations();
118
+
119
+ fields.forEach((field) => {
120
+ const value = field.input.val();
121
+ const required = field.required !== false;
122
+
123
+ if (!required && !value) {
124
+ updateStylingError(field.input, true, '');
125
+ return;
126
+ }
127
+
128
+ isValid =
129
+ Wick.AddressBook.validateInput(field.input, field.validator, field.error) && isValid;
130
+ });
131
+
132
+ return isValid;
133
+ },
134
+ handleFormSubmit: function () {
135
+ $(Wick.AddressBook.el.addressForm).on('submit', function (event) {
136
+ event.preventDefault();
137
+
138
+ if (Wick.AddressBook.validateForm()) {
139
+ Wick.LeaveEvent.proceedBrowserLeave = false;
140
+ $(Wick.AddressBook.el.btnSaveForm).attr('disabled', true);
141
+ event.target.submit();
142
+ } else {
143
+ const targetElement = $(Wick.AddressBook.el.formRowError).closest(Wick.AddressBook.el.formRow)[0];
144
+
145
+ scrollToElement(targetElement);
146
+ }
147
+ });
148
+ },
149
+ deleteAddress() {
150
+ $(Wick.AddressBook.el.deleteAddressLink).on('click', function (e) {
151
+ e.preventDefault();
152
+
153
+ const $clickedLink = $(this);
154
+ const href = $clickedLink.attr('data-link');
155
+
156
+ const $addressCard = $(this).closest(Wick.AddressBook.el.addressCard);
157
+ const cardInfo = $addressCard.find(Wick.AddressBook.el.addressCardInformation).html();
158
+
159
+ $(Wick.AddressBook.el.deleteModalContent).html(cardInfo);
160
+
161
+ $(Wick.AddressBook.el.deleteModalContinue).on('click', function () {
162
+ window.location.href = href;
163
+ });
164
+
165
+ Wick.AddressBook.showModal();
166
+ });
167
+ },
168
+ showModal() {
169
+ $(Wick.AddressBook.el.deleteAddressModal).modal('show');
170
+ },
171
+ clearModal() {
172
+ $(Wick.AddressBook.el.deleteAddressModal).on('hidden.bs.modal', function () {
173
+ $(this).find(Wick.AddressBook.el.addressCardInformation).html('');
174
+ });
175
+ },
176
+ init () {
177
+ Wick.LeaveEvent.bindEvent(
178
+ Wick.AddressBook.el.addressForm,
179
+ Wick.AddressBook.el.btnCancel,
180
+ );
181
+ Wick.AddressBook.deleteAddress();
182
+ Wick.AddressBook.clearModal();
183
+ Wick.AddressBook.handleFormSubmit();
184
+ }
185
+ }
186
+
187
+ $(document).ready(function () {
188
+ if (!Wick.AddressBook.el.$addressBook.length) {
189
+ return;
190
+ }
191
+
192
+ Wick.AddressBook.init();
193
+ });
@@ -0,0 +1,118 @@
1
+ import {isValidFieldSize, isValidPasswordSize, updateStylingError} from "./utils/validation";
2
+
3
+ var Wick = window.Wick || {};
4
+
5
+ Wick.ChangePassword = {
6
+ el: {
7
+ changePasswordForm: '.change-password__form',
8
+ fieldRow: '.form-row',
9
+ $currentPassword: $('#currentPassword'),
10
+ $newPassword: $('#newPassword'),
11
+ $confirmPassword: $('#confirmPassword'),
12
+ formInvalidClass: 'form_invalid',
13
+ fieldError: '.form-row.form-row_validation-error',
14
+ btnCancel: '[data-action="cancel-form"]',
15
+ btnReset: '[data-action="reset-details"]',
16
+ saveForm: '[data-action="save-form"]'
17
+ },
18
+ errorMessages: {
19
+ errorCurrentPassword: 'Please enter your current password',
20
+ errorNewPassword: 'Please enter a strong password (at least 6 characters)',
21
+ errorPasswordMismatch: 'Password and password confirmation do not match'
22
+ },
23
+ defaultNotificationConfig: {
24
+ container: '.change-password .globalMessages .container',
25
+ closeBtn: true,
26
+ noScrolling: true,
27
+ },
28
+ getFieldsConfigurations: function () {
29
+ return [
30
+ {
31
+ input: Wick.ChangePassword.el.$currentPassword,
32
+ validator: isValidFieldSize,
33
+ error: Wick.ChangePassword.errorMessages.errorCurrentPassword,
34
+ },
35
+ {
36
+ input: Wick.ChangePassword.el.$newPassword,
37
+ validator: isValidPasswordSize,
38
+ error: Wick.ChangePassword.errorMessages.errorNewPassword,
39
+ },
40
+ {
41
+ input: Wick.ChangePassword.el.$confirmPassword,
42
+ validator: isValidPasswordSize,
43
+ error: Wick.ChangePassword.errorMessages.errorNewPassword,
44
+ },
45
+ ];
46
+ },
47
+ validateInput: function (input, validatorFunction, errorMsg) {
48
+ const value = $(input).val();
49
+
50
+ const isValid = validatorFunction(value);
51
+ updateStylingError(input, isValid, errorMsg);
52
+
53
+ return isValid;
54
+ },
55
+ validateForm: function () {
56
+ let isValid = true;
57
+
58
+ const fields = Wick.ChangePassword.getFieldsConfigurations();
59
+
60
+ fields.forEach((field) => {
61
+ isValid =
62
+ Wick.ChangePassword.validateInput(field.input, field.validator, field.error) && isValid;
63
+ });
64
+
65
+ if (isValid) {
66
+ const newPassword = Wick.ChangePassword.el.$newPassword.val();
67
+ const confirmPassword = Wick.ChangePassword.el.$confirmPassword.val();
68
+
69
+ if (newPassword !== confirmPassword) {
70
+ isValid = false;
71
+ updateStylingError(
72
+ Wick.ChangePassword.el.$confirmPassword,
73
+ false,
74
+ Wick.ChangePassword.errorMessages.errorPasswordMismatch
75
+ );
76
+ }
77
+ }
78
+
79
+ return isValid;
80
+ },
81
+ handleChangePasswordFormSubmit: function () {
82
+ $(Wick.ChangePassword.el.changePasswordForm).on('submit', function (event) {
83
+ event.preventDefault();
84
+
85
+ if (Wick.ChangePassword.validateForm()) {
86
+ Wick.LeaveEvent.removeLeaveEvent();
87
+ event.target.submit();
88
+ }
89
+ });
90
+ },
91
+ hasUnsavedChanges() {
92
+ const currentState = Wick.LeaveEvent.getState(Wick.ChangePassword.el.changePasswordForm);
93
+
94
+ return !_.isEqual(currentState, Wick.LeaveEvent.initialFormState);
95
+ },
96
+ reloadPage() {
97
+ location.reload();
98
+ },
99
+ init() {
100
+ Wick.LeaveEvent.bindEvent(
101
+ Wick.ChangePassword.el.changePasswordForm,
102
+ Wick.ChangePassword.el.btnCancel,
103
+ Wick.ChangePassword.el.btnReset,
104
+ Wick.ChangePassword.reloadPage
105
+ );
106
+
107
+ Wick.Pwdstrength.bindPStrength();
108
+ Wick.ChangePassword.handleChangePasswordFormSubmit();
109
+ },
110
+ };
111
+
112
+ $(document).ready(function () {
113
+ if (!$(Wick.ChangePassword.el.changePasswordForm).length) {
114
+ return;
115
+ }
116
+
117
+ Wick.ChangePassword.init();
118
+ });
@@ -0,0 +1,14 @@
1
+ const errorMessages = {
2
+ errorName: 'Please enter a first name',
3
+ errorSurname: 'Please enter a surname',
4
+ errorAddress: 'Please complete your address details',
5
+ errorAddressLine1: 'Please enter address line 1',
6
+ errorAddressLine2: 'Please enter address line 2',
7
+ errorTown: 'Please enter a town/city',
8
+ errorPostcode: 'Please enter a valid postcode',
9
+ errorMobilePhoneEmpty: 'Please enter mobile number',
10
+ errorMobilePhone: 'Please enter a valid mobile number with no spaces e.g. 07700900000',
11
+ errorHomePhone: 'Please enter a valid phone number. It should be 10 or 11 digits e.g. 01234 123456, 0123 412 3456'
12
+ }
13
+
14
+ export default errorMessages;
@@ -42,3 +42,21 @@ export function isTouchDevice () {
42
42
  export function isApp () {
43
43
  return navigator.userAgent.match(/TradeProMobile_iOS|TradeProMobile_Android|DIYMobile_iOS|DIYMobile_Android|DIYApp_Guest_Mobile_iOS|DIYApp_Guest_Mobile_Android|AGENT_PLACEHOLDER/i);
44
44
  }
45
+
46
+ export function trimFields () {
47
+ const fields = Wick.AddressBook.getFieldsConfigurations();
48
+ fields.forEach((field) => {
49
+ const trimmedValue = field.input.val().trim();
50
+ field.input.val(trimmedValue);
51
+ });
52
+ }
53
+
54
+ export function scrollToElement(element, offset = 20) {
55
+ const targetElement = $(element);
56
+
57
+ if (targetElement.length > 0) {
58
+ $('html, body').animate({
59
+ scrollTop: targetElement.offset().top - offset
60
+ }, 300);
61
+ }
62
+ }
@@ -95,7 +95,11 @@ export function validateCity(element) {
95
95
  }
96
96
 
97
97
  export function isValidFieldSize(value) {
98
- return value.length > 0 && value.length < 255;
98
+ return value.length > 0 && value.length < 256;
99
+ }
100
+
101
+ export function isValidPasswordSize(value) {
102
+ return value.length > 5 && value.length < 256;
99
103
  }
100
104
 
101
105
  export function isValidInputTextField(value) {
@@ -16,7 +16,7 @@
16
16
  {{> google-banner}}
17
17
  {{/if}}
18
18
  {{#block "header"}}
19
- {{> header chatBot=chatBot switch-vat=switch-vat }}
19
+ {{> header chatBot=chatBot }}
20
20
  {{/block}}
21
21
  <a id="skip-to-content"></a>
22
22
  {{#if hybrisClass}}