Add menu entry to directly collapse posts

This commit is contained in:
Michael 2023-05-20 12:24:19 +00:00
parent 28185c12fc
commit 1744f6b2c3
7 changed files with 182 additions and 110 deletions

View file

@ -206,6 +206,10 @@ function confirmIgnore() {
return confirm(aStr.ignoreAuthor);
}
function confirmCollapse() {
return confirm(aStr.collapseAuthor);
}
/**
* Hide and removes an item element from the DOM after the deletion url is
* successful, restore it else.
@ -292,4 +296,33 @@ function ignoreAuthor(url, elementId) {
});
}
}
/**
* Collapse author posts
*
* @param {string} url The item collapse URL
* @param {string} elementId The DOM id of the item element
* @returns {undefined}
*/
function collapseAuthor(url, elementId) {
if (confirmCollapse()) {
$("body").css("cursor", "wait");
var $el = $(document.getElementById(elementId));
$el.fadeTo("fast", 0.33, function () {
$.get(url)
.then(function () {
//$el.remove();
})
.fail(function () {
// @todo Show related error message
$el.show();
})
.always(function () {
$("body").css("cursor", "auto");
});
});
}
}
// @license-end