diff options
author | Marc Alexander <admin@m-a-styles.de> | 2019-09-25 17:13:06 +0200 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2019-09-25 17:13:06 +0200 |
commit | dc0374eca3267c1e429e8ae138e8e11ba48e1617 (patch) | |
tree | c29e29ae72c1ba27e3d6ba5159de064ce6128cc2 /phpBB/assets | |
parent | Merge branch '3.3.x' (diff) | |
parent | Merge pull request #5135 from senky/ticket/15564 (diff) | |
download | phpbb-dc0374eca3267c1e429e8ae138e8e11ba48e1617.tar.gz phpbb-dc0374eca3267c1e429e8ae138e8e11ba48e1617.tar.bz2 phpbb-dc0374eca3267c1e429e8ae138e8e11ba48e1617.zip |
Merge branch '3.3.x'
Diffstat (limited to 'phpBB/assets')
-rw-r--r-- | phpBB/assets/javascript/core.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index db13b3653d..ab23a33c47 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -1646,6 +1646,50 @@ phpbb.lazyLoadAvatars = function loadAvatars() { }); }; +var recaptchaForm = $('.g-recaptcha').parents('form'); +var submitButton = null; +var programaticallySubmitted = false; + +phpbb.recaptchaOnLoad = function () { + // Listen to submit buttons in order to know which one was pressed + $('input[type="submit"]').each(function () { + $(this).on('click', function () { + submitButton = this; + }); + }); + + recaptchaForm.on('submit', function (e) { + if (!programaticallySubmitted) { + grecaptcha.execute(); + e.preventDefault(); + } + }); +} + +phpbb.recaptchaOnSubmit = function () { + programaticallySubmitted = true; + // If concrete button was clicked (e.g. preview instead of submit), + // let's trigger the same action + if (submitButton) { + submitButton.click(); + } else { + // Rename input[name="submit"] so that we can submit the form + if (typeof recaptchaForm.submit !== 'function') { + recaptchaForm.submit.name = 'submit_btn'; + } + recaptchaForm.submit(); + } +} + +// reCAPTCHA doesn't accept callback functions nested inside objects +// so we need to make this helper functions here +window.phpbbRecaptchaOnLoad = function() { + phpbb.recaptchaOnLoad(); +} +window.phpbbRecaptchaOnSubmit = function() { + phpbb.recaptchaOnSubmit(); +} + $(window).on('load', phpbb.lazyLoadAvatars); /** |