mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
Merge pull request #259 from quantum-dragons/bugfix/reply-form-js-fix
Added JS fix for reply forms
This commit is contained in:
commit
6d7b14367a
@ -6,31 +6,33 @@
|
|||||||
/**
|
/**
|
||||||
* Enable form validation
|
* Enable form validation
|
||||||
*/
|
*/
|
||||||
$('.comments-holder-container form').validate({
|
$('.comments-holder-container form').each(function() {
|
||||||
|
$(this).validate({
|
||||||
|
|
||||||
// Ignore hidden elements in this form
|
// Ignore hidden elements in this form
|
||||||
ignore: ':hidden',
|
ignore: ':hidden',
|
||||||
|
|
||||||
// Use default 'required' for error labels
|
// Use default 'required' for error labels
|
||||||
errorClass: "required",
|
errorClass: "required",
|
||||||
|
|
||||||
// Use span instead of labels
|
// Use span instead of labels
|
||||||
errorElement: "span",
|
errorElement: "span",
|
||||||
|
|
||||||
// On error, scroll to the invalid element
|
// On error, scroll to the invalid element
|
||||||
invalidHandler : function(form, validator){
|
invalidHandler : function(form, validator){
|
||||||
$('html, body').animate({
|
$('html, body').animate({
|
||||||
scrollTop: $(validator.errorList[0].element).offset().top - 30
|
scrollTop: $(validator.errorList[0].element).offset().top - 30
|
||||||
}, 200);
|
}, 200);
|
||||||
},
|
},
|
||||||
|
|
||||||
// Ensure any new error message has the correct class and placement
|
// Ensure any new error message has the correct class and placement
|
||||||
errorPlacement: function(error, element) {
|
errorPlacement: function(error, element) {
|
||||||
error
|
error
|
||||||
.addClass('message')
|
.addClass('message')
|
||||||
.insertAfter(element);
|
.insertAfter(element);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hide comment reply forms by default (unless visiting via permalink)
|
* Hide comment reply forms by default (unless visiting via permalink)
|
||||||
@ -56,7 +58,7 @@
|
|||||||
|
|
||||||
// Prevent focus
|
// Prevent focus
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if(form.is(':visible')) {
|
if(form.is(':visible')) {
|
||||||
allForms.slideUp();
|
allForms.slideUp();
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user