This commit is contained in:
Flavio Copes 2015-10-07 23:53:40 +02:00
parent a178946aba
commit 5790ac019e
1 changed files with 65 additions and 61 deletions

View File

@ -3,12 +3,13 @@
<h3>Add a Comment</h3>
<script>
function validateEmail(email) {
$(function() {
function validateEmail(email) {
var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
return re.test(email);
}
}
jQuery(document).on('click tap', '.js__add-new-comment', function(event) {
$(document).on('click tap', '.js__add-new-comment', function(event) {
event.preventDefault();
var text = $('.js__new-comment-text').val();
@ -36,7 +37,7 @@ jQuery(document).on('click tap', '.js__add-new-comment', function(event) {
}
{% endif %}
jQuery.ajax({
$.ajax({
url: "{{ grav.uri.rootUrl }}/add-comment",
data: {
text: $('.js__new-comment-text').val(),
@ -57,6 +58,7 @@ jQuery(document).on('click tap', '.js__add-new-comment', function(event) {
$('.alert').html("Error while posting the comment");
$('.alert-container').show();
});
});
});
</script>
@ -64,6 +66,7 @@ jQuery(document).on('click tap', '.js__add-new-comment', function(event) {
<script src="https://www.google.com/recaptcha/api.js?onload=captchaOnloadCallback&render=explicit" async defer></script>
<script>
$(function() {
var captchaOnloadCallback = function captchaOnloadCallback() {
grecaptcha.render('g-recaptcha', {
'sitekey': "{{grav.config.plugins.comments.recatpcha_site_key}}",
@ -78,6 +81,7 @@ jQuery(document).on('click tap', '.js__add-new-comment', function(event) {
var captchaExpiredCallback = function captchaExpiredCallback() {
grecaptcha.reset();
};
});
</script>
{% endif %}