Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
message_reaction: Calculate and render tooltip using tippyjs.
Aman Agrawal0e32454b1d68
diff --git a/static/js/click_handlers.js b/static/js/click_handlers.jsindex c09f40613c8..2048aaa26a1 100644--- a/static/js/click_handlers.js+++ b/static/js/click_handlers.js@@ -235,42 +235,6 @@ export function initialize() {e.preventDefault();});- // TOOLTIP FOR MESSAGE REACTIONS-- $("#main_div").on("mouseenter", ".message_reaction", (e) => {- e.stopPropagation();- const elem = $(e.currentTarget);- const local_id = elem.attr("data-reaction-id");- const message_id = rows.get_message_id(e.currentTarget);- const title = reactions.get_reaction_title_data(message_id, local_id);-- elem.tooltip({- title,- trigger: "hover",- placement: "bottom",- animation: false,- });- elem.tooltip("show");- $(".tooltip, .tooltip-inner").css({- "margin-left": "15px",- "max-width": $(window).width() * 0.6,- });- // Remove the arrow from the tooltip.- $(".tooltip-arrow").remove();- });-- $("#main_div").on("mouseleave", ".message_reaction", (e) => {- e.stopPropagation();- $(e.currentTarget).tooltip("destroy");- });-- // DESTROY PERSISTING TOOLTIPS ON HOVER-- $("body").on("mouseenter", ".tooltip", (e) => {- e.stopPropagation();- $(e.currentTarget).remove();- });-$("#main_div").on("click", "a.stream", function (e) {e.preventDefault();// Note that we may have an href here, but we trust the stream id more,diff --git a/static/js/tippyjs.js b/static/js/tippyjs.jsindex 650c6a0ddfc..4991e24090d 100644--- a/static/js/tippyjs.js+++ b/static/js/tippyjs.js@@ -1,5 +1,9 @@+import $ from "jquery";import tippy, {delegate} from "tippy.js";+import * as reactions from "./reactions";+import * as rows from "./rows";+// We override the defaults set by tippy library here,// so make sure to check this too after checking tippyjs// documentation for default properties.@@ -37,4 +41,16 @@ export function initialize() {// show tippy styled tooltip on hover.target: ".tippy-zulip-tooltip",});++ // message reaction tooltip showing who reacted.+ delegate("body", {+ target: ".message_reaction",+ onShow(instance) {+ const elem = $(instance.reference);+ const local_id = elem.attr("data-reaction-id");+ const message_id = rows.get_message_id(instance.reference);+ const title = reactions.get_reaction_title_data(message_id, local_id);+ instance.setContent(title);+ },+ });}