diff --git a/docs/mix-manifest.json b/docs/mix-manifest.json new file mode 100644 index 0000000..f1c1089 --- /dev/null +++ b/docs/mix-manifest.json @@ -0,0 +1,4 @@ +{ + "/app.js": "/app.js", + "/app.44b3c0de19a926b0aa07.hot-update.js": "/app.44b3c0de19a926b0aa07.hot-update.js" +} diff --git a/src/js/app.js b/src/js/app.js index ce8ba8c..4a0efad 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -1,4 +1,5 @@ import axios from "axios"; +import {disableForm,resetForm} from "./formHelper/formHelper"; // Set config defaults when creating the instance const instance = axios.create({ @@ -33,7 +34,11 @@ const app = { 'Content-Type': 'application/json', } }).then(() => { - alert("Thank you, your form has been sent, your Slack invite will be emailed to you shortly!"); + disableForm(inviteForm); + setTimeout(()=>{ + alert("Thank you, your form has been sent, your Slack invite will be emailed to you shortly!"); + resetForm(inviteForm); + },1500); }); }) } diff --git a/src/js/formHelper/formHelper.js b/src/js/formHelper/formHelper.js new file mode 100644 index 0000000..c35a31b --- /dev/null +++ b/src/js/formHelper/formHelper.js @@ -0,0 +1,25 @@ +export function disableForm(form) { + const btn = form.querySelector("button"); + btn.disabled = true; + btn.style.opacity = "0.5"; + btn.textContent = "Submitting..."; + + const inputs = Array.from(form.querySelectorAll(".form__input")); + inputs.map(input => { + input.disabled = true; + }); +} + +export function resetForm(form) { + const btn = form.querySelector("button"); + btn.disabled = false; + btn.style.opacity = "1"; + btn.textContent = "Submit"; + + const inputs = Array.from(form.querySelectorAll(".form__input")); + inputs.map(input => { + input.disabled = false; + input.value = ""; + }); + +}