beautifulSA-jekyll/assets/js/staticman.js
Marco Blessing 5e52982867
Merge/2021 02 15 (#3)
* fix(#744): Escape special characters in title (#745)

* add matt artist as sponsor

* Fix margin top alignment issue on Safari (#750)

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Remove references to any public Staticman API instance (#775)

* Update CHANGELOG.md

Co-authored-by: Dmitry <dmitry.b.danilov@gmail.com>
Co-authored-by: Dean Attali <dean@attalitech.com>
Co-authored-by: Amy Troschinetz <lexicalunit@lexicalunit.com>
Co-authored-by: Dean Attali <daattali@gmail.com>
Co-authored-by: Vincent Tam <VincentTam@users.noreply.github.com>
2021-02-15 19:33:32 +01:00

55 lines
1.7 KiB
JavaScript

---
layout: null
---
(function ($) {
var $comments = $('.js-comments');
$('#new_comment').submit(function () {
var form = this;
$(form).addClass('disabled');
{% assign sm = site.staticman -%}
var endpoint = '{{ sm.endpoint }}';
var repository = '{{ sm.repository }}';
var branch = '{{ sm.branch }}';
$.ajax({
type: $(this).attr('method'),
url: endpoint + repository + '/' + branch + '/comments',
data: $(this).serialize(),
contentType: 'application/x-www-form-urlencoded',
success: function (data) {
$('#comment-form-submit').addClass('d-none');
$('#comment-form-submitted').removeClass('d-none');
$('.page__comments-form .js-notice').removeClass('alert-danger');
$('.page__comments-form .js-notice').addClass('alert-success');
showAlert('success');
},
error: function (err) {
console.log(err);
$('#comment-form-submitted').addClass('d-none');
$('#comment-form-submit').removeClass('d-none');
$('.page__comments-form .js-notice').removeClass('alert-success');
$('.page__comments-form .js-notice').addClass('alert-danger');
showAlert('failure');
$(form).removeClass('disabled');
}
});
return false;
});
function showAlert(message) {
$('.page__comments-form .js-notice').removeClass('d-none');
if (message == 'success') {
$('.page__comments-form .js-notice-text-success').removeClass('d-none');
$('.page__comments-form .js-notice-text-failure').addClass('d-none');
} else {
$('.page__comments-form .js-notice-text-success').addClass('d-none');
$('.page__comments-form .js-notice-text-failure').removeClass('d-none');
}
}
})(jQuery);