]> git.mxchange.org Git - friendica.git/commitdiff
[frio] Add block author button in More dropdown
authorHypolite Petovan <hypolite@mrpetovan.com>
Wed, 20 Jan 2021 23:44:30 +0000 (18:44 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sat, 23 Jan 2021 10:33:15 +0000 (05:33 -0500)
view/theme/frio/js/textedit.js
view/theme/frio/templates/js_strings.tpl
view/theme/frio/templates/wall_thread.tpl

index 39e7f4428ffc22839a7b11d8c11241d05c158682..014f6504fdbda0bfd47638bf00cf5586723b0b72 100644 (file)
@@ -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");
+
+               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');
+                       });
+               });
+       }
+}
 
-       if (confirm) {
+/**
+ * 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));
index b649159b9b984e146a5e8cfe06421489039bf273..066e4bd58525521a8c543ba1cea23d50b7ddc20c 100644 (file)
@@ -6,6 +6,7 @@ They are loaded into the html <head> 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}}",
        };
 </script>
index 99316fce3e702a3aa62161999be10ee61c6d7aed..25d6885fc8c23180ecd0422d23013715afc1761e 100644 (file)
@@ -393,6 +393,12 @@ as the value of $top_child_total (this is done at the end of this file)
                                                        <a class="btn-link navicon delete" href="javascript:dropItem('item/drop/{{$item.id}}/{{$item.return}}', 'item-{{$item.guid}}');" title="{{$item.drop.delete}}"><i class="fa fa-trash" aria-hidden="true"></i> {{$item.drop.delete}}</a>
                                                </li>
                                                {{/if}}
+
+                                               {{if $item.block}}
+                                               <li role="menuitem">
+                                                       <a class="btn-link navicon block" href="javascript:blockAuthor('item/block/{{$item.id}}/{{$item.return}}', 'item-{{$item.guid}}');" title="{{$item.block.block}}"><i class="fa fa-ban" aria-hidden="true"></i> {{$item.block.block}}</a>
+                                               </li>
+                                               {{/if}}
                                        </ul>
                                        <img id="like-rotator-{{$item.id}}" class="like-rotator" src="images/rotator.gif" alt="{{$item.wait}}" title="{{$item.wait}}" style="display: none;" />
                                </span>