diff options
| author | Andrew Lee <alee14498@gmail.com> | 2019-10-27 09:57:37 -0400 |
|---|---|---|
| committer | Andrew Lee <alee14498@gmail.com> | 2019-10-27 09:57:37 -0400 |
| commit | e62e7bb6b14555c9bbe5d40d217103984f4f80e6 (patch) | |
| tree | 21887d847dccacb47644eb6f74ce31326172303c /_includes/comments-providers/staticman.html | |
| parent | 716ea6ed2b64c921a799d872a07bfbd53b2a3e58 (diff) | |
| download | pokeworld-website-e62e7bb6b14555c9bbe5d40d217103984f4f80e6.tar.gz pokeworld-website-e62e7bb6b14555c9bbe5d40d217103984f4f80e6.tar.bz2 pokeworld-website-e62e7bb6b14555c9bbe5d40d217103984f4f80e6.zip | |
Rewrite progress
Diffstat (limited to '_includes/comments-providers/staticman.html')
| -rw-r--r-- | _includes/comments-providers/staticman.html | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/_includes/comments-providers/staticman.html b/_includes/comments-providers/staticman.html new file mode 100644 index 0000000..ae3991d --- /dev/null +++ b/_includes/comments-providers/staticman.html @@ -0,0 +1,40 @@ +{% if site.repository and site.staticman.branch %} + <script> + (function ($) { + $('#new_comment').submit(function () { + var form = this; + + $(form).addClass('disabled'); + $('#comment-form-submit').html('<i class="fas fa-spinner fa-spin fa-fw"></i> {{ site.data.ui-text[site.locale].loading_label | default: "Loading..." }}'); + + $.ajax({ + type: $(this).attr('method'), + url: $(this).attr('action'), + data: $(this).serialize(), + contentType: 'application/x-www-form-urlencoded', + success: function (data) { + $('#comment-form-submit').html('{{ site.data.ui-text[site.locale].comment_btn_submitted | default: "Submitted" }}'); + $('.page__comments-form .js-notice').removeClass('notice--danger'); + $('.page__comments-form .js-notice').addClass('notice--success'); + showAlert('{{ site.data.ui-text[site.locale].comment_success_msg | default: "Thanks for your comment! It will show on the site once it has been approved." }}'); + }, + error: function (err) { + console.log(err); + $('#comment-form-submit').html('{{ site.data.ui-text[site.locale].comment_btn_submit | default: "Submit Comment" }}'); + $('.page__comments-form .js-notice').removeClass('notice--success'); + $('.page__comments-form .js-notice').addClass('notice--danger'); + showAlert('{{ site.data.ui-text[site.locale].comment_error_msg | default: "Sorry, there was an error with your submission. Please make sure all required fields have been completed and try again." }}'); + $(form).removeClass('disabled'); + } + }); + + return false; + }); + + function showAlert(message) { + $('.page__comments-form .js-notice').removeClass('hidden'); + $('.page__comments-form .js-notice-text').html(message); + } + })(jQuery); + </script> +{% endif %} |
