|
1 | | -$(document).ready(function () { |
2 | | - $('.open-button').on('click', function (e) { |
3 | | - e.preventDefault(); |
4 | | - let container = $('#contact-form-container'); |
5 | | - |
6 | | - $.ajax({ |
7 | | - type: 'GET', |
8 | | - url: '/contact/form', |
9 | | - }).done(function (response) { |
10 | | - container.replaceWith(response); |
11 | | - document.getElementById("contact-form-yb-frontend").style.display = "block"; |
12 | | - }).fail(function (jqXHR) { |
13 | | - switch (jqXHR.status) { |
14 | | - default: |
15 | | - window.toastr.error('Something went wrong! Please try again!'); |
16 | | - break; |
17 | | - } |
18 | | - }); |
19 | | - }); |
20 | | - $('.cancel').on('click', function () { |
21 | | - document.getElementById("contact-form-yb-frontend").style.display = "none"; |
22 | | - }); |
23 | | - |
24 | | - $('#send-expert-contact-form').on('click', function (e) { |
25 | | - e.preventDefault(); |
26 | | - let form = $('#contact_form'); |
27 | | - |
28 | | - $.ajax({ |
29 | | - type: "POST", |
30 | | - url: '/contact/save-contact-message', |
31 | | - data: $(form).serialize() |
32 | | - }).done(function (response) { |
33 | | - if (response.message.type === 'success') { |
34 | | - $('input[name="email"]').val(''); |
35 | | - $('input[name="name"]').val(''); |
36 | | - $('textarea[name="message"]').val(''); |
37 | | - document.getElementById("contact-form-yb-frontend").style.display = "none"; |
38 | | - window.toastr.success(response.message.text); |
39 | | - } else { |
40 | | - window.toastr.error(response.message.text); |
41 | | - } |
42 | | - }).fail(function (jqXHR) { |
43 | | - switch (jqXHR.status) { |
44 | | - case 422: |
45 | | - let responseText = JSON.parse(jqXHR.responseText); |
46 | | - window.toastr.error(responseText); |
47 | | - break; |
48 | | - |
49 | | - case 401: |
50 | | - let data = JSON.parse(jqXHR.responseText); |
51 | | - redirectTo(data.redirect); |
52 | | - break; |
53 | | - |
54 | | - default: |
55 | | - window.toastr.error("Unexpected error. Please try again!"); |
56 | | - break; |
57 | | - } |
58 | | - }); |
59 | | - }); |
60 | | -}); |
61 | | - |
62 | | -function validateContactUsForm() |
63 | | -{ |
64 | | - event.preventDefault(); |
65 | | - $('.contactUsFormErrors').hide(); |
66 | | - var submit = true; |
67 | | - if (!$('.g-recaptcha')[0].dataset.sitekey) { |
68 | | - submit = false; |
69 | | - $('#contactUsErrors').show(); |
70 | | - $('#recaptchaSiteKeyEmpty').show(); |
71 | | - return false; |
72 | | - } |
73 | | - if ($('#contact_form #name').val() == '') { |
74 | | - submit = false; |
75 | | - $('#contactUsErrors').show(); |
76 | | - $('#contactUsEmptyName').show(); |
77 | | - } |
78 | | - if ($('#contact_form #email').val() == '') { |
79 | | - submit = false; |
80 | | - $('#contactUsErrors').show(); |
81 | | - $('#contactUsEmptyEmail').show(); |
82 | | - } |
83 | | - if ($('#contact_form #message').val() == '') { |
84 | | - submit = false; |
85 | | - $('#contactUsErrors').show(); |
86 | | - $('#contactUsEmptyText').show(); |
87 | | - } |
88 | | - |
89 | | - //grecaptcha.execute(); |
90 | | - |
91 | | - if (submit == true) { |
92 | | - grecaptcha.execute(); |
93 | | - } |
94 | | -} |
95 | | -window.validateContactUsForm = validateContactUsForm; |
96 | | - |
97 | | -function submitContactUsForm() |
98 | | -{ |
99 | | - $('#contact_form').submit(); |
100 | | -} |
101 | | -window.submitContactUsForm = submitContactUsForm; |
| 1 | +$(document).ready(function () { |
| 2 | + $('.open-button').on('click', function (e) { |
| 3 | + e.preventDefault(); |
| 4 | + let container = $('#contact-form-container'); |
| 5 | + |
| 6 | + $.ajax({ |
| 7 | + type: 'GET', |
| 8 | + url: '/contact/form', |
| 9 | + }).done(function (response) { |
| 10 | + container.replaceWith(response); |
| 11 | + document.getElementById("contact-form-yb-frontend").style.display = "block"; |
| 12 | + }).fail(function (jqXHR) { |
| 13 | + switch (jqXHR.status) { |
| 14 | + default: |
| 15 | + window.toastr.error('Something went wrong! Please try again!'); |
| 16 | + break; |
| 17 | + } |
| 18 | + }); |
| 19 | + }); |
| 20 | + $('.cancel').on('click', function () { |
| 21 | + document.getElementById("contact-form-yb-frontend").style.display = "none"; |
| 22 | + }); |
| 23 | + |
| 24 | + $('#send-expert-contact-form').on('click', function (e) { |
| 25 | + e.preventDefault(); |
| 26 | + let form = $('#contact_form'); |
| 27 | + |
| 28 | + $.ajax({ |
| 29 | + type: "POST", |
| 30 | + url: '/contact/save-contact-message', |
| 31 | + data: $(form).serialize() |
| 32 | + }).done(function (response) { |
| 33 | + if (response.message.type === 'success') { |
| 34 | + $('input[name="email"]').val(''); |
| 35 | + $('input[name="name"]').val(''); |
| 36 | + $('textarea[name="message"]').val(''); |
| 37 | + document.getElementById("contact-form-yb-frontend").style.display = "none"; |
| 38 | + window.toastr.success(response.message.text); |
| 39 | + } else { |
| 40 | + window.toastr.error(response.message.text); |
| 41 | + } |
| 42 | + }).fail(function (jqXHR) { |
| 43 | + switch (jqXHR.status) { |
| 44 | + case 422: |
| 45 | + let responseText = JSON.parse(jqXHR.responseText); |
| 46 | + window.toastr.error(responseText); |
| 47 | + break; |
| 48 | + |
| 49 | + case 401: |
| 50 | + let data = JSON.parse(jqXHR.responseText); |
| 51 | + redirectTo(data.redirect); |
| 52 | + break; |
| 53 | + |
| 54 | + default: |
| 55 | + window.toastr.error("Unexpected error. Please try again!"); |
| 56 | + break; |
| 57 | + } |
| 58 | + }); |
| 59 | + }); |
| 60 | +}); |
| 61 | + |
| 62 | +function validateContactUsForm() |
| 63 | +{ |
| 64 | + event.preventDefault(); |
| 65 | + $('.contactUsFormErrors').hide(); |
| 66 | + var submit = true; |
| 67 | + if (!$('.g-recaptcha')[0].dataset.sitekey) { |
| 68 | + submit = false; |
| 69 | + $('#contactUsErrors').show(); |
| 70 | + $('#recaptchaSiteKeyEmpty').show(); |
| 71 | + return false; |
| 72 | + } |
| 73 | + if ($('#contact_form #name').val() == '') { |
| 74 | + submit = false; |
| 75 | + $('#contactUsErrors').show(); |
| 76 | + $('#contactUsEmptyName').show(); |
| 77 | + } |
| 78 | + if ($('#contact_form #email').val() == '') { |
| 79 | + submit = false; |
| 80 | + $('#contactUsErrors').show(); |
| 81 | + $('#contactUsEmptyEmail').show(); |
| 82 | + } |
| 83 | + if ($('#contact_form #message').val() == '') { |
| 84 | + submit = false; |
| 85 | + $('#contactUsErrors').show(); |
| 86 | + $('#contactUsEmptyText').show(); |
| 87 | + } |
| 88 | + |
| 89 | + //grecaptcha.execute(); |
| 90 | + |
| 91 | + if (submit == true) { |
| 92 | + grecaptcha.execute(); |
| 93 | + } |
| 94 | +} |
| 95 | +window.validateContactUsForm = validateContactUsForm; |
| 96 | + |
| 97 | +function submitContactUsForm() |
| 98 | +{ |
| 99 | + $('#contact_form').submit(); |
| 100 | +} |
| 101 | +window.submitContactUsForm = submitContactUsForm; |
0 commit comments