mod-build 4.0.0 → 4.0.1-beta.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.
- package/CHANGELOG.md +5 -0
- package/package.json +1 -1
- package/src/scripts/default/index.js +9 -0
- package/src/scripts/default/update-link-paths.js +7 -13
- package/src/scripts/default/use-dynamic-gtm.js +4 -5
- package/src/scripts/plugins.js +109 -0
- package/src/scripts/utils.js +12 -52
- package/tasks/serve.js +1 -1
- package/vite.config.js +3 -51
- package/src/accessible-components/button/_button.scss +0 -308
- package/src/accessible-components/button/back-button.html +0 -8
- package/src/accessible-components/button/button.html +0 -17
- package/src/accessible-components/carousel/_carousel.scss +0 -112
- package/src/accessible-components/carousel/carousel.html +0 -25
- package/src/accessible-components/carousel/carousel.js +0 -3426
- package/src/accessible-components/carousel/carousel.js.map +0 -1
- package/src/accessible-components/carousel/carousel.min.js +0 -6
- package/src/accessible-components/carousel/carousel.min.js.map +0 -1
- package/src/accessible-components/checkbox/_checkbox.scss +0 -153
- package/src/accessible-components/checkbox/checkbox-group.html +0 -18
- package/src/accessible-components/checkbox/checkbox.html +0 -8
- package/src/accessible-components/expand-collapse/_expand-collapse.scss +0 -129
- package/src/accessible-components/expand-collapse/expand-collapse.html +0 -14
- package/src/accessible-components/expand-collapse/expand-collapse.js +0 -52
- package/src/accessible-components/expand-collapse/expand-collapse.min.js +0 -2
- package/src/accessible-components/expand-collapse/expand-collapse.min.js.map +0 -1
- package/src/accessible-components/featured-block/_featured-block.scss +0 -221
- package/src/accessible-components/featured-block/featured-block.html +0 -54
- package/src/accessible-components/foot-assets/foot-assets.html +0 -112
- package/src/accessible-components/footer/footer.html +0 -2
- package/src/accessible-components/gtm-body/gtm-body.html +0 -4
- package/src/accessible-components/head/head.html +0 -187
- package/src/accessible-components/header/_header.scss +0 -287
- package/src/accessible-components/header/header.html +0 -66
- package/src/accessible-components/hero/_hero.scss +0 -405
- package/src/accessible-components/hero/hero.html +0 -53
- package/src/accessible-components/how-it-works/_how-it-works.scss +0 -217
- package/src/accessible-components/how-it-works/how-it-works-carousel.html +0 -12
- package/src/accessible-components/how-it-works/how-it-works-static.html +0 -12
- package/src/accessible-components/how-it-works/how-it-works.html +0 -14
- package/src/accessible-components/information/_information.scss +0 -96
- package/src/accessible-components/information/information.html +0 -32
- package/src/accessible-components/input/_input.scss +0 -204
- package/src/accessible-components/input/input.html +0 -22
- package/src/accessible-components/input/textarea.html +0 -9
- package/src/accessible-components/partners/_partners.scss +0 -234
- package/src/accessible-components/partners/partners.html +0 -56
- package/src/accessible-components/picture/picture.html +0 -19
- package/src/accessible-components/preloader/_preloader.scss +0 -61
- package/src/accessible-components/preloader/preloader.html +0 -23
- package/src/accessible-components/progress-bar/_progress-bar.scss +0 -140
- package/src/accessible-components/progress-bar/progress-bar.html +0 -21
- package/src/accessible-components/progress-bar/progress-bar.js +0 -37
- package/src/accessible-components/progress-bar/progress-bar.min.js +0 -2
- package/src/accessible-components/progress-bar/progress-bar.min.js.map +0 -1
- package/src/accessible-components/radio-button/_radio-button.scss +0 -586
- package/src/accessible-components/radio-button/radio-button.html +0 -33
- package/src/accessible-components/reviews/_reviews.scss +0 -175
- package/src/accessible-components/reviews/reviews-carousel.html +0 -12
- package/src/accessible-components/reviews/reviews-static.html +0 -12
- package/src/accessible-components/reviews/reviews.html +0 -37
- package/src/accessible-components/select/_select.scss +0 -69
- package/src/accessible-components/select/select.html +0 -10
- package/src/accessible-components/steps/_steps.scss +0 -636
- package/src/accessible-components/steps/defaultFormFieldConfig.json +0 -109
- package/src/accessible-components/steps/step-fields.html +0 -38
- package/src/accessible-components/steps/steps.html +0 -160
- package/src/accessible-components/tcpa/_tcpa.scss +0 -49
- package/src/accessible-components/tcpa/tcpa.html +0 -9
- package/src/accessible-components/tile/_tile.scss +0 -117
- package/src/accessible-components/tile/tile.html +0 -14
- package/src/accessible-components/value-props/_value-props.scss +0 -102
- package/src/accessible-components/value-props/value-props.html +0 -17
- package/src/accessible-components/zip-control/_zip-control.scss +0 -79
- package/src/accessible-components/zip-control/zip-control.html +0 -10
- package/src/resources/data/tcpa.json +0 -3
- package/src/resources/scripts/abandonment/abandonment-e099a424bf17408f1db2.min.js +0 -2
- package/src/resources/scripts/abandonment/abandonment.min.js +0 -2
- package/src/resources/scripts/footer/footer-component-7b5e263f64568573ecc0.min.js +0 -2
- package/src/resources/scripts/footer/footer-component.min.js +0 -2
- package/src/resources/scripts/helpers/initNumericOnlyFields.min.js +0 -2
- package/src/resources/scripts/helpers/initNumericOnlyFields.min.js.map +0 -1
- package/src/resources/scripts/helpers/isZipCodeValid.min.js +0 -2
- package/src/resources/scripts/helpers/isZipCodeValid.min.js.map +0 -1
- package/src/resources/scripts/mod-alytics/modalytics-0ac7d7a5a72ea67a0f47.min.js +0 -2
- package/src/resources/scripts/mod-alytics/modalytics.min.js +0 -2
- package/src/resources/scripts/mod-form/form/homeowner-f395431201f7a6e56690.min.js +0 -2
- package/src/resources/scripts/mod-form/form/homeowner.min.js +0 -2
- package/src/resources/scripts/mod-utils/modutils-a08fecfbb83afad1a9f8.min.js +0 -2
- package/src/resources/scripts/mod-utils/modutils.min.js +0 -2
- package/src/resources/styles/components/abandonment/abandonment-a8571a9e32ed6ef9acb4.min.css +0 -1
- package/src/resources/styles/components/abandonment/abandonment.min.css +0 -1
- package/src/resources/styles/components/footer/mod-footer-1fb2cec3278f29df57d0.min.css +0 -1
- package/src/resources/styles/components/footer/mod-footer.min.css +0 -1
- package/src/resources/styles/components/footer/qs-footer-9a3b0ab00428b03e6e9e.min.css +0 -1
- package/src/resources/styles/components/footer/qs-footer.min.css +0 -1
- package/src/resources/templates/modals/about/index.hbs +0 -9
- package/src/resources/templates/modals/about/index.html +0 -9
- package/src/resources/templates/modals/contact-us/index.hbs +0 -348
- package/src/resources/templates/modals/contact-us/index.html +0 -348
- package/src/resources/templates/modals/faq/index.hbs +0 -9
- package/src/resources/templates/modals/faq/index.html +0 -9
- package/src/resources/templates/modals/privacy/index.hbs +0 -236
- package/src/resources/templates/modals/privacy/index.html +0 -236
- package/src/resources/templates/modals/terms/index.hbs +0 -166
- package/src/resources/templates/modals/terms/index.html +0 -166
- package/src/shared-components/card-button/_card-button.scss +0 -49
- package/src/shared-components/card-button/card-button.html +0 -9
- package/src/shared-components/carousel/_carousel.scss +0 -106
- package/src/shared-components/carousel/carousel.html +0 -22
- package/src/shared-components/carousel/carousel.js +0 -3427
- package/src/shared-components/carousel/carousel.js.map +0 -1
- package/src/shared-components/carousel/carousel.min.js +0 -6
- package/src/shared-components/carousel/carousel.min.js.map +0 -1
- package/src/shared-components/carousel/carousel.min.min.js +0 -6
- package/src/shared-components/carousel/carousel.min.min.js.map +0 -1
- package/src/shared-components/checkbox/_checkbox.scss +0 -104
- package/src/shared-components/checkbox/checkbox.html +0 -6
- package/src/shared-components/expand-collapse/_expand-collapse.scss +0 -93
- package/src/shared-components/expand-collapse/expand-collapse.html +0 -8
- package/src/shared-components/expand-collapse/expand-collapse.js +0 -40
- package/src/shared-components/expand-collapse/expand-collapse.min.js +0 -2
- package/src/shared-components/expand-collapse/expand-collapse.min.js.map +0 -1
- package/src/shared-components/featured-block/_featured-block.scss +0 -185
- package/src/shared-components/featured-block/featured-block.html +0 -62
- package/src/shared-components/foot-assets/foot-assets.html +0 -107
- package/src/shared-components/form-tcpa/form-tcpa.html +0 -12
- package/src/shared-components/gtm-body/gtm-body.html +0 -4
- package/src/shared-components/head/head.html +0 -192
- package/src/shared-components/header/_header.scss +0 -200
- package/src/shared-components/header/header.html +0 -71
- package/src/shared-components/hero/_hero.scss +0 -253
- package/src/shared-components/hero/hero.html +0 -126
- package/src/shared-components/how-it-works/_how-it-works.scss +0 -138
- package/src/shared-components/how-it-works/how-it-works.html +0 -19
- package/src/shared-components/input/_input.scss +0 -229
- package/src/shared-components/input/input.html +0 -30
- package/src/shared-components/preloader/_preloader.scss +0 -61
- package/src/shared-components/preloader/preloader.html +0 -49
- package/src/shared-components/progress-bar/_progress-bar.scss +0 -105
- package/src/shared-components/progress-bar/progress-bar.html +0 -20
- package/src/shared-components/progress-bar/progress-bar.js +0 -25
- package/src/shared-components/progress-bar/progress-bar.min.js +0 -2
- package/src/shared-components/progress-bar/progress-bar.min.js.map +0 -1
- package/src/shared-components/radio-button/_radio-button.scss +0 -554
- package/src/shared-components/radio-button/radio-button.html +0 -25
- package/src/shared-components/reviews/_reviews.scss +0 -79
- package/src/shared-components/reviews/reviews.html +0 -27
- package/src/shared-components/select/_select.scss +0 -61
- package/src/shared-components/select/select.html +0 -8
- package/src/shared-components/steps/_steps.scss +0 -334
- package/src/shared-components/steps/defaultFormFieldConfig.json +0 -64
- package/src/shared-components/steps/step-fields.html +0 -36
- package/src/shared-components/steps/steps.html +0 -131
- package/src/shared-components/textarea/_textarea.scss +0 -96
- package/src/shared-components/textarea/textarea.html +0 -13
- package/src/shared-components/theme-toggle/_theme-toggle.scss +0 -68
- package/src/shared-components/theme-toggle/theme-toggle.html +0 -34
- package/src/shared-components/tile/_tile.scss +0 -117
- package/src/shared-components/tile/tile.html +0 -27
- package/src/shared-components/value-props/_value-props.scss +0 -98
- package/src/shared-components/value-props/value-props.html +0 -17
- package/src/shared-components/zip-control/_zip-control.scss +0 -42
- package/src/shared-components/zip-control/zip-control.html +0 -21
- package/src/temp/scripts/maxmind-geoip2.js +0 -104
|
@@ -1,348 +0,0 @@
|
|
|
1
|
-
<div class="contact-us">
|
|
2
|
-
<div class="contact-us__container">
|
|
3
|
-
<form class="contact-us__form">
|
|
4
|
-
<div class="step step--active" aria-hidden="false" tabindex="-1" aria-labelledby="contact-step-one-header">
|
|
5
|
-
<span id="contact-step-one-header" class="visually-hidden">Step 1: Select the radio button option that suits your inquiry.</span>
|
|
6
|
-
<div class="step__header">
|
|
7
|
-
<p class="step__header-number">
|
|
8
|
-
Step 1
|
|
9
|
-
</p>
|
|
10
|
-
<p class="step__header-text">
|
|
11
|
-
Select an option that suits your inquiry
|
|
12
|
-
</p>
|
|
13
|
-
</div>
|
|
14
|
-
<div class="step__content">
|
|
15
|
-
<div class="step__content-item">
|
|
16
|
-
<picture>
|
|
17
|
-
<source srcset="https://modernize.com/quote/resources/assets/images/illustrations/misc/handshake.webp" type="image/webp">
|
|
18
|
-
<img class="step__image" src="https://modernize.com/quote/resources/assets/images/illustrations/misc/handshake.jpg" alt="">
|
|
19
|
-
</picture>
|
|
20
|
-
<div class="step__fieldset">
|
|
21
|
-
<fieldset>
|
|
22
|
-
<legend>Partnerships</legend>
|
|
23
|
-
<div class="field">
|
|
24
|
-
<input type="radio" name="topic" value="SF_partnerships" id="SF_partnerships">
|
|
25
|
-
<label for="SF_partnerships">Publisher/Media Partnership</label>
|
|
26
|
-
</div>
|
|
27
|
-
<div class="field">
|
|
28
|
-
<input type="radio" name="topic" value="SF_advertisers" id="SF_advertisers">
|
|
29
|
-
<label for="SF_advertisers">Advertisers</label>
|
|
30
|
-
</div>
|
|
31
|
-
</fieldset>
|
|
32
|
-
</div>
|
|
33
|
-
</div>
|
|
34
|
-
<div class="step__content-item">
|
|
35
|
-
<picture>
|
|
36
|
-
<source srcset="https://modernize.com/quote/resources/assets/images/illustrations/misc/presentation.webp" type="image/webp">
|
|
37
|
-
<img class="step__image" src="https://modernize.com/quote/resources/assets/images/illustrations/misc/presentation.jpg" alt="">
|
|
38
|
-
</picture>
|
|
39
|
-
<div class="step__fieldset">
|
|
40
|
-
<fieldset>
|
|
41
|
-
<legend>Website Content, Data, Technical Issues</legend>
|
|
42
|
-
<div class="field">
|
|
43
|
-
<input type="radio" name="topic" value="reprint-permissions" id="reprint-permissions">
|
|
44
|
-
<label for="reprint-permissions">Reprint Permissions</label>
|
|
45
|
-
</div>
|
|
46
|
-
<div class="field">
|
|
47
|
-
<input type="radio" name="topic" value="technical-site-issue" id="technical-site-issue">
|
|
48
|
-
<label for="technical-site-issue">Technical Issues with Website</label>
|
|
49
|
-
</div>
|
|
50
|
-
</fieldset>
|
|
51
|
-
</div>
|
|
52
|
-
</div>
|
|
53
|
-
<div class="step__content-item">
|
|
54
|
-
<picture>
|
|
55
|
-
<source srcset="https://modernize.com/quote/resources/assets/images/illustrations/misc/man-on-couch.webp" type="image/webp">
|
|
56
|
-
<img class="step__image" src="https://modernize.com/quote/resources/assets/images/illustrations/misc/man-on-couch.jpg" alt="">
|
|
57
|
-
</picture>
|
|
58
|
-
<div class="step__fieldset">
|
|
59
|
-
<fieldset>
|
|
60
|
-
<legend>Unsubscribe Requests</legend>
|
|
61
|
-
<div class="field">
|
|
62
|
-
<input type="radio" name="topic" value="email-opt-out" id="email-opt-out">
|
|
63
|
-
<label for="email-opt-out">Consumer Email Unsubscribe</label>
|
|
64
|
-
</div>
|
|
65
|
-
<div class="field">
|
|
66
|
-
<input type="radio" name="topic" value="phone-opt-out" id="phone-opt-out">
|
|
67
|
-
<label for="phone-opt-out">Consumer Phone Calls/Text Message Unsubscribe</label>
|
|
68
|
-
</div>
|
|
69
|
-
<div class="field">
|
|
70
|
-
<input type="radio" name="topic" value="general-inquiry" id="general-inquiry">
|
|
71
|
-
<label for="general-inquiry">Other Consumer Issues</label>
|
|
72
|
-
</div>
|
|
73
|
-
</fieldset>
|
|
74
|
-
</div>
|
|
75
|
-
<ul class="step__list">
|
|
76
|
-
<li>
|
|
77
|
-
<a href="https://privacy-central.securiti.ai/#/dsr/edc7a01c-b34c-43d4-8da8-127895e8bd71" target="_parent">California - Request to Know</a>
|
|
78
|
-
<a href="tel:8448727854">(844) 872-7854</a>
|
|
79
|
-
</li>
|
|
80
|
-
<li>
|
|
81
|
-
<a href="https://privacy-central.securiti.ai/#/dsr/edc7a01c-b34c-43d4-8da8-127895e8bd71" target="_parent">California - Request to Delete</a>
|
|
82
|
-
</li>
|
|
83
|
-
</ul>
|
|
84
|
-
</div>
|
|
85
|
-
</div>
|
|
86
|
-
</div>
|
|
87
|
-
<div class="step" aria-hidden="true" tabindex="-1" aria-labelledby="contact-step-two-header">
|
|
88
|
-
<span id="contact-step-two-header" class="visually-hidden">Step 2: Submit your contact info and we'll address your request ASAP. Press tab to begin entering your information.</span>
|
|
89
|
-
<div class="step__header">
|
|
90
|
-
<p class="step__header-number">
|
|
91
|
-
Step 2
|
|
92
|
-
</p>
|
|
93
|
-
<p class="step__header-text">
|
|
94
|
-
Submit your contact info and we'll address your request ASAP
|
|
95
|
-
</p>
|
|
96
|
-
</div>
|
|
97
|
-
<div class="step__content">
|
|
98
|
-
<div class="step__error"></div>
|
|
99
|
-
<div class="form-group parent-error">
|
|
100
|
-
<label for="contact-name">Name</label>
|
|
101
|
-
<input class="form-control" type="text" name="name" id="contact-name">
|
|
102
|
-
<span class="step__error-message" id="error-contact-name">Please enter your name.</span>
|
|
103
|
-
</div>
|
|
104
|
-
<div class="form-group parent-error">
|
|
105
|
-
<label for="contact-phone">Phone</label>
|
|
106
|
-
<input class="form-control" type="tel" name="phone" id="contact-phone">
|
|
107
|
-
<span class="step__error-message" id="error-contact-phone">Please enter a valid phone number.</span>
|
|
108
|
-
</div>
|
|
109
|
-
<div class="form-group parent-error">
|
|
110
|
-
<label for="contact-email">Email</label>
|
|
111
|
-
<input class="form-control" type="email" name="email" id="contact-email">
|
|
112
|
-
<span class="step__error-message" id="error-contact-email">Please enter a valid email address.</span>
|
|
113
|
-
</div>
|
|
114
|
-
<div class="form-group parent-error">
|
|
115
|
-
<label for="contact-message">Message</label>
|
|
116
|
-
<textarea class="form-control" name="message" id="contact-message"></textarea>
|
|
117
|
-
<span class="step__error-message" id="error-contact-message">Please enter your message.</span>
|
|
118
|
-
</div>
|
|
119
|
-
<div>
|
|
120
|
-
<input type="hidden" name="domain" value="{{domain}}">
|
|
121
|
-
<input type="hidden" name="date">
|
|
122
|
-
<input type="hidden" name="time">
|
|
123
|
-
<input type="hidden" name="vertical" value="HomeServices">
|
|
124
|
-
<input type="hidden" name="g-recaptcha-response" value="">
|
|
125
|
-
</div>
|
|
126
|
-
</div>
|
|
127
|
-
<div class="captcha-container captcha-body">
|
|
128
|
-
<div class="g-recaptcha" data-callback="captcha_submit" data-sitekey="6LcsGEkUAAAAAHekw-AS_6Vcu_WeYk7LiPJB1mrR"></div>
|
|
129
|
-
</div>
|
|
130
|
-
<div class="form-controls">
|
|
131
|
-
<button class="btn btn-secondary btn-back" type="button" aria-label="Back"></button>
|
|
132
|
-
<button class="btn btn-submit" type="submit">
|
|
133
|
-
<span class="btn__text">Submit</span>
|
|
134
|
-
<span class="btn__spinner"></span>
|
|
135
|
-
</button>
|
|
136
|
-
</div>
|
|
137
|
-
</div>
|
|
138
|
-
</form>
|
|
139
|
-
<div class="contact-us__thankyou" aria-hidden="true" tabindex="-1" aria-labelledby="contact-success-header">
|
|
140
|
-
<span id="contact-success-header" class="visually-hidden"> Thank you. We'll address your request as soon as possible.</span>
|
|
141
|
-
<picture>
|
|
142
|
-
<source srcset="https://modernize.com/quote/resources/assets/images/illustrations/misc/laptop.webp" type="image/webp">
|
|
143
|
-
<img class="contact-us__thankyou-img" src="https://modernize.com/quote/resources/assets/images/illustrations/misc/laptop.jpg" alt="">
|
|
144
|
-
</picture>
|
|
145
|
-
<p class="contact-us__thankyou-title">Thank You!</p>
|
|
146
|
-
<p class="contact-us__thankyou-subtitle">We'll address your request as soon as possible.</p>
|
|
147
|
-
</div>
|
|
148
|
-
</div>
|
|
149
|
-
</div>
|
|
150
|
-
<script src="https://www.google.com/recaptcha/api.js"></script>
|
|
151
|
-
<script>
|
|
152
|
-
window.captcha_submit = function(response) {
|
|
153
|
-
document.querySelector('input[name="g-recaptcha-response"]').value = response;
|
|
154
|
-
}
|
|
155
|
-
</script>
|
|
156
|
-
|
|
157
|
-
<script>
|
|
158
|
-
var contactUs = {
|
|
159
|
-
$modal: document.getElementById('info-modal'),
|
|
160
|
-
$form: document.querySelector('.contact-us__form'),
|
|
161
|
-
$thankyou: document.querySelector('.contact-us__thankyou'),
|
|
162
|
-
url: 'https://contact.formfetch.com/v2_submit',
|
|
163
|
-
getFormData: function() {
|
|
164
|
-
const date = new Date();
|
|
165
|
-
const data = {};
|
|
166
|
-
const inputs = this.$form.elements;
|
|
167
|
-
if (inputs) {
|
|
168
|
-
for (let i = 0; i < inputs.length; i++) {
|
|
169
|
-
const input = inputs[i];
|
|
170
|
-
if (input.name) {
|
|
171
|
-
data[input.name] = input.value;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
data.time = date.toLocaleTimeString();
|
|
177
|
-
data.date = date.toLocaleDateString();
|
|
178
|
-
return data;
|
|
179
|
-
},
|
|
180
|
-
validateData: function(data) {
|
|
181
|
-
const _this = this;
|
|
182
|
-
var isFormValid = true;
|
|
183
|
-
const emailPattern = /^([\w\+-]+(?:\.[\w\+-]+)*)(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)/i;
|
|
184
|
-
|
|
185
|
-
Object.keys(data).forEach(function(key) {
|
|
186
|
-
var isValid = true;
|
|
187
|
-
const value = data[key];
|
|
188
|
-
switch (key) {
|
|
189
|
-
case 'email':
|
|
190
|
-
isValid = emailPattern.test(value);
|
|
191
|
-
break;
|
|
192
|
-
default:
|
|
193
|
-
isValid = value !== '';
|
|
194
|
-
break;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
if (!isValid) {
|
|
198
|
-
_this.markFieldAsInvalid(key);
|
|
199
|
-
_this.focusOnFirstError();
|
|
200
|
-
isFormValid = false;
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
return isFormValid;
|
|
205
|
-
},
|
|
206
|
-
focusOnFirstError: function() {
|
|
207
|
-
const $error = this.$form.querySelectorAll('.has-error');
|
|
208
|
-
|
|
209
|
-
if ($error.length > 0) {
|
|
210
|
-
const firstError = $error[0];
|
|
211
|
-
const $field = firstError.querySelector('input[type="text"], input[type="tel"], input[type="email"], textarea');
|
|
212
|
-
if ($field) {
|
|
213
|
-
$field.focus();
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
},
|
|
217
|
-
markFieldAsInvalid: function(fieldName) {
|
|
218
|
-
const $invalidField = this.$form.querySelector('#contact-' + fieldName);
|
|
219
|
-
if ($invalidField) {
|
|
220
|
-
$invalidField.parentElement.classList.add('has-error');
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
const $field = this.$form.querySelector('input[name="' + fieldName + '"]');
|
|
224
|
-
if ($field) {
|
|
225
|
-
$field.setAttribute('aria-invalid', 'true');
|
|
226
|
-
$field.setAttribute('aria-describedby', 'error-contact' + fieldName);
|
|
227
|
-
}
|
|
228
|
-
},
|
|
229
|
-
submit: function() {
|
|
230
|
-
this.$form.classList.add('form--loading');
|
|
231
|
-
|
|
232
|
-
const _this = this;
|
|
233
|
-
const data = this.getFormData();
|
|
234
|
-
const isFormValid = this.validateData(data);
|
|
235
|
-
const formData = Object.keys(data).map(function(key) {
|
|
236
|
-
return encodeURIComponent(key) + '=' + encodeURIComponent(data[key]).replace(/%20/g, '+');
|
|
237
|
-
}).join('&');
|
|
238
|
-
|
|
239
|
-
if (isFormValid) {
|
|
240
|
-
// Submit Form
|
|
241
|
-
var request = new XMLHttpRequest();
|
|
242
|
-
request.onreadystatechange = function() {
|
|
243
|
-
if (request.readyState === 4) {
|
|
244
|
-
if (request.status === 200) {
|
|
245
|
-
var response = JSON.parse(request.responseText);
|
|
246
|
-
if (response.success) {
|
|
247
|
-
_this.$form.style.display = 'none';
|
|
248
|
-
_this.$thankyou.style.display = 'block';
|
|
249
|
-
} else {
|
|
250
|
-
_this.$form.classList.remove('form--loading');
|
|
251
|
-
document.querySelector('.step__error').innerHTML = response.message;
|
|
252
|
-
}
|
|
253
|
-
} else {
|
|
254
|
-
console.error('Request failed with status:', request.status);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
request.open('POST', _this.url, true);
|
|
260
|
-
request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
|
|
261
|
-
request.send(formData);
|
|
262
|
-
} else {
|
|
263
|
-
_this.$form.classList.remove('form--loading');
|
|
264
|
-
}
|
|
265
|
-
},
|
|
266
|
-
changeStep: function(direction) {
|
|
267
|
-
const $activeStep = this.$form.querySelector('.step--active');
|
|
268
|
-
const $nextStep = $activeStep.nextElementSibling;
|
|
269
|
-
const $prevStep = $activeStep.previousElementSibling;
|
|
270
|
-
|
|
271
|
-
$activeStep.classList.remove('step--active');
|
|
272
|
-
$activeStep.setAttribute('aria-hidden', 'true');
|
|
273
|
-
if (direction === 'next') {
|
|
274
|
-
$nextStep.classList.add('step--active');
|
|
275
|
-
$nextStep.setAttribute('aria-hidden', 'false');
|
|
276
|
-
$nextStep.focus();
|
|
277
|
-
} else {
|
|
278
|
-
$prevStep.classList.add('step--active');
|
|
279
|
-
$prevStep.setAttribute('aria-hidden', 'false');
|
|
280
|
-
$prevStep.focus();
|
|
281
|
-
}
|
|
282
|
-
},
|
|
283
|
-
watch: function() {
|
|
284
|
-
const _this = this;
|
|
285
|
-
var radioChangedWithMouse = false;
|
|
286
|
-
|
|
287
|
-
// Watch form submission
|
|
288
|
-
_this.$form.addEventListener('submit', function(e) {
|
|
289
|
-
e.preventDefault();
|
|
290
|
-
if (!_this.$form.classList.contains('form--loading')) {
|
|
291
|
-
_this.submit();
|
|
292
|
-
}
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
// Watch radio click with mouse only
|
|
296
|
-
const $radioLabelsAndInputs = _this.$form.querySelectorAll('fieldset label, input[type="radio"]');
|
|
297
|
-
$radioLabelsAndInputs.forEach(function(input) {
|
|
298
|
-
input.addEventListener('mouseup', function() {
|
|
299
|
-
radioChangedWithMouse = true;
|
|
300
|
-
});
|
|
301
|
-
})
|
|
302
|
-
|
|
303
|
-
const $radioInputs = _this.$form.querySelectorAll('input[type="radio"]');
|
|
304
|
-
$radioInputs.forEach(function(input) {
|
|
305
|
-
input.addEventListener('click', function(e) {
|
|
306
|
-
if (radioChangedWithMouse) {
|
|
307
|
-
_this.changeStep('next');
|
|
308
|
-
radioChangedWithMouse = false;
|
|
309
|
-
}
|
|
310
|
-
});
|
|
311
|
-
input.addEventListener('keypress', function(e) {
|
|
312
|
-
if(e.which == 13){
|
|
313
|
-
e.preventDefault();
|
|
314
|
-
_this.changeStep('next');
|
|
315
|
-
|
|
316
|
-
// Making sure radio button is actually selected on Enter
|
|
317
|
-
var focused = e.target;
|
|
318
|
-
if (!focused.checked) {
|
|
319
|
-
focused.checked = true;
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
})
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
// Watch back button
|
|
326
|
-
const $backBtn = _this.$form.querySelector('.btn-back');
|
|
327
|
-
if ($backBtn) {
|
|
328
|
-
$backBtn.addEventListener('click', function() {
|
|
329
|
-
_this.changeStep('prev');
|
|
330
|
-
});
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
// Remove error state when input/textarea changes
|
|
334
|
-
const $formInputs = _this.$form.querySelectorAll('input, textarea');
|
|
335
|
-
$formInputs.forEach(function(input) {
|
|
336
|
-
input.addEventListener('change', function() {
|
|
337
|
-
input.parentElement.classList.remove('has-error');
|
|
338
|
-
input.setAttribute('aria-invalid', 'false');
|
|
339
|
-
input.removeAttribute('aria-describedby');
|
|
340
|
-
});
|
|
341
|
-
});
|
|
342
|
-
},
|
|
343
|
-
init: function() {
|
|
344
|
-
this.watch();
|
|
345
|
-
}
|
|
346
|
-
};
|
|
347
|
-
contactUs.init();
|
|
348
|
-
</script>
|