// ! If input label click
$('.input-label:not(.mobile)').click(function () {
$(this).children('input').trigger('focus');
});
$(document).ready(function () {
reloadRecaptcha("contact");
// {# Profile Form Ajax #}
const $contactForm = $(".contact_form")
$contactForm.submit(function (event) {
event.preventDefault()
const $contactForm_data = $(this).serialize()
// {# Remove repeated icon and text #}
if ($('html').attr("lang") === "ar") {
h1Message = "استلمنا رسالتك";
displayMessage = "
شكر لتواصلك معنا سيتم الرد عليك في اقرب وقت.
"
} else {
h1Message = "We received your message!";
displayMessage = "Thank you for contacting us. We will get back to you as soon as possible.
"
}
$("#submit_contact_request").attr("disabled", true).append('').css("background", "#ffc67c");
$(".error").remove();
$('input').css("border", "");
$.ajax({
method: "POST",
url: "",
data: $contactForm_data,
dataType: 'json',
success: function (data) {
$('#submit_contact_request .fa-spin').remove();
$("#submit_contact_request").css(
"background", "").attr("disabled", false);
if (data.message == 'Success') {
setTimeout(function () {
// {# Fade out form and show success message #}
$(".contact_form").fadeOut(500,
function () {
$(".contact_form .input-label,#id_message, #submit_contact_request, .info")
.remove();
$(".contact_form h1").text(
h1Message
);
$('.contact_form')
.append(
displayMessage
);
$(".contact_form").fadeIn(500);
});
}, 1000)
} else {
let json;
$.each(data, function (key, item) {
json = $.parseJSON(item);
});
if (json.hasOwnProperty('first_name')) {
$('.contact_form .input-label:eq(0) .label-inside')
.after(
"* " + json
.first_name[0]
.message +
"");
$('.contact_form .input-label:eq(0) input').css(
"border", "1px solid red");
}
if (json.hasOwnProperty('last_name')) {
$('.contact_form .input-label:eq(1) .label-inside')
.after(
"* " + json
.last_name[
0]
.message +
"");
$('.contact_form .input-label:eq(1) input').css(
"border", "1px solid red");
}
if (json.hasOwnProperty('phone')) {
$('.contact_form .input-label:eq(2) .label-inside')
.after(
"* " + json
.phone[0]
.message +
"");
$('.contact_form .input-label:eq(2) input').css(
"border", "1px solid red");
}
if (json.hasOwnProperty('message')) {
$('.contact_form #id_message')
.before(
"* " + json
.message[0]
.message +
"");
}
if (json.hasOwnProperty('contact_recaptcha')) {
$('.contact_form #id_message')
.after(
"* " + json
.contact_recaptcha[0]
.message +
"");
}
reloadRecaptcha("contact");
}
}
})
})
})