[ticket/15564] Use es2015

PHPBB3-15564
This commit is contained in:
Jakub Senko 2018-02-20 08:40:24 +01:00 committed by Marc Alexander
parent 760a03fffc
commit 0f3559528a

View file

@ -1650,47 +1650,39 @@ phpbb.lazyLoadAvatars = function loadAvatars() {
}); });
}; };
// reCAPTCHA-related variables const recaptchaForm = $('.g-recaptcha').parents('form');
var recaptcha_form = $('.g-recaptcha').parents('form'), let submitButton = null;
submit_button = null, let programaticallySubmitted = false;
programatically_submitted = false;
/** phpbb.recaptchaOnLoad = function () {
* Function is called when reCAPTCHA code is loaded
*/
phpbb.recaptchaOnLoad = function() {
console.log('ahoj'); console.log('ahoj');
// listen to submit buttons in order to know which one was pressed // Listen to submit buttons in order to know which one was pressed
$('input[type="submit"]').each(function() { $('input[type="submit"]').each(() => {
$(this).on('click', function() { $(this).on('click', () => {
submit_button = this; submitButton = this;
}); });
}); });
recaptcha_form.on('submit', function(e) { recaptchaForm.on('submit', e => {
if (!programatically_submitted) { if (!programaticallySubmitted) {
grecaptcha.execute(); grecaptcha.execute();
e.preventDefault(); e.preventDefault();
} }
}); });
} }
/** phpbb.recaptchaOnSubmit = function () {
* Function is called after successful solving of reCAPTCHA programaticallySubmitted = true;
*/ // If concrete button was clicked (e.g. preview instead of submit),
phpbb.recaptchaOnSubmit = function() {
console.log('submit');
programatically_submitted = true;
// if concrete button was clicked (e.g. preview instead of submit),
// let's trigger the same action // let's trigger the same action
if (submit_button) { if (submitButton) {
submit_button.click(); submitButton.click();
} else { } else {
// rename input[name="submit"] so that we can submit the form // Rename input[name="submit"] so that we can submit the form
if (typeof recaptcha_form.submit !== 'function') { if (typeof recaptchaForm.submit !== 'function') {
recaptcha_form.submit.name = 'submit_btn'; recaptchaForm.submit.name = 'submit_btn';
} }
recaptcha_form.submit(); recaptchaForm.submit();
} }
} }