Commit 4b7e7fd3 authored by Tino Goratsch's avatar Tino Goratsch

minor refactoring of the reCAPTCHA frontend components

parent 7a51af16
......@@ -78,10 +78,13 @@ class ReCaptchaCaptchaExtension implements CaptchaExtensionInterface
$path = ''
) {
if (!$this->user->isAuthenticated()) {
$settings = $this->settings->getSettings(Schema::MODULE_NAME);
$this->view->assign('captcha', [
'id' => $formFieldId,
'input_only' => $inputOnly,
'length' => $captchaLength
'length' => $captchaLength,
'sitekey' => $settings['recaptcha_sitekey']
]);
return $this->view->fetchTemplate(static::TEMPLATE);
......
/*
* Copyright (c) 2017 by the ACP3 Developers.
* See the LICENCE file at the top-level module directory for licencing details.
*/
var onloadCallback = function() {
jQuery('.recaptcha-placeholder').each(function() {
grecaptcha.render(this.id, {
'sitekey': this.dataset.sitekey,
'size': this.dataset.size
});
});
};
{extends file="asset:System/Partials/form_group.base.tpl"}
{$required=true}
{if $captcha.input_only}
{$cssSelector=''}
{/if}
{block FORM_GROUP_FORM_FIELD}
<div id="{$captcha.id}"
class="recaptcha-placeholder"
data-size="invisible">
</div>
<div class="recaptcha-placeholder"></div>
{/block}
<div id="{$captcha.id}"
class="recaptcha-placeholder"
data-size="invisible">
</div>
<div class="recaptcha-placeholder"></div>
{javascripts}
<script type="text/javascript">
var onloadCallback = function() {
jQuery('.recaptcha-placeholder').each(function() {
grecaptcha.render(this.id, {
'sitekey': '{$recaptcha.sitekey}',
'size': this.dataset.size
});
});
};
</script>
{include_js module="captcha" file="partials/recaptcha.onload"}
<script type="text/javascript"
src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&amp;render=explicit&amp;hl={$recaptcha.lang}"
async
......
......@@ -7,5 +7,6 @@
{block FORM_GROUP_FORM_FIELD}
<div id="{$captcha.id}"
class="recaptcha-placeholder"{if $captcha.length < 5} data-size="compact"{/if}></div>
class="recaptcha-placeholder"
data-sitekey="{$captcha.sitekey}"{if $captcha.length < 5} data-size="compact"{/if}></div>
{/block}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment