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