From 85144908fa9cf12594b568f4f0b2d37fa21b6be1 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 23 Mar 2017 22:47:56 -0400 Subject: [PATCH] Improve display feedback on like actions - Move rotator in sight - Preventively change display class before next item update --- view/theme/frio/js/theme.js | 21 +++++++++++++++++++++ view/theme/frio/templates/search_item.tpl | 14 +++++++------- view/theme/frio/templates/wall_thread.tpl | 16 ++++++++-------- 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/view/theme/frio/js/theme.js b/view/theme/frio/js/theme.js index 62cd85df9..4e8ede07f 100644 --- a/view/theme/frio/js/theme.js +++ b/view/theme/frio/js/theme.js @@ -617,3 +617,24 @@ function htmlToText(htmlString) { return text; } + +/** + * Sends a /like API call and updates the display of the relevant action button + * before the update reloads the item. + * + * @param {string} ident The id of the relevant item + * @param {string} verb The verb of the action + * @returns {undefined} + */ +function doLikeAction(ident, verb) { + unpause(); + + if (verb.indexOf('attend') === 0) { + $('.item-' + ident + ' .button-event:not(#' + verb + '-' + ident + ')').removeClass('active'); + } + $('#' + verb + '-' + ident).toggleClass('active'); + $('#like-rotator-' + ident.toString()).show(); + $.get('like/' + ident.toString() + '?verb=' + verb, NavUpdate ); + liking = 1; + force_update = true; +} \ No newline at end of file diff --git a/view/theme/frio/templates/search_item.tpl b/view/theme/frio/templates/search_item.tpl index 51a9017c2..095b38968 100644 --- a/view/theme/frio/templates/search_item.tpl +++ b/view/theme/frio/templates/search_item.tpl @@ -2,12 +2,11 @@ -
+
{{* Put additional actions in a top-right dropdown menu *}} @@ -170,11 +169,11 @@ {{* Buttons for like and dislike *}} {{if $item.vote}} {{if $item.vote.like}} - + {{/if}} {{if $item.vote.dislike}} - + {{/if}} {{/if}} @@ -189,6 +188,7 @@ {{/if}} {{/if}} +
@@ -196,9 +196,9 @@ {{* Event attendance buttons *}} {{if $item.isevent}}
- - - + + +
{{/if}} diff --git a/view/theme/frio/templates/wall_thread.tpl b/view/theme/frio/templates/wall_thread.tpl index f276ee6f0..08057a1a9 100644 --- a/view/theme/frio/templates/wall_thread.tpl +++ b/view/theme/frio/templates/wall_thread.tpl @@ -68,9 +68,9 @@ as the value of $top_child_total (this is done at the end of this file) {{* Use a different div container in dependence max thread-level = 7 *}} {{if $item.thread_level<7}} -
+
{{else}} -
+
{{/if}}
{{* Put addional actions in a top-right dropdown menu *}} @@ -192,7 +192,6 @@ as the value of $top_child_total (this is done at the end of this file)
{{if $item.location}} @@ -287,13 +286,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}} @@ -315,15 +314,16 @@ as the value of $top_child_total (this is done at the end of this file)
{{* Event attendance buttons *}} {{if $item.isevent}}
- - - + + +
{{/if}}