From 590d44df5fa8bd68c1feeb6c108cb85496336157 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 20 Jan 2021 18:44:30 -0500 Subject: [PATCH] [frio] Add block author button in More dropdown --- view/theme/frio/js/textedit.js | 33 +++++++++++++++++++++-- view/theme/frio/templates/js_strings.tpl | 3 ++- view/theme/frio/templates/wall_thread.tpl | 6 +++++ 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/view/theme/frio/js/textedit.js b/view/theme/frio/js/textedit.js index 39e7f4428f..014f6504fd 100644 --- a/view/theme/frio/js/textedit.js +++ b/view/theme/frio/js/textedit.js @@ -198,6 +198,10 @@ function confirmDelete() { return confirm(aStr.delitem); } +function confirmBlock() { + return confirm(aStr.blockAuthor); +} + /** * Hide and removes an item element from the DOM after the deletion url is * successful, restore it else. @@ -207,9 +211,34 @@ function confirmDelete() { * @returns {undefined} */ function dropItem(url, elementId) { - var confirm = confirmDelete(); + if (confirmDelete()) { + $("body").css("cursor", "wait"); - if (confirm) { + 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'); + }); + }); + } +} + +/** + * Blocks an author and hide and removes an item element from the DOM after the block is + * successful, restore it else. + * + * @param {string} url The item removal URL + * @param {string} elementId The DOM id of the item element + * @returns {undefined} + */ +function blockAuthor(url, elementId) { + if (confirmBlock()) { $("body").css("cursor", "wait"); var $el = $(document.getElementById(elementId)); diff --git a/view/theme/frio/templates/js_strings.tpl b/view/theme/frio/templates/js_strings.tpl index b649159b9b..066e4bd585 100644 --- a/view/theme/frio/templates/js_strings.tpl +++ b/view/theme/frio/templates/js_strings.tpl @@ -6,6 +6,7 @@ They are loaded into the html so that js functions can use them *}} var localUser = {{if $local_user}}{{$local_user}}{{else}}false{{/if}}; var aStr = { - 'delitem' : "{{$delitem}}", + 'delitem' : "{{$delitem|escape:'javascript' nofilter}}", + 'blockAuthor' : "{{$blockAuthor|escape:'javascript' nofilter}}", }; diff --git a/view/theme/frio/templates/wall_thread.tpl b/view/theme/frio/templates/wall_thread.tpl index 99316fce3e..25d6885fc8 100644 --- a/view/theme/frio/templates/wall_thread.tpl +++ b/view/theme/frio/templates/wall_thread.tpl @@ -393,6 +393,12 @@ as the value of $top_child_total (this is done at the end of this file) {{$item.drop.delete}} {{/if}} + + {{if $item.block}} +
  • + {{$item.block.block}} +
  • + {{/if}}