Fix bad merge on commentsinterface.js

This commit is contained in:
Juan Jose Gonzalez 2023-02-11 17:05:55 +01:00
parent 6bf07c8643
commit bcfdee4e72
1 changed files with 26 additions and 118 deletions

View File

@ -75,6 +75,27 @@
}
});
/**
* Toggle on/off update form
*/
$('.comments-holder').on('click', '.comment-update-link', function (e) {
const allForms = $('.comment-update-form-holder');
const formID = `#${$(this).attr('aria-controls')}`;
const form = $(formID).closest('.comment-update-form-holder');
$(this).attr('aria-expanded', (i, attr) => (attr === 'true' ? 'false' : 'true'));
// Prevent focus
e.preventDefault();
if (form.is(':visible')) {
allForms.slideUp();
} else {
allForms.not(form).slideUp();
form.slideDown();
}
});
/**
* Clicking one of the metalinks performs the operation via ajax
* this inclues the spam and approve links
@ -123,121 +144,8 @@
}
});
/**
* Hide comment reply forms by default (unless visiting via permalink)
*/
$(".comment")
.children('.info')
.not(window.document.location.hash)
.nextAll(".comment-replies-container")
.children(".comment-reply-form-holder")
.hide();
/**
* Hide comment update forms by default
*/
$(".comment")
.children(".comment-update-form-holder")
.hide();
/**
* Toggle on/off reply form
*/
$('.comments-holder').on('click', '.comment-reply-link', function(e) {
var allForms = $('.comment-reply-form-holder');
var formID = '#' + $(this).attr('aria-controls');
var form = $(formID).closest('.comment-reply-form-holder');
$(this).attr('aria-expanded', function (i, attr) {
return attr == 'true' ? 'false' : 'true'
});
// Prevent focus
e.preventDefault();
if(form.is(':visible')) {
allForms.slideUp();
} else {
allForms.not(form).slideUp();
form.slideDown();
}
});
/**
* Toggle on/off update form
*/
$('.comments-holder').on('click', '.comment-update-link', function(e) {
var allForms = $('.comment-update-form-holder');
var formID = '#' + $(this).attr('aria-controls');
var form = $(formID).closest('.comment-update-form-holder');
$(this).attr('aria-expanded', function (i, attr) {
return attr == 'true' ? 'false' : 'true'
});
// Prevent focus
e.preventDefault();
if(form.is(':visible')) {
allForms.slideUp();
} else {
allForms.not(form).slideUp();
form.slideDown();
}
});
/**
* Clicking one of the metalinks performs the operation via ajax
* this inclues the spam and approve links
*/
$('.comments-holder .comments-list').on('click', 'div.comment-moderation-options a', function(e) {
e.stopPropagation();
var link = $(this);
if (link.hasClass('delete')) {
var confirmationMsg = ss.i18n._t('CommentsInterface_singlecomment_ss.DELETE_CONFIRMATION');
var confirmation = window.confirm(confirmationMsg);
if (!confirmation) {
e.preventDefault();
return false;
}
}
var comment = link.parents('.comment:first');
$.ajax({
url: $(this).attr('href'),
cache: false,
success: function(html){
if(link.hasClass('ham')) {
// comment has been marked as not spam
comment.html(html);
comment.removeClass('spam');
}
else if(link.hasClass('approve')) {
// comment has been approved
comment.html(html);
comment.removeClass('unmoderated');
}
else if(link.hasClass('delete')) {
comment.fadeOut(1000, function() {
comment.remove();
if($('.comments-holder .comments-list').children().length === 0) {
$('.no-comments-yet').show();
}
});
}
else if(link.hasClass('spam')) {
comment.html(html).addClass('spam');
}
},
failure: function(html) {
var errorMsg = ss.i18n._t('CommentsInterface_singlecomment_ss.AJAX_ERROR');
alert(errorMsg);
}
});
e.preventDefault();
});
});
})(jQuery);
e.preventDefault();
return false;
});
});
}(jQuery));