Skip to content
Snippets Groups Projects

Issue #2493183 by rang501, fearlsgroove, bceyssens, hass, alemadlei, nigelcunningham: Ajax support / Use behaviors

Closed Issue #2493183 by rang501, fearlsgroove, bceyssens, hass, alemadlei, nigelcunningham: Ajax support / Use behaviors
Closed Nigel Cunningham requested to merge issue/recaptcha-2493183:2493183-ajax-support- into 8.x-3.x
12 files
+ 525
29
Compare changes
  • Side-by-side
  • Inline
Files
12
js/recaptcha.js 0 → 100644
+ 34
0
 
/**
 
* @file
 
* Contains the definition of the behaviour recaptcha.
 
*/
 
 
(function ($, Drupal) {
 
Drupal.behaviors.recaptcha = {
 
attach: function (context) {
 
$('.g-recaptcha', context).each(function () {
 
if (typeof grecaptcha === 'undefined' || typeof grecaptcha.render !== 'function') {
 
return;
 
}
 
if ($(this).closest('body').length > 0) {
 
if ($(this).hasClass('recaptcha-processed')) {
 
grecaptcha.reset();
 
}
 
else {
 
grecaptcha.render(this, $(this).data());
 
$(this).addClass('recaptcha-processed');
 
}
 
}
 
});
 
}
 
};
 
 
window.drupalRecaptchaOnload = function () {
 
$('.g-recaptcha').each(function () {
 
if (!$(this).hasClass('recaptcha-processed')) {
 
grecaptcha.render(this, $(this).data());
 
$(this).addClass('recaptcha-processed');
 
}
 
});
 
};
 
})(jQuery, Drupal);
Loading