diff options
author | Szasza Palmer <szasza@szasza.info> | 2020-11-13 09:26:32 +0300 |
---|---|---|
committer | Szasza Palmer <szasza@szasza.info> | 2020-11-13 09:26:32 +0300 |
commit | 84c04e241d6429e2abffb911db4f9894b0b89aac (patch) | |
tree | 84e726bb613dc6c7f5c520d60f3de128f7879f47 | |
parent | eb206a014b7f52a96a78e0914be7d8b74d4f7389 (diff) |
removing customised Formspree POST URL handling from the contact form
17 files changed, 29 insertions, 35 deletions
diff --git a/assets/js/contact.js b/assets/js/contact.js index 49b94829..7c9c9a87 100644 --- a/assets/js/contact.js +++ b/assets/js/contact.js @@ -18,7 +18,7 @@ const validatorConfig = { ); }, onSuccess: function(e, form) { - if (form.dataset.hasNetlify || form.dataset.hasFormspree) { + if (form.dataset.hasNetlify) { return; } diff --git a/assets/scripts/syna-contact.js b/assets/scripts/syna-contact.js index 911280d9..d43bd3b4 100644 --- a/assets/scripts/syna-contact.js +++ b/assets/scripts/syna-contact.js @@ -94,7 +94,7 @@ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _helpers_jq_helpers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./helpers/jq-helpers */ \"./assets/js/helpers/jq-helpers.js\");\n/* harmony import */ var form_validator_simple__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! form-validator-simple */ \"./node_modules/form-validator-simple/dist/bundle.js\");\n/* harmony import */ var form_validator_simple__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(form_validator_simple__WEBPACK_IMPORTED_MODULE_1__);\n\n\n\n(function () {\n if (Object(_helpers_jq_helpers__WEBPACK_IMPORTED_MODULE_0__[\"default\"])('.g-recaptcha')) {\n checkReCaptcha();\n }\n})();\n\nvar validatorConfig = {\n errorTemplate: '<span class=\"help-block form-error\">%s</span>',\n onFormValidate: function onFormValidate(isFormValid, form) {\n form.querySelector('button.submit-btn').disabled = !isFormValid;\n },\n onError: function onError(e, form) {\n Object(_helpers_jq_helpers__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"form[id=\".concat(form.getAttribute('id'), \"] .generic-error\")).removeClass('d-none');\n },\n onSuccess: function onSuccess(e, form) {\n if (form.dataset.hasNetlify || form.dataset.hasFormspree) {\n return;\n }\n\n e.preventDefault();\n var id = form.getAttribute('id');\n var $form = Object(_helpers_jq_helpers__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"form[id=\".concat(id, \"]\"));\n var action = $form.attr('action');\n var genericSuccess = $form.$('.generic-success');\n var genericError = $form.$('.generic-error');\n genericSuccess.addClass('hidden');\n genericError.addClass('d-none');\n $form.removeClass('error').removeClass('success');\n var serializedForm = Object(_helpers_jq_helpers__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"#\".concat(id)).serialize();\n\n if (typeof grecaptcha !== 'undefined' && grecaptcha.getResponse() === '') {\n grecaptcha.execute();\n return false;\n }\n\n $form.$('button.submit-btn').attr('disabled', true).addClass('disabled');\n _helpers_jq_helpers__WEBPACK_IMPORTED_MODULE_0__[\"default\"].post(action, serializedForm, {\n contentType: 'application/x-www-form-urlencoded'\n }).then(function () {\n genericSuccess.removeClass('hidden');\n $form.addClass('success');\n $form.$('button.submit-btn').removeAttr('disabled').removeClass('disabled');\n })[\"catch\"](function () {\n genericError.removeClass('d-none');\n $form.addClass('error');\n $form.$('button.submit-btn').removeAttr('disabled').removeClass('disabled');\n });\n return false;\n }\n};\ndocument.querySelectorAll('form.contact').forEach(function (form) {\n new form_validator_simple__WEBPACK_IMPORTED_MODULE_1___default.a(Object.assign(validatorConfig, {\n form: form\n }));\n Object(_helpers_jq_helpers__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(form).$('#generic-success [data-action=\"return-form\"]').on('click', function () {\n Object(_helpers_jq_helpers__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(form).$('#generic-success').addClass('hidden');\n Object(_helpers_jq_helpers__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(form).removeClass('success');\n });\n});\n\nfunction checkReCaptcha() {\n if (document.querySelector('.g-recaptcha-container') && typeof grecaptcha === 'undefined') {\n Object(_helpers_jq_helpers__WEBPACK_IMPORTED_MODULE_0__[\"default\"])('.captcha-error').removeClass('d-none');\n setTimeout(checkReCaptcha, 200);\n } else if (document.querySelector('.g-recaptcha-container div div')) {\n Object(_helpers_jq_helpers__WEBPACK_IMPORTED_MODULE_0__[\"default\"])('.captcha-error').addClass('d-none');\n Object(_helpers_jq_helpers__WEBPACK_IMPORTED_MODULE_0__[\"default\"])('.g-recaptcha-filler').addClass('d-none');\n Object(_helpers_jq_helpers__WEBPACK_IMPORTED_MODULE_0__[\"default\"])('.g-recaptcha').attr('disabled', true);\n }\n}\n\nwindow.onContactCaptcha = function ($form) {\n var customEvent = document.createEvent('Event');\n customEvent.initEvent('submit', true, true);\n document.querySelector('form.contact').dispatchEvent(customEvent);\n};\n\nwindow.syna.stream.subscribe('contact:update', function (_ref) {\n var name = _ref.name,\n email = _ref.email,\n phone = _ref.phone,\n message = _ref.message;\n var form = Object(_helpers_jq_helpers__WEBPACK_IMPORTED_MODULE_0__[\"default\"])('form.contact');\n form.$('input[name=name]').attr('value', name || null)[0].focus(); // TODO: REVISIT: Remove the following line whenever firefox fixes center on focus\n\n form[0].scrollIntoView({\n behavior: 'instant',\n block: 'center'\n });\n form.$('input[name=email]').attr('value', email || null);\n form.$('input[name=phone]').attr('value', phone || null);\n form.$('textarea[name=message]').$nodes.forEach(function (node) {\n node.innerHTML = '';\n node.appendChild(document.createTextNode(message || ''));\n });\n});\n\n//# sourceURL=webpack:///./assets/js/contact.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _helpers_jq_helpers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./helpers/jq-helpers */ \"./assets/js/helpers/jq-helpers.js\");\n/* harmony import */ var form_validator_simple__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! form-validator-simple */ \"./node_modules/form-validator-simple/dist/bundle.js\");\n/* harmony import */ var form_validator_simple__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(form_validator_simple__WEBPACK_IMPORTED_MODULE_1__);\n\n\n\n(function () {\n if (Object(_helpers_jq_helpers__WEBPACK_IMPORTED_MODULE_0__[\"default\"])('.g-recaptcha')) {\n checkReCaptcha();\n }\n})();\n\nvar validatorConfig = {\n errorTemplate: '<span class=\"help-block form-error\">%s</span>',\n onFormValidate: function onFormValidate(isFormValid, form) {\n form.querySelector('button.submit-btn').disabled = !isFormValid;\n },\n onError: function onError(e, form) {\n Object(_helpers_jq_helpers__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"form[id=\".concat(form.getAttribute('id'), \"] .generic-error\")).removeClass('d-none');\n },\n onSuccess: function onSuccess(e, form) {\n if (form.dataset.hasNetlify) {\n return;\n }\n\n e.preventDefault();\n var id = form.getAttribute('id');\n var $form = Object(_helpers_jq_helpers__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"form[id=\".concat(id, \"]\"));\n var action = $form.attr('action');\n var genericSuccess = $form.$('.generic-success');\n var genericError = $form.$('.generic-error');\n genericSuccess.addClass('hidden');\n genericError.addClass('d-none');\n $form.removeClass('error').removeClass('success');\n var serializedForm = Object(_helpers_jq_helpers__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"#\".concat(id)).serialize();\n\n if (typeof grecaptcha !== 'undefined' && grecaptcha.getResponse() === '') {\n grecaptcha.execute();\n return false;\n }\n\n $form.$('button.submit-btn').attr('disabled', true).addClass('disabled');\n _helpers_jq_helpers__WEBPACK_IMPORTED_MODULE_0__[\"default\"].post(action, serializedForm, {\n contentType: 'application/x-www-form-urlencoded'\n }).then(function () {\n genericSuccess.removeClass('hidden');\n $form.addClass('success');\n $form.$('button.submit-btn').removeAttr('disabled').removeClass('disabled');\n })[\"catch\"](function () {\n genericError.removeClass('d-none');\n $form.addClass('error');\n $form.$('button.submit-btn').removeAttr('disabled').removeClass('disabled');\n });\n return false;\n }\n};\ndocument.querySelectorAll('form.contact').forEach(function (form) {\n new form_validator_simple__WEBPACK_IMPORTED_MODULE_1___default.a(Object.assign(validatorConfig, {\n form: form\n }));\n Object(_helpers_jq_helpers__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(form).$('#generic-success [data-action=\"return-form\"]').on('click', function () {\n Object(_helpers_jq_helpers__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(form).$('#generic-success').addClass('hidden');\n Object(_helpers_jq_helpers__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(form).removeClass('success');\n });\n});\n\nfunction checkReCaptcha() {\n if (document.querySelector('.g-recaptcha-container') && typeof grecaptcha === 'undefined') {\n Object(_helpers_jq_helpers__WEBPACK_IMPORTED_MODULE_0__[\"default\"])('.captcha-error').removeClass('d-none');\n setTimeout(checkReCaptcha, 200);\n } else if (document.querySelector('.g-recaptcha-container div div')) {\n Object(_helpers_jq_helpers__WEBPACK_IMPORTED_MODULE_0__[\"default\"])('.captcha-error').addClass('d-none');\n Object(_helpers_jq_helpers__WEBPACK_IMPORTED_MODULE_0__[\"default\"])('.g-recaptcha-filler').addClass('d-none');\n Object(_helpers_jq_helpers__WEBPACK_IMPORTED_MODULE_0__[\"default\"])('.g-recaptcha').attr('disabled', true);\n }\n}\n\nwindow.onContactCaptcha = function ($form) {\n var customEvent = document.createEvent('Event');\n customEvent.initEvent('submit', true, true);\n document.querySelector('form.contact').dispatchEvent(customEvent);\n};\n\nwindow.syna.stream.subscribe('contact:update', function (_ref) {\n var name = _ref.name,\n email = _ref.email,\n phone = _ref.phone,\n message = _ref.message;\n var form = Object(_helpers_jq_helpers__WEBPACK_IMPORTED_MODULE_0__[\"default\"])('form.contact');\n form.$('input[name=name]').attr('value', name || null)[0].focus(); // TODO: REVISIT: Remove the following line whenever firefox fixes center on focus\n\n form[0].scrollIntoView({\n behavior: 'instant',\n block: 'center'\n });\n form.$('input[name=email]').attr('value', email || null);\n form.$('input[name=phone]').attr('value', phone || null);\n form.$('textarea[name=message]').$nodes.forEach(function (node) {\n node.innerHTML = '';\n node.appendChild(document.createTextNode(message || ''));\n });\n});\n\n//# sourceURL=webpack:///./assets/js/contact.js?"); /***/ }), diff --git a/exampleSite/content/dev/blog/_global/contact.md b/exampleSite/content/dev/blog/_global/contact.md index 90f52efb..c3c4d41a 100644 --- a/exampleSite/content/dev/blog/_global/contact.md +++ b/exampleSite/content/dev/blog/_global/contact.md @@ -9,8 +9,8 @@ form_name = "defaultContact" title = "Comment using the Contact fragment" subtitle = "*not working on demo page*" -# PostURL can be used with backends such as mailout from caddy -post_url = "https://example.com/mailout" #default: formspree.io +# PostURL can be used with backends such as formspree, or mailout from caddy +post_url = "https://example.com/mailout" email = "mail@example.com" button_text = "Send Button" # defaults to theme default #netlify = false diff --git a/exampleSite/content/dev/colors/dev-contact/contact-dark.md b/exampleSite/content/dev/colors/dev-contact/contact-dark.md index 979ba06c..3587830e 100644 --- a/exampleSite/content/dev/colors/dev-contact/contact-dark.md +++ b/exampleSite/content/dev/colors/dev-contact/contact-dark.md @@ -10,8 +10,8 @@ title = "Contact fragment" subtitle = "*not working on demo page*" #title_align = "left" # Default is center, can be left, right or center -# PostURL can be used with backends such as mailout from caddy -post_url = "https://example.com/mailout" #default: formspree.io +# PostURL can be used with backends such as formspree, or mailout from caddy +post_url = "https://example.com/mailout" email = "mail@example.com" button_text = "Send Button" # defaults to theme default #netlify = false diff --git a/exampleSite/content/dev/colors/dev-contact/contact-light.md b/exampleSite/content/dev/colors/dev-contact/contact-light.md index e75f789a..48052d31 100644 --- a/exampleSite/content/dev/colors/dev-contact/contact-light.md +++ b/exampleSite/content/dev/colors/dev-contact/contact-light.md @@ -10,8 +10,8 @@ title = "Contact fragment" subtitle = "*not working on demo page*" #title_align = "left" # Default is center, can be left, right or center -# PostURL can be used with backends such as mailout from caddy -post_url = "https://example.com/mailout" #default: formspree.io +# PostURL can be used with backends such as formspree, or mailout from caddy +post_url = "https://example.com/mailout" email = "mail@example.com" button_text = "Send Button" # defaults to theme default #netlify = false diff --git a/exampleSite/content/dev/colors/dev-contact/contact-primary.md b/exampleSite/content/dev/colors/dev-contact/contact-primary.md index adaebe6c..4bb68028 100644 --- a/exampleSite/content/dev/colors/dev-contact/contact-primary.md +++ b/exampleSite/content/dev/colors/dev-contact/contact-primary.md @@ -10,8 +10,8 @@ title = "Contact fragment" subtitle = "*not working on demo page*" #title_align = "left" # Default is center, can be left, right or center -# PostURL can be used with backends such as mailout from caddy -post_url = "https://example.com/mailout" #default: formspree.io +# PostURL can be used with backends such as formspree, or mailout from caddy +post_url = "https://example.com/mailout" email = "mail@example.com" button_text = "Send Button" # defaults to theme default #netlify = false diff --git a/exampleSite/content/dev/colors/dev-contact/contact-secondary.md b/exampleSite/content/dev/colors/dev-contact/contact-secondary.md index 680a0ad4..1cd3a544 100644 --- a/exampleSite/content/dev/colors/dev-contact/contact-secondary.md +++ b/exampleSite/content/dev/colors/dev-contact/contact-secondary.md @@ -10,8 +10,8 @@ title = "Contact fragment" subtitle = "*not working on demo page*" #title_align = "left" # Default is center, can be left, right or center -# PostURL can be used with backends such as mailout from caddy -post_url = "https://example.com/mailout" #default: formspree.io +# PostURL can be used with backends such as formspree, or mailout from caddy +post_url = "https://example.com/mailout" email = "mail@example.com" button_text = "Send Button" # defaults to theme default #netlify = false diff --git a/exampleSite/content/dev/colors/dev-contact/contact-white.md b/exampleSite/content/dev/colors/dev-contact/contact-white.md index 8ffcb313..f70794fe 100644 --- a/exampleSite/content/dev/colors/dev-contact/contact-white.md +++ b/exampleSite/content/dev/colors/dev-contact/contact-white.md @@ -10,8 +10,8 @@ title = "Contact fragment" subtitle = "*not working on demo page*" #title_align = "left" # Default is center, can be left, right or center -# PostURL can be used with backends such as mailout from caddy -post_url = "https://example.com/mailout" #default: formspree.io +# PostURL can be used with backends such as formspree, or mailout from caddy +post_url = "https://example.com/mailout" email = "mail@example.com" button_text = "Send Button" # defaults to theme default #netlify = false diff --git a/exampleSite/content/dev/contact/contact-netlify.md b/exampleSite/content/dev/contact/contact-netlify.md index 089169af..de7fd16c 100644 --- a/exampleSite/content/dev/contact/contact-netlify.md +++ b/exampleSite/content/dev/contact/contact-netlify.md @@ -9,8 +9,8 @@ form_name = "contact-form-netlify" title = "Contact fragment with Netlify support" subtitle = "*not working on demo page*" -# PostURL can be used with backends such as mailout from caddy -post_url = "https://example.com/mailout" #default: formspree.io +# PostURL can be used with backends such as formspree, or mailout from caddy +post_url = "https://example.com/mailout" email = "mail@example.com" button_text = "Send Button" # defaults to theme default netlify = true diff --git a/exampleSite/content/dev/contact/contact-recaptcha.md b/exampleSite/content/dev/contact/contact-recaptcha.md index b07f0128..f478049e 100644 --- a/exampleSite/content/dev/contact/contact-recaptcha.md +++ b/exampleSite/content/dev/contact/contact-recaptcha.md @@ -9,8 +9,8 @@ form_name = "contact-form-recaptcha" title = "Contact fragment with ReCaptcha support" subtitle = "*not working on demo page*" -# PostURL can be used with backends such as mailout from caddy -post_url = "https://example.com/mailout" #default: formspree.io +# PostURL can be used with backends such as formspree, or mailout from caddy +post_url = "https://example.com/mailout" email = "mail@example.com" button_text = "Send Button" # defaults to theme default #netlify = false diff --git a/exampleSite/content/dev/contact/contact.md b/exampleSite/content/dev/contact/contact.md index 774e5d36..a8c087c8 100644 --- a/exampleSite/content/dev/contact/contact.md +++ b/exampleSite/content/dev/contact/contact.md @@ -9,8 +9,8 @@ form_name = "contact-form" title = "Contact fragment" subtitle = "*not working on demo page*" -# PostURL can be used with backends such as mailout from caddy -post_url = "https://example.com/mailout" #default: formspree.io +# PostURL can be used with backends such as formspree, or mailout from caddy +post_url = "https://example.com/mailout" email = "mail@example.com" button_text = "Send Button" # defaults to theme default #netlify = false diff --git a/exampleSite/content/dev/events/payment/contact.md b/exampleSite/content/dev/events/payment/contact.md index 16238533..3a223895 100644 --- a/exampleSite/content/dev/events/payment/contact.md +++ b/exampleSite/content/dev/events/payment/contact.md @@ -10,8 +10,8 @@ title = "Contact fragment" subtitle = "*not working on demo page*" #title_align = "left" # Default is center, can be left, right or center -# PostURL can be used with backends such as mailout from caddy -post_url = "https://example.com/mailout" #default: formspree.io +# PostURL can be used with backends such as formspree, or mailout from caddy +post_url = "https://example.com/mailout" email = "mail@example.com" button_text = "Send Button" # defaults to theme default #netlify = false diff --git a/exampleSite/content/fragments/contact/code-contact.md b/exampleSite/content/fragments/contact/code-contact.md index f8df2f71..71ba4771 100644 --- a/exampleSite/content/fragments/contact/code-contact.md +++ b/exampleSite/content/fragments/contact/code-contact.md @@ -18,8 +18,8 @@ title = "Contact fragment" subtitle = "*not working on demo page*" #title_align = "left" # Default is center, can be left, right or center -# PostURL can be used with backends such as mailout from caddy -post_url = "https://example.com/mailout" #default: formspree.io +# PostURL can be used with backends such as formspree, or mailout from caddy +post_url = "https://example.com/mailout" email = "mail@example.com" button_text = "Send Button" # defaults to theme default #netlify = false diff --git a/exampleSite/content/fragments/contact/contact.md b/exampleSite/content/fragments/contact/contact.md index 3c9c26e8..86922817 100644 --- a/exampleSite/content/fragments/contact/contact.md +++ b/exampleSite/content/fragments/contact/contact.md @@ -10,8 +10,8 @@ title = "Contact fragment" subtitle = "*not working on demo page*" #title_align = "left" # Default is center, can be left, right or center -# PostURL can be used with backends such as mailout from caddy -post_url = "https://example.com/mailout" #default: formspree.io +# PostURL can be used with backends such as formspree, or mailout from caddy +post_url = "https://example.com/mailout" email = "mail@example.com" button_text = "Send Button" # defaults to theme default #netlify = false diff --git a/exampleSite/content/fragments/contact/docs.md b/exampleSite/content/fragments/contact/docs.md index bcb72f89..712d1cb8 100644 --- a/exampleSite/content/fragments/contact/docs.md +++ b/exampleSite/content/fragments/contact/docs.md @@ -60,8 +60,6 @@ Unique name for the form used to identify the form in scripts and on the page. #### post_url *type: string* -*default: formspree.io* -*Requires email to be set* URL to your own backend or a service you are using. diff --git a/exampleSite/content/fragments/contact/index.md b/exampleSite/content/fragments/contact/index.md index 6b755f92..ad75b900 100644 --- a/exampleSite/content/fragments/contact/index.md +++ b/exampleSite/content/fragments/contact/index.md @@ -19,5 +19,4 @@ Contact fragment renders a form with a maximum of 4 fields: This fragment supports validations and thus can have customized error messages. Recaptcha and Netlify (with Netlify auto Recaptcha) support is also available. -With a [Formspree](https://formspree.io) account you can simply enter your -email. Other options are using a custom server or other form submission handlers +Other options are using a custom server or other form submission handlers such as [Formspree](https://formspree.io). diff --git a/layouts/partials/fragments/contact.html b/layouts/partials/fragments/contact.html index c3609408..d1fb5437 100644 --- a/layouts/partials/fragments/contact.html +++ b/layouts/partials/fragments/contact.html @@ -19,11 +19,8 @@ {{- if .Params.netlify -}} {{- safeHTMLAttr (print " data-has-netlify=\"true\" netlify") -}} {{- else -}} - {{- safeHTMLAttr (printf " action=\"%s\"" (.Params.post_url | default (printf "https://formspree.io/%s" .Params.email))) -}} - {{- end -}} - {{- if and (isset .Params "email") -}} - {{- safeHTMLAttr (print " data-has-formspree=\"true\"") -}} - {{- end }}> + {{- safeHTMLAttr (printf " action=\"%s\"" .Params.post_url) -}} + {{- end -}}> <div class="row py-3 should-fade"> <div class="col-md-6"> {{- with .Params.fields.name }} |