Merge pull request #259 from quantum-dragons/bugfix/reply-form-js-fix

Added JS fix for reply forms
This commit is contained in:
Robbie Averill 2018-06-25 14:08:08 +12:00 committed by GitHub
commit 6d7b14367a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,31 +6,33 @@
/**
* Enable form validation
*/
$('.comments-holder-container form').validate({
$('.comments-holder-container form').each(function() {
$(this).validate({
// Ignore hidden elements in this form
ignore: ':hidden',
// Ignore hidden elements in this form
ignore: ':hidden',
// Use default 'required' for error labels
errorClass: "required",
// Use default 'required' for error labels
errorClass: "required",
// Use span instead of labels
errorElement: "span",
// Use span instead of labels
errorElement: "span",
// On error, scroll to the invalid element
invalidHandler : function(form, validator){
$('html, body').animate({
scrollTop: $(validator.errorList[0].element).offset().top - 30
}, 200);
},
// On error, scroll to the invalid element
invalidHandler : function(form, validator){
$('html, body').animate({
scrollTop: $(validator.errorList[0].element).offset().top - 30
}, 200);
},
// Ensure any new error message has the correct class and placement
errorPlacement: function(error, element) {
error
.addClass('message')
.insertAfter(element);
}
});
// Ensure any new error message has the correct class and placement
errorPlacement: function(error, element) {
error
.addClass('message')
.insertAfter(element);
}
});
});
/**
* Hide comment reply forms by default (unless visiting via permalink)
@ -56,7 +58,7 @@
// Prevent focus
e.preventDefault();
if(form.is(':visible')) {
allForms.slideUp();
} else {