From aec07b943871f806be5b01ab351392a0a77c21be Mon Sep 17 00:00:00 2001 From: Michael Bumann Date: Thu, 30 Apr 2020 15:31:36 +0200 Subject: [PATCH] Cleanup --- app/javascript/contact_us_form.js | 20 +++++++++++--------- app/views/home/index.html.erb | 19 +++++++++++-------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/app/javascript/contact_us_form.js b/app/javascript/contact_us_form.js index 6dcd401..5ae9f14 100644 --- a/app/javascript/contact_us_form.js +++ b/app/javascript/contact_us_form.js @@ -1,12 +1,14 @@ document.addEventListener("turbolinks:load", function () { - var form = document.getElementById('contact-us-form'); - form.addEventListener('submit', function (e) { - document.getElementById("contact-us-form-submit-button").classList.add('is-hidden'); - document.getElementById("contact-us-form-loading-state").classList.remove('is-hidden'); - }); + var form = document.getElementById('contact-us-form'); + if (!form) { return; } - form.addEventListener('tinyforms:submitted', function(e) { - form.classList.add('is-hidden'); - document.getElementById("contact-us-form-success-message").classList.remove('is-hidden'); - }) + form.addEventListener('submit', function (e) { + document.getElementById("contact-us-form-submit-button").classList.add('is-hidden'); + document.getElementById("contact-us-form-loading-state").classList.remove('is-hidden'); + }); + + form.addEventListener('tinyforms:submitted', function(e) { + form.classList.add('is-hidden'); + document.getElementById("contact-us-form-success-message").classList.remove('is-hidden'); + }); }); \ No newline at end of file diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 6f4362a..df33706 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -188,7 +188,7 @@

We are building tinyforms to make your work easier! Let us know what we can do for you.

-
@@ -201,7 +201,7 @@
- +
@@ -211,13 +211,16 @@
-
\ No newline at end of file