Files
kupshop/web/common/templates/block.recaptcha.invisible.tpl
2025-08-02 16:30:27 +02:00

47 lines
1.7 KiB
Smarty

{function captchaScript}
{ifmodule RECAPTCHA__GCLOUD}
{$script_url = "https://www.google.com/recaptcha/enterprise.js"}
{elsemodule}
{$script_url = "https://www.google.com/recaptcha/api.js"}
{/ifmodule}
<script src="{$script_url}" async defer></script>
<script>
function onComplete() {
$(".g-recaptcha").closest("form").submit();
}
</script>
{/function}
{function captchaBtn type='invisible' event='success.form.bv'}
<input type="hidden" name="recaptcha" value="{$type}">
{ifmodule RECAPTCHA__GCLOUD}
{$sitekey = {findModule('recaptcha','gcloud_site_'|cat:$type)}}
{$library = 'grecaptcha.enterprise'}
{elsemodule}
{$sitekey = {findModule('recaptcha','site_'|cat:$type)}}
{$library = 'grecaptcha'}
{/ifmodule}
<div class="g-recaptcha" data-sitekey="{$sitekey}" data-size="invisible" data-callback="onComplete"></div>
{if $force_btn}
<button class="{$class|default:'btn btn-primary'}" type="submit" name="Submit" value="{$text|default:"{t}Odeslat{/t}"}"
{if $style}style="{$style}"{/if}>{$text|default:"{t}Odeslat{/t}"}</button>
{else}
<input class="{$class|default:'btn btn-primary'}" type="submit" name="Submit" value="{$text|default:"{t}Odeslat{/t}"}"
{if $style}style="{$style}"{/if}>
{/if}
<script>
wpj.onReady.push(function () {
$(".g-recaptcha").closest("form").on('{$event}', function (event) {
if (!{$library}.getResponse()) {
event.preventDefault();
{$library}.execute();
}
});
});
</script>
{/function}
{function sharedCaptchaBtn event='submit'}
{captchaBtn type='shared' event=$event}
{/function}