(function () {
// Lock on the actual button press, before any async reCAPTCHA/submit work
document.addEventListener('click', function (e) {
var btn = e.target.closest ? e.target.closest('.wpcf7-submit') : null;
if (!btn) { return; }
var form = btn.closest('form.wpcf7-form');
if (!form) { return; }
if (form.getAttribute('data-sag-lock') === '1') {
e.preventDefault();
e.stopImmediatePropagation();
return;
}
form.setAttribute('data-sag-lock', '1');
btn.setAttribute('data-sag-label', btn.value || btn.textContent);
btn.disabled = true;
if (btn.tagName === 'INPUT') { btn.value = 'Sending...'; } else { btn.textContent = 'Sending...'; }
}, true);
// Backstop: also block at the submit event
document.addEventListener('submit', function (e) {
var form = e.target;