|
Server : LiteSpeed System : Linux terra.hostitbro.com 5.14.0-611.54.3.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:31:24 EDT 2026 x86_64 User : outerorb ( 1091) PHP Version : 8.1.34 Disable Function : mail Directory : /home2/outerorb/public_html/assets/js/plugins/ | |
|
Path: /home2/outerorb/public_html/assets/js/plugins/contact.form.js
Size: 2.24 KB
Permissions: 0666
/**
* Outer Orbit Technologies β Unified Form Handler
* Handles: #contact-form, #quick-quote-form, other .oot-ajax-form elements
*/
(function ($) {
'use strict';
// Helper: show styled message inside a target div
function showMsg($div, text, isSuccess) {
$div
.css({
display: 'block',
padding: '10px 14px',
borderRadius: '6px',
fontSize: '14px',
fontWeight: '500',
marginTop: '10px',
background: isSuccess ? '#e6f9f0' : '#fdecea',
color: isSuccess ? '#1a7c45' : '#b00020',
border: '1px solid ' + (isSuccess ? '#a3e4c1' : '#f5c6cb')
})
.text((isSuccess ? 'β ' : 'β ') + text);
}
// Helper: generic AJAX form submit
function bindForm(formSel, msgSel, btnSel, fieldsToReset) {
var $form = $(formSel);
if (!$form.length) return;
var $msg = $(msgSel);
var $btn = $(btnSel);
var origText = $btn.text();
$form.on('submit', function (e) {
e.preventDefault();
$msg.hide();
$btn.text('Sendingβ¦').prop('disabled', true);
$.ajax({
type: 'POST',
url: $form.attr('action'),
data: $form.serialize()
})
.done(function (response) {
showMsg($msg, response, true);
$form.find(fieldsToReset).val('');
$btn.text(origText).prop('disabled', false);
})
.fail(function (xhr) {
var errText = xhr.responseText || 'An error occurred. Please try again or call us directly.';
showMsg($msg, errText, false);
$btn.text(origText).prop('disabled', false);
});
});
}
// Main contact form
bindForm('#contact-form', '#form-messages', '#contact-form button[type="submit"]', '#name, #email, #phone, #message');
// Sidebar quick-quote form
bindForm('#quick-quote-form', '#qq-form-messages', '#qq-submit-btn', '#qq-name, #qq-email, #qq-phone, #qq-message');
})(jQuery);