/** * 2007-2023 ETS-Soft * * NOTICE OF LICENSE * * This file is not open source! Each license that you purchased is only available for 1 website only. * If you want to use this file on more websites (or projects), you need to purchase additional licenses. * You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please contact us for extra customization service at an affordable price * * @author ETS-Soft * @copyright 2007-2023 ETS-Soft * @license Valid for 1 website (or project) for each purchase of license * International Registered Trademark & Property of ETS-Soft */ if (ets_ct7_recaptcha_enabled!='undefined') { if (!ets_ct7_recaptcha_v3) { var recaptchaWidgets = []; var recaptchaCallback = function () { var forms = document.getElementsByTagName('form'); var pattern = /(^|\s)g-recaptcha(\s|$)/; for (var i = 0; i < forms.length; i++) { var divs = forms[i].getElementsByTagName('div'); for (var j = 0; j < divs.length; j++) { var sitekey = divs[j].getAttribute('data-key'); if (divs[j].className && divs[j].className.match(pattern) && sitekey) { var params = { 'sitekey': sitekey, 'type': divs[j].getAttribute('data-type'), 'size': divs[j].getAttribute('data-size'), 'theme': divs[j].getAttribute('data-theme'), 'badge': divs[j].getAttribute('data-badge'), 'tabindex': divs[j].getAttribute('data-tabindex') }; var callback = divs[j].getAttribute('data-callback'); if (callback && 'function' == typeof window[callback]) { params['callback'] = window[callback]; } var expired_callback = divs[j].getAttribute('data-expired-callback'); if (expired_callback && 'function' == typeof window[expired_callback]) { params['expired-callback'] = window[expired_callback]; } var widget_id = grecaptcha.render(divs[j], params); recaptchaWidgets.push(widget_id); break; } } } }; $(document).on('wpcf7submit',function(){ for (var i = 0; i < recaptchaWidgets.length; i++) { grecaptcha.reset(recaptchaWidgets[i]); } }); } else { //v3. (function ($) { var ct7_re_captcha_v3 = function (form) { if ($('.wpcf7 form:not(.g-loaded)').length <= 0) return; var g_captcha = form.find('.g-recaptcha').eq(0); if (g_captcha.length > 0) { grecaptcha.ready(function () { grecaptcha.execute(ets_ct7_recaptcha_key, {action: 'contact'}).then(function (token) { g_captcha.html(''); if (g_captcha.find('.g-recaptcha-response').length > 0) { form.addClass('g-loaded'); ct7_re_captcha_v3(form); } }); }); } }; $(document).on('wpcf7submit',function(){ ct7_re_captcha_v3($('.wpcf7 form').removeClass('g-loaded')); }); $(document).ready(function () { if (ets_ct7_recaptcha_v3) { ct7_re_captcha_v3($('.wpcf7 form:not(.g-loaded)')); } }); })(jQuery); } }