diff --git a/recaptcha.js b/recaptcha.js index 1e4041f3e..da9e2e882 100755 --- a/recaptcha.js +++ b/recaptcha.js @@ -1,17 +1,20 @@ -(function ($, window, document) { +(function ($, window, document, Drupal) { Drupal.behaviors.recaptcha = { + loaded: false, attach: function (context, settings) { // Check if the reCAPTCHA script is loaded yet. If not, don't worry: the // onload callback recaptchaOnLoad() will make sure that this function is // called again once grecaptcha is defined. - if (typeof grecaptcha == 'undefined') { + if (typeof(grecaptcha) === 'undefined' + || typeof(grecaptcha.render) === 'undefined' ) { return; } $('.g-recaptcha', context).once('drupal-recaptcha').each(function () { grecaptcha.render(this, $(this).data()); }); + Drupal.behaviors.recaptcha.loaded = true; } }; -})(jQuery, window, document); +})(jQuery, window, document, Drupal);