From f8fc9c1e8ba93b4b66184e11e5dfd846f8b18e26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Thu, 9 Mar 2023 14:55:43 +0100 Subject: [PATCH 01/21] improve like/share buttons change the button only if it could send its request successfully to the server. fixes: * disrupting a video on liking or sharing * timeline jumps around somewhere else, when you like or share a posting/comment, and you can not find back. --- view/theme/frio/js/theme.js | 50 +++++++++++++++++++--- view/theme/frio/templates/like_noshare.tpl | 7 ++- view/theme/frio/templates/wall_thread.tpl | 10 ++--- 3 files changed, 53 insertions(+), 14 deletions(-) diff --git a/view/theme/frio/js/theme.js b/view/theme/frio/js/theme.js index 60aa88ba5..1d5295f68 100644 --- a/view/theme/frio/js/theme.js +++ b/view/theme/frio/js/theme.js @@ -764,12 +764,52 @@ function htmlToText(htmlString) { * @param {boolean} un Whether to perform an activity removal instead of creation */ function doActivityItemAction(ident, verb, un) { - if (verb.indexOf("attend") === 0) { - $(".item-" + ident + " .button-event:not(#" + verb + "-" + ident + ")").removeClass("active"); - } - $("#" + verb + "-" + ident).toggleClass("active"); + console.log(ident, verb, un); + _verb = un ? 'un' + verb : verb; + $('#like-rotator-' + ident.toString()).show(); + $.post('item/' + ident.toString() + '/activity/' + _verb) + .success( + function(data){ + console.log("data.status: " + data.status); + if (data.status == "ok") { + console.log("connection: " + data.status); + $('#like-rotator-' + ident.toString()).hide(); + if (verb.indexOf("announce") === 0 ) { + console.log("announce") + if (data.verb == "un" + verb) { + $("button[id^=shareMenuOptions-" + ident.toString() + "]" ).removeClass("active"); + $("button[id^=shareMenuOptions-" + ident.toString() + "]" ).attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + false + ")").change(); + $("button[id^=" + verb + "-" + ident.toString() + "]" ).removeClass("active"); + $("button[id^=" + verb + "-" + ident.toString() + "]" ).attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + false + ")").change(); + } else { + $("button[id^=shareMenuOptions-" + ident.toString() + "]" ).addClass("active"); + $("button[id^=shareMenuOptions-" + ident.toString() + "]" ).attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + true + ")").change(); + $("button[id^=" + verb + "-" + ident.toString() + "]" ).addClass("active"); + $("button[id^=" + verb + "-" + ident.toString() + "]" ).attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + true + ")").change(); + } + } else { + console.log("likes") + if (data.verb == "un" + verb) { + console.log(data.state); + $("button[id^=" + verb + "-" + ident.toString() + "]" ).removeClass("active"); + $("button[id^=" + verb + "-" + ident.toString() + "]" ).attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + false + ")").change(); + } else { + $("button[id^=" + verb + "-" + ident.toString() + "]" ).addClass("active"); + $("button[id^=" + verb + "-" + ident.toString() + "]" ).attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + true + ")").change(); + } + $("button[id^=" + verb + "-" + ident.toString() + "]" ).button('refresh'); + } + } else { + $.jGrowl("No connection to host for like or share", {sticky: false, theme: 'info', life: 5000}); + console.err("No connection to host"); + } + }) + .error( + function(data){ + $.jGrowl("Network not reachable", {sticky: false, theme: 'info', life: 5000}); + console.log("POST unsuccessfull " + data.toString()); + }); - doActivityItem(ident, verb, un); } // Decodes a hexadecimally encoded binary string diff --git a/view/theme/frio/templates/like_noshare.tpl b/view/theme/frio/templates/like_noshare.tpl index df335c32e..83e7b4a98 100644 --- a/view/theme/frio/templates/like_noshare.tpl +++ b/view/theme/frio/templates/like_noshare.tpl @@ -3,8 +3,7 @@ {{if !$hide_dislike}} @@ -13,8 +12,8 @@ class="btn-link button-likes{{if $responses.dislike.self}} active" aria-pressed="true{{/if}}" id="dislike-{{$id}}" title="{{$dislike_title}}" - onclick="doActivityItemAction({{$id}}, 'dislike'{{if $responses.dislike.self}}, true{{/if}});" - data-toggle="button"> {{$dislike}} + onclick="doActivityItemAction({{$id}}, 'dislike'{{if $responses.dislike.self}}, true{{/if}});"> +  {{$dislike}} {{/if}} diff --git a/view/theme/frio/templates/wall_thread.tpl b/view/theme/frio/templates/wall_thread.tpl index e4f87f940..7e77e5052 100644 --- a/view/theme/frio/templates/wall_thread.tpl +++ b/view/theme/frio/templates/wall_thread.tpl @@ -285,13 +285,13 @@ as the value of $top_child_total (this is done at the end of this file) {{* Buttons for like and dislike *}} {{if $item.vote}} {{if $item.vote.like}} - + {{/if}} {{if $item.vote.like AND $item.vote.dislike}} {{/if}} {{if $item.vote.dislike}} - + {{/if}} {{if ($item.vote.like OR $item.vote.dislike) AND $item.comment_html}} @@ -316,7 +316,7 @@ as the value of $top_child_total (this is done at the end of this file) {{/if}} {{/if}} {{if $item.vote.announce}} - + {{/if}} {{if $item.vote.share}} @@ -441,10 +441,10 @@ as the value of $top_child_total (this is done at the end of this file) {{* Buttons for like and dislike *}} {{if $item.vote}} {{if $item.vote.like}} - + {{/if}} {{if $item.vote.dislike}} - + {{/if}} {{/if}} From 4244670f1cdf4fb14a07fc7a81a8d547deb105cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Thu, 9 Mar 2023 14:55:43 +0100 Subject: [PATCH 02/21] simplify code, remove debug output --- view/theme/frio/js/theme.js | 44 ++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/view/theme/frio/js/theme.js b/view/theme/frio/js/theme.js index 1d5295f68..506404ede 100644 --- a/view/theme/frio/js/theme.js +++ b/view/theme/frio/js/theme.js @@ -764,50 +764,48 @@ function htmlToText(htmlString) { * @param {boolean} un Whether to perform an activity removal instead of creation */ function doActivityItemAction(ident, verb, un) { - console.log(ident, verb, un); _verb = un ? 'un' + verb : verb; $('#like-rotator-' + ident.toString()).show(); $.post('item/' + ident.toString() + '/activity/' + _verb) .success( function(data){ - console.log("data.status: " + data.status); if (data.status == "ok") { - console.log("connection: " + data.status); $('#like-rotator-' + ident.toString()).hide(); if (verb.indexOf("announce") === 0 ) { - console.log("announce") if (data.verb == "un" + verb) { - $("button[id^=shareMenuOptions-" + ident.toString() + "]" ).removeClass("active"); - $("button[id^=shareMenuOptions-" + ident.toString() + "]" ).attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + false + ")").change(); - $("button[id^=" + verb + "-" + ident.toString() + "]" ).removeClass("active"); - $("button[id^=" + verb + "-" + ident.toString() + "]" ).attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + false + ")").change(); + $("button[id^=shareMenuOptions-" + ident.toString() + "]" ) + .removeClass("active") + .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + false + ")").change(); + $("button[id^=" + verb + "-" + ident.toString() + "]" ) + .removeClass("active") + .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + false + ")").change(); } else { - $("button[id^=shareMenuOptions-" + ident.toString() + "]" ).addClass("active"); - $("button[id^=shareMenuOptions-" + ident.toString() + "]" ).attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + true + ")").change(); - $("button[id^=" + verb + "-" + ident.toString() + "]" ).addClass("active"); - $("button[id^=" + verb + "-" + ident.toString() + "]" ).attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + true + ")").change(); + $("button[id^=shareMenuOptions-" + ident.toString() + "]" ) + .addClass("active") + .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + true + ")").change(); + $("button[id^=" + verb + "-" + ident.toString() + "]" ) + .addClass("active") + .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + true + ")").change(); } } else { - console.log("likes") if (data.verb == "un" + verb) { - console.log(data.state); - $("button[id^=" + verb + "-" + ident.toString() + "]" ).removeClass("active"); - $("button[id^=" + verb + "-" + ident.toString() + "]" ).attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + false + ")").change(); + $("button[id^=" + verb + "-" + ident.toString() + "]" ) + .removeClass("active") + .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + false + ")").change(); } else { - $("button[id^=" + verb + "-" + ident.toString() + "]" ).addClass("active"); - $("button[id^=" + verb + "-" + ident.toString() + "]" ).attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + true + ")").change(); + $("button[id^=" + verb + "-" + ident.toString() + "]" ) + .addClass("active") + .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + true + ")").change(); } - $("button[id^=" + verb + "-" + ident.toString() + "]" ).button('refresh'); +// $("button[id^=" + verb + "-" + ident.toString() + "]" ).button('refresh'); } } else { - $.jGrowl("No connection to host for like or share", {sticky: false, theme: 'info', life: 5000}); - console.err("No connection to host"); + $.jGrowl("No connection to host for " + verb, {sticky: false, theme: 'info', life: 5000}); } }) .error( function(data){ - $.jGrowl("Network not reachable", {sticky: false, theme: 'info', life: 5000}); - console.log("POST unsuccessfull " + data.toString()); + $.jGrowl("Activity " + verb + "unsuccessful", {sticky: false, theme: 'info', life: 5000}); }); } From a1b9f2754576678bff42d8611b08a31ec39ed1cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Thu, 9 Mar 2023 14:55:43 +0100 Subject: [PATCH 03/21] make indentation as tabs --- view/theme/frio/js/theme.js | 77 ++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 39 deletions(-) diff --git a/view/theme/frio/js/theme.js b/view/theme/frio/js/theme.js index 506404ede..6239ebd35 100644 --- a/view/theme/frio/js/theme.js +++ b/view/theme/frio/js/theme.js @@ -769,45 +769,44 @@ function doActivityItemAction(ident, verb, un) { $.post('item/' + ident.toString() + '/activity/' + _verb) .success( function(data){ - if (data.status == "ok") { - $('#like-rotator-' + ident.toString()).hide(); - if (verb.indexOf("announce") === 0 ) { - if (data.verb == "un" + verb) { - $("button[id^=shareMenuOptions-" + ident.toString() + "]" ) - .removeClass("active") - .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + false + ")").change(); - $("button[id^=" + verb + "-" + ident.toString() + "]" ) - .removeClass("active") - .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + false + ")").change(); - } else { - $("button[id^=shareMenuOptions-" + ident.toString() + "]" ) - .addClass("active") - .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + true + ")").change(); - $("button[id^=" + verb + "-" + ident.toString() + "]" ) - .addClass("active") - .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + true + ")").change(); - } - } else { - if (data.verb == "un" + verb) { - $("button[id^=" + verb + "-" + ident.toString() + "]" ) - .removeClass("active") - .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + false + ")").change(); - } else { - $("button[id^=" + verb + "-" + ident.toString() + "]" ) - .addClass("active") - .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + true + ")").change(); - } -// $("button[id^=" + verb + "-" + ident.toString() + "]" ).button('refresh'); - } - } else { - $.jGrowl("No connection to host for " + verb, {sticky: false, theme: 'info', life: 5000}); - } - }) - .error( - function(data){ - $.jGrowl("Activity " + verb + "unsuccessful", {sticky: false, theme: 'info', life: 5000}); - }); - + if (data.status == "ok") { + $('#like-rotator-' + ident.toString()).hide(); + if (verb.indexOf("announce") === 0 ) { + if (data.verb == "un" + verb) { + $("button[id^=shareMenuOptions-" + ident.toString() + "]" ) + .removeClass("active") + .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + false + ")").change(); + $("button[id^=" + verb + "-" + ident.toString() + "]" ) + .removeClass("active") + .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + false + ")").change(); + } else { + $("button[id^=shareMenuOptions-" + ident.toString() + "]" ) + .addClass("active") + .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + true + ")").change(); + $("button[id^=" + verb + "-" + ident.toString() + "]" ) + .addClass("active") + .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + true + ")").change(); + } + } else { + if (data.verb == "un" + verb) { + $("button[id^=" + verb + "-" + ident.toString() + "]" ) + .removeClass("active") + .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + false + ")").change(); + } else { + $("button[id^=" + verb + "-" + ident.toString() + "]" ) + .addClass("active") + .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + true + ")").change(); + } + // $("button[id^=" + verb + "-" + ident.toString() + "]" ).button('refresh'); + } + } else { + $.jGrowl("No connection to host for " + verb, {sticky: false, theme: 'info', life: 5000}); + } + }) + .error( + function(data){ + $.jGrowl("Activity " + verb + "unsuccessful", {sticky: false, theme: 'info', life: 5000}); + }); } // Decodes a hexadecimally encoded binary string From 660a9cf28525db90a31c0440ab1c460b0d8d372a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Thu, 9 Mar 2023 14:55:43 +0100 Subject: [PATCH 04/21] show rotator on button --- view/theme/frio/js/theme.js | 103 ++++++++++++++++++++++++------------ 1 file changed, 70 insertions(+), 33 deletions(-) diff --git a/view/theme/frio/js/theme.js b/view/theme/frio/js/theme.js index 6239ebd35..221288a16 100644 --- a/view/theme/frio/js/theme.js +++ b/view/theme/frio/js/theme.js @@ -765,48 +765,85 @@ function htmlToText(htmlString) { */ function doActivityItemAction(ident, verb, un) { _verb = un ? 'un' + verb : verb; - $('#like-rotator-' + ident.toString()).show(); + var rot = $('') + .attr('src', 'images/rotator.gif') + .addClass("fa"); + //$('#like-rotator-' + ident.toString()).show(); + if (verb.indexOf("announce") === 0 ) { + $("button[id^=shareMenuOptions-" + ident.toString() + "]").off('click'); +// $("button[id^=shareMenuOptions-" + ident.toString() + "] i:first-child").hide(); + $("button[id^=announce-" + ident.toString() + "]").off('click'); +// $("button[id^=announce-" + ident.toString() + "] i:first-child").hide(); + if ($('img[id^=waitfor-' + verb + "-" + ident.toString() + "]").length == 0) { + rot.addClass("fa-share").appendTo($("button[id^=shareMenuOptions-" + ident.toString() + "] i:first-child" )).show(); + rot.removeClass("fa-share").addClass("fa-retweet").appendTo($("button[id^=announce-" + ident.toString() + "] i:first-child" )).show(); + } else { + $('img[id^=waitfor-' + verb + "-" + ident.toString() + "]").show() + } + } else { + $("button[id^=" + verb + "-" + ident.toString() + "]").off('click'); +// $("button[id^=" + verb + "-" + ident.toString() + "] i:first-child").hide(); + if ($('#waitfor-' + verb + "-" + ident.toString()).length == 0) { + rot.addClass("fa-thumbs-up").appendTo($("button[id^=" + verb + "-" + ident.toString() + "] i:first-child")).show(); + } else { + $('img[id^=waitfor-' + verb + "-" + ident.toString() + "]").show() + } + } $.post('item/' + ident.toString() + '/activity/' + _verb) .success( function(data){ + //$('#like-rotator-' + ident.toString()).hide(); + $("img[id^=waitfor-" + verb + "-" + ident.toString() + "]").hide(); if (data.status == "ok") { - $('#like-rotator-' + ident.toString()).hide(); - if (verb.indexOf("announce") === 0 ) { - if (data.verb == "un" + verb) { - $("button[id^=shareMenuOptions-" + ident.toString() + "]" ) - .removeClass("active") - .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + false + ")").change(); - $("button[id^=" + verb + "-" + ident.toString() + "]" ) - .removeClass("active") - .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + false + ")").change(); - } else { - $("button[id^=shareMenuOptions-" + ident.toString() + "]" ) - .addClass("active") - .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + true + ")").change(); - $("button[id^=" + verb + "-" + ident.toString() + "]" ) - .addClass("active") - .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + true + ")").change(); - } + if (verb.indexOf("announce") === 0 ) { + if (data.verb == "un" + verb) { + $("button[id^=shareMenuOptions-" + ident.toString() + "]" ) + .removeClass("active") + .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + false + ")").change(); + $("button[id^=" + verb + "-" + ident.toString() + "]" ) + .removeClass("active") + .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + false + ")").change(); } else { - if (data.verb == "un" + verb) { - $("button[id^=" + verb + "-" + ident.toString() + "]" ) - .removeClass("active") - .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + false + ")").change(); - } else { - $("button[id^=" + verb + "-" + ident.toString() + "]" ) - .addClass("active") - .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + true + ")").change(); - } - // $("button[id^=" + verb + "-" + ident.toString() + "]" ).button('refresh'); + $("button[id^=shareMenuOptions-" + ident.toString() + "]" ) + .addClass("active") + .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + true + ")").change(); + $("button[id^=" + verb + "-" + ident.toString() + "]" ) + .addClass("active") + .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + true + ")").change(); } + $("button[id^=shareMenuOptions-" + ident.toString() + "]").on('click'); + $("button[id^=shareMenuOptions-" + ident.toString() + "] i:first-child").show(); + } else { + if (data.verb == "un" + verb) { + $("button[id^=" + verb + "-" + ident.toString() + "]" ) + .removeClass("active") + .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + false + ")").change(); + } else { + $("button[id^=" + verb + "-" + ident.toString() + "]" ) + .addClass("active") + .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + true + ")").change(); + } + $("button[id^=" + verb + "-" + ident.toString() + "]").on('click'); + $("button[id^=" + verb + "-" + ident.toString() + "] i:first-child").show(); + } } else { - $.jGrowl("No connection to host for " + verb, {sticky: false, theme: 'info', life: 5000}); + $("button[id^=shareMenuOptions-" + ident.toString() + "]").on('click'); + $("button[id^=shareMenuOptions-" + ident.toString() + "] i:first-child").show(); + $("button[id^=" + verb + "-" + ident.toString() + "]").on('click'); + $("button[id^=" + verb + "-" + ident.toString() + "] i:first-child").show(); + $.jGrowl(verb + " not successful", {sticky: false, theme: 'info', life: 5000}); } }) - .error( - function(data){ - $.jGrowl("Activity " + verb + "unsuccessful", {sticky: false, theme: 'info', life: 5000}); - }); + .error( + function(data){ + //$('#like-rotator-' + ident.toString()).hide(); + $("img[id^=waitfor-" + verb + "-" + ident.toString() + "]").remove(); + $("button[id^=shareMenuOptions-" + ident.toString() + "]").on('click'); + $("button[id^=shareMenuOptions-" + ident.toString() + "] i:first-child").show(); + $("button[id^=" + verb + "-" + ident.toString() + "]").on('click'); + $("button[id^=" + verb + "-" + ident.toString() + "] i:first-child").show(); + $.jGrowl(verb + " not successful", {sticky: false, theme: 'info', life: 5000}); + }); } // Decodes a hexadecimally encoded binary string From 96c3321bb8ea6a0c392739dc6d2ec8b30523867b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Thu, 9 Mar 2023 14:55:43 +0100 Subject: [PATCH 05/21] improve optical feedback with rotator on buttons * functional rotator with feedback from ajax-request for activity on like, dislike, share and shareMenu button in wide-screen and media-screen --- view/theme/frio/js/theme.js | 149 +++++++++++++++++++++--------------- 1 file changed, 87 insertions(+), 62 deletions(-) diff --git a/view/theme/frio/js/theme.js b/view/theme/frio/js/theme.js index 221288a16..ba3831aa9 100644 --- a/view/theme/frio/js/theme.js +++ b/view/theme/frio/js/theme.js @@ -765,84 +765,109 @@ function htmlToText(htmlString) { */ function doActivityItemAction(ident, verb, un) { _verb = un ? 'un' + verb : verb; - var rot = $('') - .attr('src', 'images/rotator.gif') - .addClass("fa"); + var thumbsClass = ''; + switch (verb) { + case 'like': + thumbsClass = 'fa-thumbs-up'; + break; + case 'dislike': + thumbsClass = 'fa-thumbs-down'; + break; + case 'announce': + thumbsClass = 'fa-retweet'; + } + // remindert to remove the like-rotator from templates //$('#like-rotator-' + ident.toString()).show(); - if (verb.indexOf("announce") === 0 ) { - $("button[id^=shareMenuOptions-" + ident.toString() + "]").off('click'); -// $("button[id^=shareMenuOptions-" + ident.toString() + "] i:first-child").hide(); - $("button[id^=announce-" + ident.toString() + "]").off('click'); -// $("button[id^=announce-" + ident.toString() + "] i:first-child").hide(); - if ($('img[id^=waitfor-' + verb + "-" + ident.toString() + "]").length == 0) { - rot.addClass("fa-share").appendTo($("button[id^=shareMenuOptions-" + ident.toString() + "] i:first-child" )).show(); - rot.removeClass("fa-share").addClass("fa-retweet").appendTo($("button[id^=announce-" + ident.toString() + "] i:first-child" )).show(); + if (verb.indexOf('announce') === 0 ) { + // Share-Button(s) + // remove share-symbol, to replace it by rotator + $('button[id^=shareMenuOptions-' + ident.toString() + '] i:first-child').removeClass('fa-share'); + $('button[id^=announce-' + ident.toString() + '] i:first-child').removeClass('fa-retweet'); + // if no wait-rotator for activity(verb) is added, add it. or just show it, if exists + if ($('img[id^=waitfor-' + verb + '-' + ident.toString() + ']').length == 0) { + // append rotator to the shareMenu-button for small media + $('') + .attr('src', 'images/rotator.gif') + .addClass('fa') + .appendTo($('button[id^=shareMenuOptions-' + ident.toString() + '] i:first-child' )).show(); } else { - $('img[id^=waitfor-' + verb + "-" + ident.toString() + "]").show() - } - } else { - $("button[id^=" + verb + "-" + ident.toString() + "]").off('click'); -// $("button[id^=" + verb + "-" + ident.toString() + "] i:first-child").hide(); - if ($('#waitfor-' + verb + "-" + ident.toString()).length == 0) { - rot.addClass("fa-thumbs-up").appendTo($("button[id^=" + verb + "-" + ident.toString() + "] i:first-child")).show(); - } else { - $('img[id^=waitfor-' + verb + "-" + ident.toString() + "]").show() + $('img[id^=waitfor-' + verb + '-' + ident.toString() + ']').show() } } + $('button[id^=' + verb + '-' + ident.toString() + '] i:first-child').removeClass(thumbsClass); + // if verb is announce, then one rotator is added above to the shareMedia-dropdown button + if ($('button:not(button.dropdown-toggle) img#waitfor-' + verb + '-' + ident.toString()).length == 0) { + $('') + .attr('src', 'images/rotator.gif') + .addClass('fa') + .appendTo($('button[id^=' + verb + '-' + ident.toString() + '] i:first-child')).show(); + } else { + // show existing rotator for activity + $('img[id^=waitfor-' + verb + '-' + ident.toString() + ']').show() + } + + // do request for activity $.post('item/' + ident.toString() + '/activity/' + _verb) .success( function(data){ //$('#like-rotator-' + ident.toString()).hide(); - $("img[id^=waitfor-" + verb + "-" + ident.toString() + "]").hide(); - if (data.status == "ok") { - if (verb.indexOf("announce") === 0 ) { - if (data.verb == "un" + verb) { - $("button[id^=shareMenuOptions-" + ident.toString() + "]" ) - .removeClass("active") - .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + false + ")").change(); - $("button[id^=" + verb + "-" + ident.toString() + "]" ) - .removeClass("active") - .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + false + ")").change(); - } else { - $("button[id^=shareMenuOptions-" + ident.toString() + "]" ) - .addClass("active") - .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + true + ")").change(); - $("button[id^=" + verb + "-" + ident.toString() + "]" ) - .addClass("active") - .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + true + ")").change(); - } - $("button[id^=shareMenuOptions-" + ident.toString() + "]").on('click'); - $("button[id^=shareMenuOptions-" + ident.toString() + "] i:first-child").show(); + $('img[id^=waitfor-' + verb + '-' + ident.toString() + ']').remove(); + if (data.status == 'ok') { + // response from server was ok + if (data.verb == 'un' + verb) { + // like/dislike buttons + $('button[id^=' + verb + '-' + ident.toString() + ']' ) + .removeClass('active') + .attr('onclick', 'doActivityItemAction(' + ident +', "' + verb + '",false )').change(); + // link in share-menu + $('a[id^=' + verb + '-' + ident.toString() + ']' ) + .removeClass('active') + .attr('href', 'javascript:doActivityItemAction(' + ident +', "' + verb + '",false )').change(); + $('a[id^=' + verb + '-' + ident.toString() + '] i:first-child' ).addClass('fa-retweet').removeClass('fa-ban'); } else { - if (data.verb == "un" + verb) { - $("button[id^=" + verb + "-" + ident.toString() + "]" ) - .removeClass("active") - .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + false + ")").change(); - } else { - $("button[id^=" + verb + "-" + ident.toString() + "]" ) - .addClass("active") - .attr("onclick", "doActivityItemAction(" + ident +", '" + verb + "', " + true + ")").change(); - } - $("button[id^=" + verb + "-" + ident.toString() + "]").on('click'); - $("button[id^=" + verb + "-" + ident.toString() + "] i:first-child").show(); + // like/dislike buttons + $('button[id^=' + verb + '-' + ident.toString() + ']' ) + .addClass('active') + .attr('onclick', 'doActivityItemAction(' + ident + ', "' + verb + '", true )').change(); + // link in share-menu + $('a[id^=' + verb + '-' + ident.toString() + ']' ) + .addClass('active') + .attr('href', 'javascript:doActivityItemAction(' + ident + ', "' + verb + '", true )').change(); + $('a[id^=' + verb + '-' + ident.toString() + '] i:first-child' ).removeClass('fa-retweet').addClass('fa-ban'); } + $('button[id^=' + verb + '-' + ident.toString() + '] i:first-child').addClass(thumbsClass).show(); + if (verb.indexOf('announce') === 0 ) { + // ShareMenuButton + $('button[id^=shareMenuOptions-' + ident.toString() + '] i:first-child').addClass('fa-share'); + if (data.verb == 'un' + verb) { + $('button[id^=shareMenuOptions-' + ident.toString() + ']').removeClass('active'); + } else { + $('button[id^=shareMenuOptions-' + ident.toString() + ']').addClass('active'); + } + + } } else { - $("button[id^=shareMenuOptions-" + ident.toString() + "]").on('click'); - $("button[id^=shareMenuOptions-" + ident.toString() + "] i:first-child").show(); - $("button[id^=" + verb + "-" + ident.toString() + "]").on('click'); - $("button[id^=" + verb + "-" + ident.toString() + "] i:first-child").show(); - $.jGrowl(verb + " not successful", {sticky: false, theme: 'info', life: 5000}); + /* server-response was not ok. Database-problems or some changes in + * data? + * reset all buttons + */ + $('img[id^=waitfor-' + verb + '-' + ident.toString() + ']').remove(); + $('button[id^=shareMenuOptions-' + ident.toString() + '] i:first-child').addClass('fa-share'); + $('button[id^=' + verb + '-' + ident.toString() + '] i:first-child').addClass(thumbsClass); + $('a[id^=' + verb + '-' + ident.toString() + '] i:first-child').addClass(thumbsClass); + $.jGrowl(verb + ' not successful (server error)', {sticky: false, theme: 'info', life: 5000}); } }) .error( function(data){ + /* Server could not be reaches successfully */ + // remindert to remove the like-rotator from templates //$('#like-rotator-' + ident.toString()).hide(); - $("img[id^=waitfor-" + verb + "-" + ident.toString() + "]").remove(); - $("button[id^=shareMenuOptions-" + ident.toString() + "]").on('click'); - $("button[id^=shareMenuOptions-" + ident.toString() + "] i:first-child").show(); - $("button[id^=" + verb + "-" + ident.toString() + "]").on('click'); - $("button[id^=" + verb + "-" + ident.toString() + "] i:first-child").show(); - $.jGrowl(verb + " not successful", {sticky: false, theme: 'info', life: 5000}); + $('img[id^=waitfor-' + verb + '-' + ident.toString() + ']').remove(); + $('button[id^=shareMenuOptions-' + ident.toString() + '] i:first-child').addClass('fa-share'); + $('button[id^=' + verb + '-' + ident.toString() + '] i:first-child').addClass(thumbsClass); + $('a[id^=' + verb + '-' + ident.toString() + '] i:first-child').addClass(thumbsClass); + $.jGrowl(verb + ' not successful (network error)', {sticky: false, theme: 'info', life: 5000}); }); } From 221997878868afd1ab635ed569f193f085a95100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Thu, 9 Mar 2023 17:43:14 +0100 Subject: [PATCH 06/21] reduce indentation --- view/theme/frio/js/theme.js | 115 ++++++++++++++++++------------------ 1 file changed, 56 insertions(+), 59 deletions(-) diff --git a/view/theme/frio/js/theme.js b/view/theme/frio/js/theme.js index ba3831aa9..f40c8d306 100644 --- a/view/theme/frio/js/theme.js +++ b/view/theme/frio/js/theme.js @@ -808,67 +808,64 @@ function doActivityItemAction(ident, verb, un) { // do request for activity $.post('item/' + ident.toString() + '/activity/' + _verb) - .success( - function(data){ + .success(function(data){ + //$('#like-rotator-' + ident.toString()).hide(); + $('img[id^=waitfor-' + verb + '-' + ident.toString() + ']').remove(); + if (data.status == 'ok') { + // response from server was ok + if (data.verb == 'un' + verb) { + // like/dislike buttons + $('button[id^=' + verb + '-' + ident.toString() + ']' ) + .removeClass('active') + .attr('onclick', 'doActivityItemAction(' + ident +', "' + verb + '",false )').change(); + // link in share-menu + $('a[id^=' + verb + '-' + ident.toString() + ']' ) + .removeClass('active') + .attr('href', 'javascript:doActivityItemAction(' + ident +', "' + verb + '",false )').change(); + $('a[id^=' + verb + '-' + ident.toString() + '] i:first-child' ).addClass('fa-retweet').removeClass('fa-ban'); + } else { + // like/dislike buttons + $('button[id^=' + verb + '-' + ident.toString() + ']' ) + .addClass('active') + .attr('onclick', 'doActivityItemAction(' + ident + ', "' + verb + '", true )').change(); + // link in share-menu + $('a[id^=' + verb + '-' + ident.toString() + ']' ) + .addClass('active') + .attr('href', 'javascript:doActivityItemAction(' + ident + ', "' + verb + '", true )').change(); + $('a[id^=' + verb + '-' + ident.toString() + '] i:first-child' ).removeClass('fa-retweet').addClass('fa-ban'); + } + $('button[id^=' + verb + '-' + ident.toString() + '] i:first-child').addClass(thumbsClass).show(); + if (verb.indexOf('announce') === 0 ) { + // ShareMenuButton + $('button[id^=shareMenuOptions-' + ident.toString() + '] i:first-child').addClass('fa-share'); + if (data.verb == 'un' + verb) { + $('button[id^=shareMenuOptions-' + ident.toString() + ']').removeClass('active'); + } else { + $('button[id^=shareMenuOptions-' + ident.toString() + ']').addClass('active'); + } + } + } else { + /* server-response was not ok. Database-problems or some changes in + * data? + * reset all buttons + */ + $('img[id^=waitfor-' + verb + '-' + ident.toString() + ']').remove(); + $('button[id^=shareMenuOptions-' + ident.toString() + '] i:first-child').addClass('fa-share'); + $('button[id^=' + verb + '-' + ident.toString() + '] i:first-child').addClass(thumbsClass); + $('a[id^=' + verb + '-' + ident.toString() + '] i:first-child').addClass(thumbsClass); + $.jGrowl(verb + ' not successful (server error)', {sticky: false, theme: 'info', life: 5000}); + } + }) + .error(function(data){ + /* Server could not be reaches successfully */ + // remindert to remove the like-rotator from templates //$('#like-rotator-' + ident.toString()).hide(); $('img[id^=waitfor-' + verb + '-' + ident.toString() + ']').remove(); - if (data.status == 'ok') { - // response from server was ok - if (data.verb == 'un' + verb) { - // like/dislike buttons - $('button[id^=' + verb + '-' + ident.toString() + ']' ) - .removeClass('active') - .attr('onclick', 'doActivityItemAction(' + ident +', "' + verb + '",false )').change(); - // link in share-menu - $('a[id^=' + verb + '-' + ident.toString() + ']' ) - .removeClass('active') - .attr('href', 'javascript:doActivityItemAction(' + ident +', "' + verb + '",false )').change(); - $('a[id^=' + verb + '-' + ident.toString() + '] i:first-child' ).addClass('fa-retweet').removeClass('fa-ban'); - } else { - // like/dislike buttons - $('button[id^=' + verb + '-' + ident.toString() + ']' ) - .addClass('active') - .attr('onclick', 'doActivityItemAction(' + ident + ', "' + verb + '", true )').change(); - // link in share-menu - $('a[id^=' + verb + '-' + ident.toString() + ']' ) - .addClass('active') - .attr('href', 'javascript:doActivityItemAction(' + ident + ', "' + verb + '", true )').change(); - $('a[id^=' + verb + '-' + ident.toString() + '] i:first-child' ).removeClass('fa-retweet').addClass('fa-ban'); - } - $('button[id^=' + verb + '-' + ident.toString() + '] i:first-child').addClass(thumbsClass).show(); - if (verb.indexOf('announce') === 0 ) { - // ShareMenuButton - $('button[id^=shareMenuOptions-' + ident.toString() + '] i:first-child').addClass('fa-share'); - if (data.verb == 'un' + verb) { - $('button[id^=shareMenuOptions-' + ident.toString() + ']').removeClass('active'); - } else { - $('button[id^=shareMenuOptions-' + ident.toString() + ']').addClass('active'); - } - - } - } else { - /* server-response was not ok. Database-problems or some changes in - * data? - * reset all buttons - */ - $('img[id^=waitfor-' + verb + '-' + ident.toString() + ']').remove(); - $('button[id^=shareMenuOptions-' + ident.toString() + '] i:first-child').addClass('fa-share'); - $('button[id^=' + verb + '-' + ident.toString() + '] i:first-child').addClass(thumbsClass); - $('a[id^=' + verb + '-' + ident.toString() + '] i:first-child').addClass(thumbsClass); - $.jGrowl(verb + ' not successful (server error)', {sticky: false, theme: 'info', life: 5000}); - } - }) - .error( - function(data){ - /* Server could not be reaches successfully */ - // remindert to remove the like-rotator from templates - //$('#like-rotator-' + ident.toString()).hide(); - $('img[id^=waitfor-' + verb + '-' + ident.toString() + ']').remove(); - $('button[id^=shareMenuOptions-' + ident.toString() + '] i:first-child').addClass('fa-share'); - $('button[id^=' + verb + '-' + ident.toString() + '] i:first-child').addClass(thumbsClass); - $('a[id^=' + verb + '-' + ident.toString() + '] i:first-child').addClass(thumbsClass); - $.jGrowl(verb + ' not successful (network error)', {sticky: false, theme: 'info', life: 5000}); - }); + $('button[id^=shareMenuOptions-' + ident.toString() + '] i:first-child').addClass('fa-share'); + $('button[id^=' + verb + '-' + ident.toString() + '] i:first-child').addClass(thumbsClass); + $('a[id^=' + verb + '-' + ident.toString() + '] i:first-child').addClass(thumbsClass); + $.jGrowl(verb + ' not successful (network error)', {sticky: false, theme: 'info', life: 5000}); + }); } // Decodes a hexadecimally encoded binary string From 4885841c16437ed65e8004ef09a92c53575a0b05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Thu, 9 Mar 2023 21:01:32 +0100 Subject: [PATCH 07/21] add personal README --- README-jakob.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 README-jakob.md diff --git a/README-jakob.md b/README-jakob.md new file mode 100644 index 000000000..77363f2fb --- /dev/null +++ b/README-jakob.md @@ -0,0 +1,9 @@ +# Anleitung für die Erweiterungen + +Ich habe ein paar Verbesserungen an Friendica vorgenommen, die mich schon lange gestört haben. + +## Activity-Buttons + +Liken und Sharen führt im Standard-UI von Friendica oft dazu, dass die Timeline irgendwo hin hüpft, und man findet den soeben gelikten Beitrag oder Kommentar nicht mehr. +Meine Änderungen führen ein Live-Update am Server aus, mit einer optischen Rückmeldung auf dem Button, der geklickt wurde, der nach erfolgreichem Request dann seinen Status ändert. Sonst eben nicht. +Es wird nur dieser eine Button aktualisiert. Damit gibt es kein Hüpfen der Timeline mehr, aber auch kein Unterbrechen eines Videos, das man sich ansieht und zwischendrin mal liken möchte. From 82e8b5b76d5ad63b46a14f83b874a1deea7c9fdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Sat, 11 Mar 2023 01:57:14 +0100 Subject: [PATCH 08/21] update README --- README-jakob.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README-jakob.md b/README-jakob.md index 77363f2fb..edb895618 100644 --- a/README-jakob.md +++ b/README-jakob.md @@ -7,3 +7,5 @@ Ich habe ein paar Verbesserungen an Friendica vorgenommen, die mich schon lange Liken und Sharen führt im Standard-UI von Friendica oft dazu, dass die Timeline irgendwo hin hüpft, und man findet den soeben gelikten Beitrag oder Kommentar nicht mehr. Meine Änderungen führen ein Live-Update am Server aus, mit einer optischen Rückmeldung auf dem Button, der geklickt wurde, der nach erfolgreichem Request dann seinen Status ändert. Sonst eben nicht. Es wird nur dieser eine Button aktualisiert. Damit gibt es kein Hüpfen der Timeline mehr, aber auch kein Unterbrechen eines Videos, das man sich ansieht und zwischendrin mal liken möchte. + +Diese Änderung betrifft das gesamte Frio-Theme From 225e2124cc3a325b4188b8569a0a479fabf83987 Mon Sep 17 00:00:00 2001 From: xundeenergie Date: Sat, 11 Mar 2023 13:11:48 +0100 Subject: [PATCH 09/21] Update view/theme/frio/js/theme.js in this case, the img[id^=waitfor... .show() shows existing image-containers. All of them which exist. Because there can be more than one. And this filter just shows them. adding another rotator with your suggestion can lead to 2 or more rotators on a button. Co-authored-by: Hypolite Petovan --- view/theme/frio/js/theme.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/theme/frio/js/theme.js b/view/theme/frio/js/theme.js index f40c8d306..a1501f138 100644 --- a/view/theme/frio/js/theme.js +++ b/view/theme/frio/js/theme.js @@ -791,7 +791,7 @@ function doActivityItemAction(ident, verb, un) { .addClass('fa') .appendTo($('button[id^=shareMenuOptions-' + ident.toString() + '] i:first-child' )).show(); } else { - $('img[id^=waitfor-' + verb + '-' + ident.toString() + ']').show() + $('').attr({id: 'waitfor-' + verb + '-' + ident.toString(), src: 'images/rotator.gif'}) } } $('button[id^=' + verb + '-' + ident.toString() + '] i:first-child').removeClass(thumbsClass); From bd2cd8dd4cbfcb9035fb209ef00388c730d050e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Sat, 11 Mar 2023 13:14:30 +0100 Subject: [PATCH 10/21] remove reminder for deleting rotators in tpl --- view/theme/frio/js/theme.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/view/theme/frio/js/theme.js b/view/theme/frio/js/theme.js index a1501f138..4d14df572 100644 --- a/view/theme/frio/js/theme.js +++ b/view/theme/frio/js/theme.js @@ -776,8 +776,6 @@ function doActivityItemAction(ident, verb, un) { case 'announce': thumbsClass = 'fa-retweet'; } - // remindert to remove the like-rotator from templates - //$('#like-rotator-' + ident.toString()).show(); if (verb.indexOf('announce') === 0 ) { // Share-Button(s) // remove share-symbol, to replace it by rotator @@ -858,8 +856,6 @@ function doActivityItemAction(ident, verb, un) { }) .error(function(data){ /* Server could not be reaches successfully */ - // remindert to remove the like-rotator from templates - //$('#like-rotator-' + ident.toString()).hide(); $('img[id^=waitfor-' + verb + '-' + ident.toString() + ']').remove(); $('button[id^=shareMenuOptions-' + ident.toString() + '] i:first-child').addClass('fa-share'); $('button[id^=' + verb + '-' + ident.toString() + '] i:first-child').addClass(thumbsClass); From 7daecf67417ca1f024ffa326f2a364c5558de9e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Sat, 11 Mar 2023 13:15:24 +0100 Subject: [PATCH 11/21] remove rotator from templates --- view/theme/frio/templates/like_noshare.tpl | 1 - view/theme/frio/templates/wall_thread.tpl | 154 ++++++++++----------- 2 files changed, 74 insertions(+), 81 deletions(-) diff --git a/view/theme/frio/templates/like_noshare.tpl b/view/theme/frio/templates/like_noshare.tpl index 83e7b4a98..3514d79e7 100644 --- a/view/theme/frio/templates/like_noshare.tpl +++ b/view/theme/frio/templates/like_noshare.tpl @@ -16,5 +16,4 @@  {{$dislike}} {{/if}} - diff --git a/view/theme/frio/templates/wall_thread.tpl b/view/theme/frio/templates/wall_thread.tpl index 7e77e5052..b58644a26 100644 --- a/view/theme/frio/templates/wall_thread.tpl +++ b/view/theme/frio/templates/wall_thread.tpl @@ -280,7 +280,7 @@ as the value of $top_child_total (this is done at the end of this file)
{{* Action buttons to interact with the item (like: like, dislike, share and so on *}} -
{{/if}} From f8018f8dfe0183ce7c8f7e8460e0d9fbd5b9395b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Sat, 11 Mar 2023 19:23:48 +0100 Subject: [PATCH 14/21] make errormessages modular and better --- src/App/Page.php | 11 +++++------ view/theme/frio/js/theme.js | 5 +++-- view/theme/frio/templates/js_strings.tpl | 15 +++++++-------- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/App/Page.php b/src/App/Page.php index c2a77b325..965c04915 100644 --- a/src/App/Page.php +++ b/src/App/Page.php @@ -253,12 +253,11 @@ class Page implements ArrayAccess '$touch_icon' => $touch_icon, '$block_public' => intval($config->get('system', 'block_public')), '$stylesheets' => $this->stylesheets, - '$likeNetError' => $l10n->t('Like not successfull (Network error)'), - '$dislikeNetError' => $l10n->t('Dislike not successfull (Network error)'), - '$annonNetError' => $l10n->t('Sharing not successfull (Network error)'), - '$likeSrvError' => $l10n->t('Like not successfull (Backend error)'), - '$dislikeSrvError' => $l10n->t('Dislike not successfull (Backend error)'), - '$annonSrvError' => $l10n->t('Sharing not successfull (Backend error)'), + '$likeError' => $l10n->t('Like not successfull'), + '$dislikeError' => $l10n->t('Dislike not successfull'), + '$announceError' => $l10n->t('Sharing not successfull'), + '$srvError' => $l10n->t('Backend error'), + '$netError' => $l10n->t('Network error'), ]) . $this->page['htmlhead']; } diff --git a/view/theme/frio/js/theme.js b/view/theme/frio/js/theme.js index f6d681203..a94bd560b 100644 --- a/view/theme/frio/js/theme.js +++ b/view/theme/frio/js/theme.js @@ -851,7 +851,8 @@ function doActivityItemAction(ident, verb, un) { $('button[id^=shareMenuOptions-' + ident.toString() + '] i:first-child').addClass('fa-share'); $('button[id^=' + verb + '-' + ident.toString() + '] i:first-child').addClass(thumbsClass); $('a[id^=' + verb + '-' + ident.toString() + '] i:first-child').addClass(thumbsClass); - $.jGrowl(aActSrvErr[verb], {sticky: false, theme: 'info', life: 5000}); + $('a[id^=' + verb + '-' + ident.toString() + '] i:first-child').addClass(thumbsClass); + $.jGrowl(aActErr[verb] + '
(' + aErrType['srvErr'] + ')', {sticky: false, theme: 'info', life: 5000}); } }) .error(function(data){ @@ -860,7 +861,7 @@ function doActivityItemAction(ident, verb, un) { $('button[id^=shareMenuOptions-' + ident.toString() + '] i:first-child').addClass('fa-share'); $('button[id^=' + verb + '-' + ident.toString() + '] i:first-child').addClass(thumbsClass); $('a[id^=' + verb + '-' + ident.toString() + '] i:first-child').addClass(thumbsClass); - $.jGrowl(aActNetErr[verb], {sticky: false, theme: 'info', life: 5000}); + $.jGrowl(aActErr[verb] + '
(' + aErrType['netErr'] + ')', {sticky: false, theme: 'info', life: 5000}); }); } diff --git a/view/theme/frio/templates/js_strings.tpl b/view/theme/frio/templates/js_strings.tpl index 540009c82..39445a0ac 100644 --- a/view/theme/frio/templates/js_strings.tpl +++ b/view/theme/frio/templates/js_strings.tpl @@ -10,14 +10,13 @@ They are loaded into the html so that js functions can use them *}} 'blockAuthor' : "{{$blockAuthor|escape:'javascript' nofilter}}", 'ignoreAuthor' : "{{$ignoreAuthor|escape:'javascript' nofilter}}", }; - var aActNetErr = { - 'like' : "{{$likeNetError}}", - 'dislike' : "{{$dislikeNetError}}", - 'announce' : "{{$annonNetError}}", + var aActErr = { + 'like' : "{{$likeError}}", + 'dislike' : "{{$dislikeError}}", + 'announce' : "{{$announceError}}", }; - var aActSrvErr = { - 'like' : "{{$likeSrvError}}", - 'dislike' : "{{$dislikeSrvError}}", - 'announce' : "{{$annonSrvError}}", + var aErrType = { + 'srvErr' : "{{$srvError}}", + 'netErr' : "{{$netError}}", }; From c94b586543756a610568b981f96e79b79c3e2aac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Mon, 13 Mar 2023 07:44:08 +0100 Subject: [PATCH 15/21] reduce literal html in javascript-code --- view/theme/frio/js/theme.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/view/theme/frio/js/theme.js b/view/theme/frio/js/theme.js index a94bd560b..0916552f2 100644 --- a/view/theme/frio/js/theme.js +++ b/view/theme/frio/js/theme.js @@ -784,8 +784,8 @@ function doActivityItemAction(ident, verb, un) { // if no wait-rotator for activity(verb) is added, add it. or just show it, if exists if ($('img[id^=waitfor-' + verb + '-' + ident.toString() + ']').length == 0) { // append rotator to the shareMenu-button for small media - $('') - .attr('src', 'images/rotator.gif') + $('') + .attr('id', 'waitfor-' + verb + '-' + ident.toString()) .addClass('fa') .appendTo($('button[id^=shareMenuOptions-' + ident.toString() + '] i:first-child' )).show(); } else { @@ -795,7 +795,8 @@ function doActivityItemAction(ident, verb, un) { $('button[id^=' + verb + '-' + ident.toString() + '] i:first-child').removeClass(thumbsClass); // if verb is announce, then one rotator is added above to the shareMedia-dropdown button if ($('button:not(button.dropdown-toggle) img#waitfor-' + verb + '-' + ident.toString()).length == 0) { - $('') + $('') + .attr('id', 'waitfor-' + verb + '-' + ident.toString()) .attr('src', 'images/rotator.gif') .addClass('fa') .appendTo($('button[id^=' + verb + '-' + ident.toString() + '] i:first-child')).show(); From d6fc00c7431551250ceff84032c6bfb0df636358 Mon Sep 17 00:00:00 2001 From: xundeenergie Date: Mon, 13 Mar 2023 14:31:13 +0100 Subject: [PATCH 16/21] Update view/theme/frio/js/theme.js removed it. Co-authored-by: Hypolite Petovan --- view/theme/frio/js/theme.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/view/theme/frio/js/theme.js b/view/theme/frio/js/theme.js index 0916552f2..06d3d3fda 100644 --- a/view/theme/frio/js/theme.js +++ b/view/theme/frio/js/theme.js @@ -820,7 +820,8 @@ function doActivityItemAction(ident, verb, un) { // link in share-menu $('a[id^=' + verb + '-' + ident.toString() + ']' ) .removeClass('active') - .attr('href', 'javascript:doActivityItemAction(' + ident +', "' + verb + '",false )').change(); + .attr('href', 'javascript:doActivityItemAction(' + ident +', "' + verb + '",false )') + .change(); $('a[id^=' + verb + '-' + ident.toString() + '] i:first-child' ).addClass('fa-retweet').removeClass('fa-ban'); } else { // like/dislike buttons From 0dffe65d646438a555f818b9bc2244c06df37312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Mon, 13 Mar 2023 14:38:44 +0100 Subject: [PATCH 17/21] fix indetation and removed some calls. --- view/theme/frio/js/theme.js | 38 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/view/theme/frio/js/theme.js b/view/theme/frio/js/theme.js index 06d3d3fda..d1ec22c5b 100644 --- a/view/theme/frio/js/theme.js +++ b/view/theme/frio/js/theme.js @@ -784,10 +784,10 @@ function doActivityItemAction(ident, verb, un) { // if no wait-rotator for activity(verb) is added, add it. or just show it, if exists if ($('img[id^=waitfor-' + verb + '-' + ident.toString() + ']').length == 0) { // append rotator to the shareMenu-button for small media - $('') - .attr('id', 'waitfor-' + verb + '-' + ident.toString()) + $('') + .attr({id: 'waitfor-' + verb + '-' + ident.toString(), src: 'images/rotator.gif'}) .addClass('fa') - .appendTo($('button[id^=shareMenuOptions-' + ident.toString() + '] i:first-child' )).show(); + .appendTo($('button[id^=shareMenuOptions-' + ident.toString() + '] i:first-child' )); } else { $('').attr({id: 'waitfor-' + verb + '-' + ident.toString(), src: 'images/rotator.gif'}) } @@ -796,19 +796,17 @@ function doActivityItemAction(ident, verb, un) { // if verb is announce, then one rotator is added above to the shareMedia-dropdown button if ($('button:not(button.dropdown-toggle) img#waitfor-' + verb + '-' + ident.toString()).length == 0) { $('') - .attr('id', 'waitfor-' + verb + '-' + ident.toString()) - .attr('src', 'images/rotator.gif') + .attr({id: 'waitfor-' + verb + '-' + ident.toString(), src: 'images/rotator.gif'}) .addClass('fa') - .appendTo($('button[id^=' + verb + '-' + ident.toString() + '] i:first-child')).show(); + .appendTo($('button[id^=' + verb + '-' + ident.toString() + '] i:first-child')); } else { // show existing rotator for activity - $('img[id^=waitfor-' + verb + '-' + ident.toString() + ']').show() + $('img[id^=waitfor-' + verb + '-' + ident.toString() + ']') } // do request for activity $.post('item/' + ident.toString() + '/activity/' + _verb) .success(function(data){ - //$('#like-rotator-' + ident.toString()).hide(); $('img[id^=waitfor-' + verb + '-' + ident.toString() + ']').remove(); if (data.status == 'ok') { // response from server was ok @@ -816,22 +814,21 @@ function doActivityItemAction(ident, verb, un) { // like/dislike buttons $('button[id^=' + verb + '-' + ident.toString() + ']' ) .removeClass('active') - .attr('onclick', 'doActivityItemAction(' + ident +', "' + verb + '",false )').change(); + .attr('onclick', 'doActivityItemAction(' + ident +', "' + verb + '",false )'); // link in share-menu $('a[id^=' + verb + '-' + ident.toString() + ']' ) .removeClass('active') - .attr('href', 'javascript:doActivityItemAction(' + ident +', "' + verb + '",false )') - .change(); + .attr('href', 'javascript:doActivityItemAction(' + ident +', "' + verb + '",false )'); $('a[id^=' + verb + '-' + ident.toString() + '] i:first-child' ).addClass('fa-retweet').removeClass('fa-ban'); } else { // like/dislike buttons $('button[id^=' + verb + '-' + ident.toString() + ']' ) .addClass('active') - .attr('onclick', 'doActivityItemAction(' + ident + ', "' + verb + '", true )').change(); + .attr('onclick', 'doActivityItemAction(' + ident + ', "' + verb + '", true )'); // link in share-menu $('a[id^=' + verb + '-' + ident.toString() + ']' ) .addClass('active') - .attr('href', 'javascript:doActivityItemAction(' + ident + ', "' + verb + '", true )').change(); + .attr('href', 'javascript:doActivityItemAction(' + ident + ', "' + verb + '", true )'); $('a[id^=' + verb + '-' + ident.toString() + '] i:first-child' ).removeClass('fa-retweet').addClass('fa-ban'); } $('button[id^=' + verb + '-' + ident.toString() + '] i:first-child').addClass(thumbsClass).show(); @@ -853,17 +850,16 @@ function doActivityItemAction(ident, verb, un) { $('button[id^=shareMenuOptions-' + ident.toString() + '] i:first-child').addClass('fa-share'); $('button[id^=' + verb + '-' + ident.toString() + '] i:first-child').addClass(thumbsClass); $('a[id^=' + verb + '-' + ident.toString() + '] i:first-child').addClass(thumbsClass); - $('a[id^=' + verb + '-' + ident.toString() + '] i:first-child').addClass(thumbsClass); - $.jGrowl(aActErr[verb] + '
(' + aErrType['srvErr'] + ')', {sticky: false, theme: 'info', life: 5000}); + $.jGrowl(aActErr[verb] + '
(' + aErrType['srvErr'] + ')', {sticky: false, theme: 'info', life: 5000}); } }) .error(function(data){ - /* Server could not be reaches successfully */ - $('img[id^=waitfor-' + verb + '-' + ident.toString() + ']').remove(); - $('button[id^=shareMenuOptions-' + ident.toString() + '] i:first-child').addClass('fa-share'); - $('button[id^=' + verb + '-' + ident.toString() + '] i:first-child').addClass(thumbsClass); - $('a[id^=' + verb + '-' + ident.toString() + '] i:first-child').addClass(thumbsClass); - $.jGrowl(aActErr[verb] + '
(' + aErrType['netErr'] + ')', {sticky: false, theme: 'info', life: 5000}); + // Server could not be reached successfully + $('img[id^=waitfor-' + verb + '-' + ident.toString() + ']').remove(); + $('button[id^=shareMenuOptions-' + ident.toString() + '] i:first-child').addClass('fa-share'); + $('button[id^=' + verb + '-' + ident.toString() + '] i:first-child').addClass(thumbsClass); + $('a[id^=' + verb + '-' + ident.toString() + '] i:first-child').addClass(thumbsClass); + $.jGrowl(aActErr[verb] + '
(' + aErrType['netErr'] + ')', {sticky: false, theme: 'info', life: 5000}); }); } From e2625592b70aa0c6c9927447516db01e51c4f215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Mon, 13 Mar 2023 14:30:19 +0100 Subject: [PATCH 18/21] update translation-files --- view/lang/C/messages.po | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/view/lang/C/messages.po b/view/lang/C/messages.po index 52888018b..3c45d3670 100644 --- a/view/lang/C/messages.po +++ b/view/lang/C/messages.po @@ -673,7 +673,27 @@ msgid "" "notifications." msgstr "" -#: src/App/Page.php:320 +#: src/App/Page.php:256 +msgid "Like not successfull" +msgstr "" + +#: src/App/Page.php:257 +msgid "Dislike not successfull" +msgstr "" + +#: src/App/Page.php:258 +msgid "Sharing not successfull" +msgstr "" + +#: src/App/Page.php:259 +msgid "Backend error" +msgstr "" + +#: src/App/Page.php:260 +msgid "Network error" +msgstr "" + +#: src/App/Page.php:325 msgid "toggle mobile" msgstr "" From c540b9275ce5800ef480df97b6d68f49d856072a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Tue, 14 Mar 2023 13:07:02 +0100 Subject: [PATCH 19/21] remove own readme --- README-jakob.md | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 README-jakob.md diff --git a/README-jakob.md b/README-jakob.md deleted file mode 100644 index edb895618..000000000 --- a/README-jakob.md +++ /dev/null @@ -1,11 +0,0 @@ -# Anleitung für die Erweiterungen - -Ich habe ein paar Verbesserungen an Friendica vorgenommen, die mich schon lange gestört haben. - -## Activity-Buttons - -Liken und Sharen führt im Standard-UI von Friendica oft dazu, dass die Timeline irgendwo hin hüpft, und man findet den soeben gelikten Beitrag oder Kommentar nicht mehr. -Meine Änderungen führen ein Live-Update am Server aus, mit einer optischen Rückmeldung auf dem Button, der geklickt wurde, der nach erfolgreichem Request dann seinen Status ändert. Sonst eben nicht. -Es wird nur dieser eine Button aktualisiert. Damit gibt es kein Hüpfen der Timeline mehr, aber auch kein Unterbrechen eines Videos, das man sich ansieht und zwischendrin mal liken möchte. - -Diese Änderung betrifft das gesamte Frio-Theme From f5f2076a2d5ec4d8229f168a9a3f66dc2d0bde6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Tue, 14 Mar 2023 16:55:10 +0100 Subject: [PATCH 20/21] remove unused selector was there for historical reasons... :/ --- view/theme/frio/js/theme.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/view/theme/frio/js/theme.js b/view/theme/frio/js/theme.js index d1ec22c5b..3ae76dbf5 100644 --- a/view/theme/frio/js/theme.js +++ b/view/theme/frio/js/theme.js @@ -788,8 +788,6 @@ function doActivityItemAction(ident, verb, un) { .attr({id: 'waitfor-' + verb + '-' + ident.toString(), src: 'images/rotator.gif'}) .addClass('fa') .appendTo($('button[id^=shareMenuOptions-' + ident.toString() + '] i:first-child' )); - } else { - $('').attr({id: 'waitfor-' + verb + '-' + ident.toString(), src: 'images/rotator.gif'}) } } $('button[id^=' + verb + '-' + ident.toString() + '] i:first-child').removeClass(thumbsClass); @@ -799,11 +797,7 @@ function doActivityItemAction(ident, verb, un) { .attr({id: 'waitfor-' + verb + '-' + ident.toString(), src: 'images/rotator.gif'}) .addClass('fa') .appendTo($('button[id^=' + verb + '-' + ident.toString() + '] i:first-child')); - } else { - // show existing rotator for activity - $('img[id^=waitfor-' + verb + '-' + ident.toString() + ']') } - // do request for activity $.post('item/' + ident.toString() + '/activity/' + _verb) .success(function(data){ From e651769134351ddeb57603b603cd5823643a94a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Wed, 15 Mar 2023 14:37:54 +0100 Subject: [PATCH 21/21] change/remove comments in code --- view/theme/frio/js/theme.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/view/theme/frio/js/theme.js b/view/theme/frio/js/theme.js index 3ae76dbf5..9196858bb 100644 --- a/view/theme/frio/js/theme.js +++ b/view/theme/frio/js/theme.js @@ -781,7 +781,7 @@ function doActivityItemAction(ident, verb, un) { // remove share-symbol, to replace it by rotator $('button[id^=shareMenuOptions-' + ident.toString() + '] i:first-child').removeClass('fa-share'); $('button[id^=announce-' + ident.toString() + '] i:first-child').removeClass('fa-retweet'); - // if no wait-rotator for activity(verb) is added, add it. or just show it, if exists + // avoid multiple rotators on like/share-button if klicked multiple times. if ($('img[id^=waitfor-' + verb + '-' + ident.toString() + ']').length == 0) { // append rotator to the shareMenu-button for small media $('') @@ -798,12 +798,10 @@ function doActivityItemAction(ident, verb, un) { .addClass('fa') .appendTo($('button[id^=' + verb + '-' + ident.toString() + '] i:first-child')); } - // do request for activity $.post('item/' + ident.toString() + '/activity/' + _verb) .success(function(data){ $('img[id^=waitfor-' + verb + '-' + ident.toString() + ']').remove(); if (data.status == 'ok') { - // response from server was ok if (data.verb == 'un' + verb) { // like/dislike buttons $('button[id^=' + verb + '-' + ident.toString() + ']' )