(function( $ ) { 'use strict'; /** * All of the code for your public-facing JavaScript source * should reside in this file. * * Note: It has been assumed you will write jQuery code here, so the * $ function reference has been prepared for usage within the scope * of this function. * * This enables you to define handlers, for when the DOM is ready: * * $(function() { * * }); * * When the window is loaded: * * $( window ).load(function() { * * }); * * ...and/or other possibilities. * * Ideally, it is not considered best practise to attach more than a * single DOM-ready or window-load handler for a particular page. * Although scripts in the WordPress core, Plugins and Themes may be * practising this, we should strive to set a better example in our own work. */ jQuery( document ).ready(function() { if (document.getElementsByClassName('captcha-field').length > 0) { // Function to handle reCAPTCHA and form submission function handleRecaptcha(form, e) { if (typeof grecaptcha === 'undefined' || typeof grecaptcha.execute !== 'function') { // If grecaptcha is not defined or not fully loaded, submit the form normally return true; } e.preventDefault(); grecaptcha.ready(function() { grecaptcha.execute(ccf_settings.captcha_key, {action: 'submit'}) .then(function(token) { let captchaField = form.querySelector('.captcha-field'); if (captchaField) { captchaField.value = token; form.submit(); } else { form.submit(); // Submit anyway if captcha field is not found } }) .catch(function(error) { console.error('reCAPTCHA execution failed:', error); form.submit(); // Submit the form even if reCAPTCHA fails }); }); return false; } // Get all forms on the page var forms = document.querySelectorAll('.vmg-contact-form'); forms.forEach(function(form) { form.addEventListener('submit', function(e) { return handleRecaptcha(form, e); }); }); } if( jQuery( '.wp-block-contact-form .datepicker').length > 0 ) { jQuery('.datepicker').datepicker({ dateFormat: 'mm/dd/yy', // Set the date format as needed changeMonth: true, // Allow the month to be changed directly changeYear: true // Allow the year to be changed directly }); jQuery('#tour_date').datepicker('setDate', 'today'); jQuery('#Date_Requested, #tour_date').datepicker("option", "minDate", 0); // Enable only future dates if( jQuery( '#gf_end_date').length > 0 ) { var minDate = new Date(); minDate.setDate(minDate.getDate() + 30); // Set the start of the range to 30 days from now var maxDate = new Date(minDate); maxDate.setFullYear(maxDate.getFullYear() + 1 ); // Set the end of the range to 12 months from the minDate jQuery('#gf_end_date').datepicker('option', 'minDate', minDate); jQuery('#gf_end_date').datepicker('option', 'maxDate', maxDate); jQuery('#gf_end_date').datepicker('setDate', minDate); jQuery('.datepicker').each(function() { var $this = jQuery(this); if($.datepicker._getInst($this[0])) { $this.keydown(function(e) { return false; // Prevent keydown events }); } }); } } // Load autofill data for the user profile or auto-fill the form. if ( typeof vsConfig !== 'undefined' && vsConfig.isLogin && ! vsConfig.isUpdated ) { $.ajax({ type: 'POST', url: vsConfig.ajaxUrl, data: { action: 'vs_get_customer_info', nonce: vsConfig.ajax_nonce, }, success: function (response) { if ( response.success && response.data.id ) { $('.wp-block-contact-form .general-freeze #gf_state').val(response.data.primaryAddress.state ? response.data.primaryAddress.state : ''); $('.wp-block-contact-form .general-freeze #gf_zip').val(response.data.primaryAddress.postalCode ? response.data.primaryAddress.postalCode : ''); } } }); } // Form condtional logic handle. function evaluateCondition(field, value, operator, actualValue) { const expectedValue = value; // Handle if actualValue is an array (checkbox group) if (Array.isArray(actualValue)) { switch (operator) { case 'is': return actualValue.includes(expectedValue); case 'isnot': return !actualValue.includes(expectedValue); // These may not make sense for checkboxes: case 'greaterthan': case 'lessthan': return false; // Or handle based on count if needed default: return false; } } else { // Normalize actualValue to string for safe comparison const actual = actualValue !== undefined ? actualValue.toString() : ''; switch (operator) { case 'is': return actual == expectedValue; case 'is_not': return actual != expectedValue; case 'greaterthan': return parseFloat(actual) > parseFloat(expectedValue); case 'lessthan': return parseFloat(actual) < parseFloat(expectedValue); default: return false; } } } function toggleConditionalFields() { $('[data-conditional-field]').each(function () { var $conditionalField = $(this); var targetFieldName = $conditionalField.data('conditional-field'); var expectedValue = $conditionalField.data('conditional-value'); var operator = $conditionalField.data('conditional-operator') || 'is'; let $targetInputs = $('[name="' + targetFieldName + '"], [name="' + targetFieldName + '[]"]'); let actualValue = ''; if ($targetInputs.length > 1) { let type = $targetInputs.first().attr('type'); if (type === 'checkbox' || type === 'radio') { if ( $targetInputs.filter(':checked').length ){ actualValue = $targetInputs.filter(':checked').map(function () { return this.value; }).get(); // Returns array } } } else { actualValue = $targetInputs.val(); } if ( undefined === actualValue || evaluateCondition(targetFieldName, expectedValue, operator, actualValue)) { $conditionalField.show(); } else { $conditionalField.hide(); } }); } // Initial check toggleConditionalFields(); // Trigger condition checks on change $('[name]').on('change', function () { toggleConditionalFields(); }); }); })( jQuery ); if (jQuery('select[multiple]').length > 0 && ccf_settings && ccf_settings.select2_css && ccf_settings.select2_js ) { // Load Select2 CSS var link = document.createElement('link'); link.rel = 'stylesheet'; link.type = 'text/css'; link.href = ccf_settings.select2_css; document.head.appendChild(link); // Load Select2 JS jQuery.getScript(ccf_settings.select2_js, function() { // Load select2Sortable JS after Select2 JS is loaded jQuery('select[multiple]').each(function() { var placeholder = jQuery(this).siblings('label').text(); // Get the text of the associated label placeholder = placeholder.replace('*', ''); // Remove the asterisk jQuery(this).select2({ placeholder: placeholder // Set the placeholder }).on("select2:select", function (evt) { var id = evt.params.data.id; var element = jQuery(this).children("option[value="+id+"]"); moveElementToEndOfParent(element); jQuery(this).trigger("change"); }); }); }); moveElementToEndOfParent = function(element) { var parent = element.parent(); element.detach(); parent.append(element); }; } ; /** * Form Setup. * * @package Custom_Contact_Form */ var $ = jQuery; var postID = $( '#post_ID' ).val(); var formObj = formObj; function HandleBrowseClick(fileinput) { var browse = $( '#' + fileinput ).parents( '.field-group' ).find( '.form-control' ).attr( 'id' ); var fileinputDom = document.getElementById( browse ); fileinputDom.click(); } function Handlechange(fileinput) { var textinput = $( '#' + fileinput ).parents( '.file-upload-wrap' ).find( '.filename' ).attr( 'id' ); var textinputDom = document.getElementById( textinput ); var fileinputDom = document.getElementById( fileinput ); console.log( textinputDom ); // Get only the filename. const filename = fileinputDom.value.split( '\\' ).pop(); textinputDom.value = filename; } ; /*! This file is auto-generated */ (()=>{"use strict";var t={d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{actions:()=>P,addAction:()=>A,addFilter:()=>m,applyFilters:()=>w,applyFiltersAsync:()=>I,createHooks:()=>h,currentAction:()=>x,currentFilter:()=>T,defaultHooks:()=>f,didAction:()=>j,didFilter:()=>z,doAction:()=>g,doActionAsync:()=>k,doingAction:()=>O,doingFilter:()=>S,filters:()=>Z,hasAction:()=>_,hasFilter:()=>v,removeAction:()=>p,removeAllActions:()=>F,removeAllFilters:()=>b,removeFilter:()=>y});const n=function(t){return"string"!=typeof t||""===t?(console.error("The namespace must be a non-empty string."),!1):!!/^[a-zA-Z][a-zA-Z0-9_.\-\/]*$/.test(t)||(console.error("The namespace can only contain numbers, letters, dashes, periods, underscores and slashes."),!1)};const r=function(t){return"string"!=typeof t||""===t?(console.error("The hook name must be a non-empty string."),!1):/^__/.test(t)?(console.error("The hook name cannot begin with `__`."),!1):!!/^[a-zA-Z][a-zA-Z0-9_.-]*$/.test(t)||(console.error("The hook name can only contain numbers, letters, dashes, periods and underscores."),!1)};const o=function(t,e){return function(o,i,s,c=10){const l=t[e];if(!r(o))return;if(!n(i))return;if("function"!=typeof s)return void console.error("The hook callback must be a function.");if("number"!=typeof c)return void console.error("If specified, the hook priority must be a number.");const a={callback:s,priority:c,namespace:i};if(l[o]){const t=l[o].handlers;let e;for(e=t.length;e>0&&!(c>=t[e-1].priority);e--);e===t.length?t[e]=a:t.splice(e,0,a),l.__current.forEach((t=>{t.name===o&&t.currentIndex>=e&&t.currentIndex++}))}else l[o]={handlers:[a],runs:0};"hookAdded"!==o&&t.doAction("hookAdded",o,i,s,c)}};const i=function(t,e,o=!1){return function(i,s){const c=t[e];if(!r(i))return;if(!o&&!n(s))return;if(!c[i])return 0;let l=0;if(o)l=c[i].handlers.length,c[i]={runs:c[i].runs,handlers:[]};else{const t=c[i].handlers;for(let e=t.length-1;e>=0;e--)t[e].namespace===s&&(t.splice(e,1),l++,c.__current.forEach((t=>{t.name===i&&t.currentIndex>=e&&t.currentIndex--})))}return"hookRemoved"!==i&&t.doAction("hookRemoved",i,s),l}};const s=function(t,e){return function(n,r){const o=t[e];return void 0!==r?n in o&&o[n].handlers.some((t=>t.namespace===r)):n in o}};const c=function(t,e,n,r){return function(o,...i){const s=t[e];s[o]||(s[o]={handlers:[],runs:0}),s[o].runs++;const c=s[o].handlers;if(!c||!c.length)return n?i[0]:void 0;const l={name:o,currentIndex:0};return(r?async function(){try{s.__current.add(l);let t=n?i[0]:void 0;for(;l.currentIndex0:Array.from(r.__current).some((t=>t.name===n))}};const u=function(t,e){return function(n){const o=t[e];if(r(n))return o[n]&&o[n].runs?o[n].runs:0}};class d{constructor(){this.actions=Object.create(null),this.actions.__current=new Set,this.filters=Object.create(null),this.filters.__current=new Set,this.addAction=o(this,"actions"),this.addFilter=o(this,"filters"),this.removeAction=i(this,"actions"),this.removeFilter=i(this,"filters"),this.hasAction=s(this,"actions"),this.hasFilter=s(this,"filters"),this.removeAllActions=i(this,"actions",!0),this.removeAllFilters=i(this,"filters",!0),this.doAction=c(this,"actions",!1,!1),this.doActionAsync=c(this,"actions",!1,!0),this.applyFilters=c(this,"filters",!0,!1),this.applyFiltersAsync=c(this,"filters",!0,!0),this.currentAction=l(this,"actions"),this.currentFilter=l(this,"filters"),this.doingAction=a(this,"actions"),this.doingFilter=a(this,"filters"),this.didAction=u(this,"actions"),this.didFilter=u(this,"filters")}}const h=function(){return new d},f=h(),{addAction:A,addFilter:m,removeAction:p,removeFilter:y,hasAction:_,hasFilter:v,removeAllActions:F,removeAllFilters:b,doAction:g,doActionAsync:k,applyFilters:w,applyFiltersAsync:I,currentAction:x,currentFilter:T,doingAction:O,doingFilter:S,didAction:j,didFilter:z,actions:P,filters:Z}=f;(window.wp=window.wp||{}).hooks=e})();;