Index: htdocs/modules/contrib/recaptcha/assets/js/recaptcha.invisible.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- htdocs/modules/contrib/recaptcha/assets/js/recaptcha.invisible.js (revision ) +++ htdocs/modules/contrib/recaptcha/assets/js/recaptcha.invisible.js (revision ) @@ -0,0 +1,34 @@ +var submittedFormId = ''; + +(function ($, Drupal) { + + Drupal.behaviors.RecaptchaInvisible = { + + request: {}, + + attach: function (context, settings) { + + + $('form').each(function() { + var thatForm = this; + if ($(this).find('.g-recaptcha[data-size="invisible"]').length === 1) { + $(this).find('input[type="submit"]').click(function(e){ + e.preventDefault(); + validateInvisibleCaptcha(thatForm); + }); + } + }); + + function validateInvisibleCaptcha(thatForm) { + submittedFormId = $(thatForm).attr('id'); + grecaptcha.execute(); + } + + }, + }; + +})(jQuery, Drupal); + +function onInvisibleSubmit() { + document.getElementById(submittedFormId).submit(); +} \ No newline at end of file Index: htdocs/modules/contrib/recaptcha/recaptcha.libraries.yml IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- htdocs/modules/contrib/recaptcha/recaptcha.libraries.yml (revision ) +++ htdocs/modules/contrib/recaptcha/recaptcha.libraries.yml (revision ) @@ -0,0 +1,3 @@ +invisible-recaptcha: + js: + assets/js/recaptcha.invisible.js: {} \ No newline at end of file Index: htdocs/modules/contrib/recaptcha/src/ReCaptcha/RequestMethod/Drupal8Post.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- htdocs/modules/contrib/recaptcha/src/ReCaptcha/RequestMethod/Drupal8Post.php (date 1488792760000) +++ htdocs/modules/contrib/recaptcha/src/ReCaptcha/RequestMethod/Drupal8Post.php (revision ) @@ -22,10 +22,10 @@ * Submit the POST request with the specified parameters. * * @param RequestParameters $params - * Request parameters. + * Request parameters * * @return string - * Body of the reCAPTCHA response. + * Body of the reCAPTCHA response */ public function submit(RequestParameters $params) { Index: htdocs/modules/contrib/recaptcha/src/Form/ReCaptchaAdminSettingsForm.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- htdocs/modules/contrib/recaptcha/src/Form/ReCaptchaAdminSettingsForm.php (date 1488792760000) +++ htdocs/modules/contrib/recaptcha/src/Form/ReCaptchaAdminSettingsForm.php (revision ) @@ -65,8 +65,8 @@ '#default_value' => $config->get('widget.theme'), '#description' => $this->t('Defines which theme to use for reCAPTCHA.'), '#options' => [ - 'light' => $this->t('Light (default)'), - 'dark' => $this->t('Dark'), + 'light' => t('Light (default)'), + 'dark' => t('Dark'), ], '#title' => $this->t('Theme'), '#type' => 'select', @@ -87,6 +87,7 @@ '#options' => [ '' => $this->t('Normal (default)'), 'compact' => $this->t('Compact'), + 'invisible' => $this->t('Invisible'), ], '#title' => $this->t('Size'), '#type' => 'select', Index: htdocs/modules/contrib/recaptcha/recaptcha.module IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- htdocs/modules/contrib/recaptcha/recaptcha.module (date 1488792760000) +++ htdocs/modules/contrib/recaptcha/recaptcha.module (revision ) @@ -78,6 +78,8 @@ $noscript = $renderer->render($recaptcha_widget_noscript); } + $invisible = $config->get('widget.size') == 'invisible'; + $attributes = [ 'class' => 'g-recaptcha', 'data-sitekey' => $recaptcha_site_key, @@ -86,6 +88,10 @@ 'data-size' => $config->get('widget.size'), 'data-tabindex' => $config->get('widget.tabindex'), ]; + + if($invisible) $attributes['data-callback'] = 'onInvisibleSubmit'; + if($invisible) $attributes['data-badge'] = 'inline'; + // Filter out empty tabindex/size. $attributes = array_filter($attributes); @@ -108,6 +114,10 @@ ], ], ]; + + if ($invisible) { + $captcha['form']['#attached']['library'][] = 'recaptcha/invisible-recaptcha'; + } } else { // Fallback to Math captcha as reCAPTCHA is not configured. Index: htdocs/modules/contrib/recaptcha/composer.json IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- htdocs/modules/contrib/recaptcha/composer.json (date 1488792760000) +++ htdocs/modules/contrib/recaptcha/composer.json (revision ) @@ -19,6 +19,6 @@ }, "license": "GPL-2.0+", "require": { - "drupal/captcha": "^1.0.0-alpha1" + "drupal/captcha": "~8.0" } }