From 4bd4828ddb1cd22a6e2bc80c215bf8fe701067c4 Mon Sep 17 00:00:00 2001 From: Ben Croker Date: Wed, 17 Feb 2021 14:45:45 +0100 Subject: [PATCH] Added setTimeout with settings.minimumSubmitTime --- src/Snaptcha.php | 5 +---- src/templates/_error.html | 16 ++++++++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Snaptcha.php b/src/Snaptcha.php index 1221e3c..3ddeb88 100644 --- a/src/Snaptcha.php +++ b/src/Snaptcha.php @@ -101,10 +101,7 @@ public function validateField(ActionEvent $event) if ($this->validated === false) { $variables = [ - 'errorTitle' => $this->settings->errorTitle, - 'errorMessage' => $this->settings->errorMessage, - 'errorJavascriptDisabled' => $this->settings->errorJavascriptDisabled, - 'errorButtonText' => $this->settings->errorButtonText, + 'settings' => $this->settings, 'postedValues' => Craft::$app->request->getBodyParams(), ]; diff --git a/src/templates/_error.html b/src/templates/_error.html index aacef1f..e520f75 100644 --- a/src/templates/_error.html +++ b/src/templates/_error.html @@ -1,23 +1,26 @@ {% extends '_layouts/message' %} -{% set title = errorTitle %} +{% set title = settings.errorTitle %} {% js %} document.getElementById('warning').remove(); document.getElementById('error').classList.remove('hidden'); - document.getElementById('resubmit').classList.remove('disabled'); + setTimeout(function() { + document.getElementById('graphic').remove(); + document.getElementById('resubmit').classList.remove('disabled'); + }, {{ (settings.minimumSubmitTime * 1000) + random(1, 100) }}); {% endjs %} {% block message %} -

{{ errorTitle }}

+

{{ settings.errorTitle }}

- {{ errorJavascriptDisabled }} + {{ settings.errorJavascriptDisabled }}

@@ -28,8 +31,9 @@

{{ errorTitle }}

{{ craft.snaptcha.field }} +
{% endblock %}