2021-06-19 02:25:13 +02:00
|
|
|
/* Module for popovers that have been ported to the modern
|
|
|
|
TippyJS/Popper popover library from the legacy Bootstrap
|
|
|
|
popovers system in popovers.js. */
|
|
|
|
|
2022-11-29 08:05:14 +01:00
|
|
|
import ClipboardJS from "clipboard";
|
2021-06-17 19:05:34 +02:00
|
|
|
import $ from "jquery";
|
2022-11-29 09:04:27 +01:00
|
|
|
import tippy, {delegate} from "tippy.js";
|
2021-06-17 19:05:34 +02:00
|
|
|
|
2022-11-29 08:05:14 +01:00
|
|
|
import render_actions_popover_content from "../templates/actions_popover_content.hbs";
|
2021-11-23 19:01:36 +01:00
|
|
|
import render_compose_control_buttons_popover from "../templates/compose_control_buttons_popover.hbs";
|
2021-12-10 09:07:42 +01:00
|
|
|
import render_compose_select_enter_behaviour_popover from "../templates/compose_select_enter_behaviour_popover.hbs";
|
2021-06-17 19:05:34 +02:00
|
|
|
import render_left_sidebar_stream_setting_popover from "../templates/left_sidebar_stream_setting_popover.hbs";
|
|
|
|
import render_mobile_message_buttons_popover_content from "../templates/mobile_message_buttons_popover_content.hbs";
|
|
|
|
|
2021-12-10 09:07:42 +01:00
|
|
|
import * as channel from "./channel";
|
|
|
|
import * as common from "./common";
|
2021-06-17 19:05:34 +02:00
|
|
|
import * as compose_actions from "./compose_actions";
|
2022-11-29 08:05:14 +01:00
|
|
|
import * as condense from "./condense";
|
|
|
|
import * as emoji_picker from "./emoji_picker";
|
2021-11-23 19:01:36 +01:00
|
|
|
import * as giphy from "./giphy";
|
2022-11-29 08:05:14 +01:00
|
|
|
import {$t} from "./i18n";
|
|
|
|
import * as message_edit from "./message_edit";
|
|
|
|
import * as message_edit_history from "./message_edit_history";
|
|
|
|
import * as message_lists from "./message_lists";
|
2021-06-17 19:05:34 +02:00
|
|
|
import * as narrow_state from "./narrow_state";
|
2022-11-29 08:05:14 +01:00
|
|
|
import * as popover_menus_data from "./popover_menus_data";
|
2021-06-17 19:05:34 +02:00
|
|
|
import * as popovers from "./popovers";
|
2022-11-29 08:05:14 +01:00
|
|
|
import * as read_receipts from "./read_receipts";
|
|
|
|
import * as rows from "./rows";
|
2021-06-17 19:05:34 +02:00
|
|
|
import * as settings_data from "./settings_data";
|
2022-11-29 08:05:14 +01:00
|
|
|
import * as stream_popover from "./stream_popover";
|
2022-03-02 23:06:33 +01:00
|
|
|
import {parse_html} from "./ui_util";
|
2022-11-29 08:05:14 +01:00
|
|
|
import * as unread_ops from "./unread_ops";
|
2021-12-10 09:07:42 +01:00
|
|
|
import {user_settings} from "./user_settings";
|
2021-06-17 19:05:34 +02:00
|
|
|
|
|
|
|
let left_sidebar_stream_setting_popover_displayed = false;
|
|
|
|
let compose_mobile_button_popover_displayed = false;
|
2021-12-10 09:07:42 +01:00
|
|
|
export let compose_enter_sends_popover_displayed = false;
|
2021-11-23 19:01:36 +01:00
|
|
|
let compose_control_buttons_popover_instance;
|
2022-11-29 08:05:14 +01:00
|
|
|
let message_actions_popover_displayed = false;
|
|
|
|
let message_actions_popover_keyboard_toggle = false;
|
|
|
|
|
|
|
|
export function actions_popped() {
|
|
|
|
return message_actions_popover_displayed;
|
|
|
|
}
|
2021-11-23 19:01:36 +01:00
|
|
|
|
|
|
|
export function get_compose_control_buttons_popover() {
|
|
|
|
return compose_control_buttons_popover_instance;
|
|
|
|
}
|
2021-06-17 19:05:34 +02:00
|
|
|
|
2021-06-17 19:11:47 +02:00
|
|
|
const default_popover_props = {
|
|
|
|
delay: 0,
|
|
|
|
appendTo: () => document.body,
|
|
|
|
trigger: "click",
|
|
|
|
interactive: true,
|
|
|
|
hideOnClick: true,
|
2021-06-19 02:25:13 +02:00
|
|
|
/* The light-border TippyJS theme is a bit of a misnomer; it
|
|
|
|
is a popover styling similar to Bootstrap. We've also customized
|
2021-11-26 10:31:52 +01:00
|
|
|
its CSS to support Zulip's dark theme. */
|
2021-06-17 19:11:47 +02:00
|
|
|
theme: "light-border",
|
|
|
|
touch: true,
|
2022-11-29 10:11:52 +01:00
|
|
|
/* Don't use allow-HTML here since it is unsafe. Instead, use `parse_html`
|
|
|
|
to generate the required html */
|
2021-06-17 19:11:47 +02:00
|
|
|
};
|
|
|
|
|
2021-11-10 14:27:27 +01:00
|
|
|
export function any_active() {
|
2021-11-23 19:01:36 +01:00
|
|
|
return (
|
|
|
|
left_sidebar_stream_setting_popover_displayed ||
|
|
|
|
compose_mobile_button_popover_displayed ||
|
2021-12-10 09:07:42 +01:00
|
|
|
compose_control_buttons_popover_instance ||
|
2022-11-29 08:05:14 +01:00
|
|
|
compose_enter_sends_popover_displayed ||
|
|
|
|
message_actions_popover_displayed
|
2021-11-23 19:01:36 +01:00
|
|
|
);
|
2021-06-17 19:05:34 +02:00
|
|
|
}
|
|
|
|
|
2021-11-23 19:00:41 +01:00
|
|
|
function on_show_prep(instance) {
|
2022-12-04 06:46:40 +01:00
|
|
|
$(instance.popper).on("click", (e) => {
|
|
|
|
// Popover is not hidden on click inside it unless the click handler for the
|
|
|
|
// element explicitly hides the popover when handling the event.
|
|
|
|
// `stopPropagation` is required here to avoid global click handlers from
|
|
|
|
// being triggered.
|
|
|
|
e.stopPropagation();
|
|
|
|
});
|
|
|
|
$(instance.popper).one("click", ".navigate_and_close_popover", (e) => {
|
|
|
|
// Handler for links inside popover which don't need a special click handler.
|
|
|
|
e.stopPropagation();
|
|
|
|
instance.hide();
|
|
|
|
});
|
2022-11-30 14:09:42 +01:00
|
|
|
popovers.hide_all_except_sidebars();
|
2021-11-23 19:00:41 +01:00
|
|
|
}
|
|
|
|
|
2022-11-29 09:04:27 +01:00
|
|
|
function tippy_no_propagation(target, popover_props) {
|
|
|
|
// For some elements, such as the click target to open the message
|
|
|
|
// actions menu, we want to avoid propagating the click event to
|
|
|
|
// parent elements. Tippy's built-in `delegate` method does not
|
|
|
|
// have an option to do stopPropagation, so we use this method to
|
|
|
|
// open the Tippy popovers associated with such elements.
|
|
|
|
//
|
|
|
|
// A click on the click target will close the menu; for this to
|
|
|
|
// work correctly without leaking, all callers need call
|
|
|
|
// `instance.destroy()` inside their `onHidden` handler.
|
|
|
|
//
|
|
|
|
// TODO: Should we instead we wrap the caller's `onHidden` hook,
|
|
|
|
// if any, to add `instance.destroy()`?
|
|
|
|
$("body").on("click", target, (e) => {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
const instance = e.currentTarget._tippy;
|
|
|
|
|
|
|
|
if (instance) {
|
|
|
|
instance.hide();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
tippy(e.currentTarget, {
|
|
|
|
...default_popover_props,
|
|
|
|
showOnCreate: true,
|
|
|
|
...popover_props,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-11-29 08:05:14 +01:00
|
|
|
export function toggle_message_actions_menu(message) {
|
|
|
|
if (message.locally_echoed) {
|
|
|
|
// Don't open the popup for locally echoed messages for now.
|
|
|
|
// It creates bugs with things like keyboard handlers when
|
|
|
|
// we get the server response.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
const $popover_reference = $(".selected_message .actions_hover .zulip-icon-ellipsis-v-solid");
|
|
|
|
message_actions_popover_keyboard_toggle = true;
|
|
|
|
$popover_reference.trigger("click");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-06-17 19:05:34 +02:00
|
|
|
export function initialize() {
|
2022-11-29 09:04:27 +01:00
|
|
|
tippy_no_propagation("#streams_inline_icon", {
|
2021-06-17 19:05:34 +02:00
|
|
|
onShow(instance) {
|
2022-01-06 19:43:18 +01:00
|
|
|
const can_create_streams =
|
|
|
|
settings_data.user_can_create_private_streams() ||
|
|
|
|
settings_data.user_can_create_public_streams() ||
|
|
|
|
settings_data.user_can_create_web_public_streams();
|
2021-11-23 19:00:41 +01:00
|
|
|
on_show_prep(instance);
|
2022-01-06 19:43:18 +01:00
|
|
|
|
|
|
|
if (!can_create_streams) {
|
|
|
|
// If the user can't create streams, we directly
|
|
|
|
// navigate them to the Manage streams subscribe UI.
|
|
|
|
window.location.assign("#streams/all");
|
|
|
|
// Returning false from an onShow handler cancels the show.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-03-02 23:06:33 +01:00
|
|
|
instance.setContent(parse_html(render_left_sidebar_stream_setting_popover()));
|
2021-06-17 19:05:34 +02:00
|
|
|
left_sidebar_stream_setting_popover_displayed = true;
|
2022-01-06 19:43:18 +01:00
|
|
|
return true;
|
2021-06-17 19:05:34 +02:00
|
|
|
},
|
2022-11-29 09:04:27 +01:00
|
|
|
onHidden(instance) {
|
|
|
|
instance.destroy();
|
2021-06-17 19:05:34 +02:00
|
|
|
left_sidebar_stream_setting_popover_displayed = false;
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
// compose box buttons popover shown on mobile widths.
|
2022-11-29 09:04:27 +01:00
|
|
|
// We want this click event to propagate and hide other popovers
|
|
|
|
// that could possibly obstruct user from using this popover.
|
2021-06-17 19:05:34 +02:00
|
|
|
delegate("body", {
|
2021-06-17 19:11:47 +02:00
|
|
|
...default_popover_props,
|
2021-06-17 19:05:34 +02:00
|
|
|
target: ".compose_mobile_button",
|
|
|
|
placement: "top",
|
|
|
|
onShow(instance) {
|
2021-11-23 19:00:41 +01:00
|
|
|
on_show_prep(instance);
|
2021-06-17 19:05:34 +02:00
|
|
|
instance.setContent(
|
2022-03-02 23:06:33 +01:00
|
|
|
parse_html(
|
|
|
|
render_mobile_message_buttons_popover_content({
|
|
|
|
is_in_private_narrow: narrow_state.narrowed_to_pms(),
|
|
|
|
}),
|
|
|
|
),
|
2021-06-17 19:05:34 +02:00
|
|
|
);
|
|
|
|
compose_mobile_button_popover_displayed = true;
|
2022-12-04 06:46:40 +01:00
|
|
|
},
|
|
|
|
onMount(instance) {
|
2021-06-17 19:05:34 +02:00
|
|
|
const $popper = $(instance.popper);
|
2022-12-04 06:46:40 +01:00
|
|
|
$popper.one("click", ".compose_mobile_stream_button", (e) => {
|
2021-06-17 19:05:34 +02:00
|
|
|
compose_actions.start("stream", {trigger: "new topic button"});
|
2022-12-04 06:46:40 +01:00
|
|
|
e.stopPropagation();
|
|
|
|
instance.hide();
|
2021-06-17 19:05:34 +02:00
|
|
|
});
|
2022-12-04 06:46:40 +01:00
|
|
|
$popper.one("click", ".compose_mobile_private_button", (e) => {
|
2021-06-17 19:05:34 +02:00
|
|
|
compose_actions.start("private");
|
2022-12-04 06:46:40 +01:00
|
|
|
e.stopPropagation();
|
|
|
|
instance.hide();
|
2021-06-17 19:05:34 +02:00
|
|
|
});
|
|
|
|
},
|
|
|
|
onHidden(instance) {
|
|
|
|
// Destroy instance so that event handlers
|
|
|
|
// are destroyed too.
|
|
|
|
instance.destroy();
|
|
|
|
compose_mobile_button_popover_displayed = false;
|
|
|
|
},
|
|
|
|
});
|
2021-11-23 19:01:36 +01:00
|
|
|
|
2022-12-04 06:44:27 +01:00
|
|
|
// Click event handlers for it are handled in `compose_ui` and
|
|
|
|
// we don't want to close this popover on click inside it but
|
|
|
|
// only if user clicked outside it.
|
2022-11-29 09:04:27 +01:00
|
|
|
tippy_no_propagation(".compose_control_menu_wrapper", {
|
2021-11-23 19:01:36 +01:00
|
|
|
placement: "top",
|
|
|
|
onShow(instance) {
|
|
|
|
instance.setContent(
|
2022-03-02 23:06:33 +01:00
|
|
|
parse_html(
|
|
|
|
render_compose_control_buttons_popover({
|
|
|
|
giphy_enabled: giphy.is_giphy_enabled(),
|
|
|
|
}),
|
|
|
|
),
|
2021-11-23 19:01:36 +01:00
|
|
|
);
|
|
|
|
compose_control_buttons_popover_instance = instance;
|
2022-11-30 14:09:42 +01:00
|
|
|
popovers.hide_all_except_sidebars();
|
2021-11-23 19:01:36 +01:00
|
|
|
},
|
2022-11-29 09:04:27 +01:00
|
|
|
onHidden(instance) {
|
|
|
|
instance.destroy();
|
2021-11-23 19:01:36 +01:00
|
|
|
compose_control_buttons_popover_instance = undefined;
|
|
|
|
},
|
|
|
|
});
|
2021-12-10 09:07:42 +01:00
|
|
|
|
2022-11-29 09:04:27 +01:00
|
|
|
tippy_no_propagation(".enter_sends", {
|
2021-12-10 09:07:42 +01:00
|
|
|
placement: "top",
|
|
|
|
onShow(instance) {
|
|
|
|
on_show_prep(instance);
|
|
|
|
instance.setContent(
|
2022-03-02 23:06:33 +01:00
|
|
|
parse_html(
|
|
|
|
render_compose_select_enter_behaviour_popover({
|
|
|
|
enter_sends_true: user_settings.enter_sends,
|
|
|
|
}),
|
|
|
|
),
|
2021-12-10 09:07:42 +01:00
|
|
|
);
|
|
|
|
compose_enter_sends_popover_displayed = true;
|
|
|
|
},
|
|
|
|
onMount(instance) {
|
|
|
|
common.adjust_mac_shortcuts(".enter_sends_choices kbd");
|
|
|
|
|
|
|
|
$(instance.popper).one("click", ".enter_sends_choice", (e) => {
|
|
|
|
let selected_behaviour = $(e.currentTarget)
|
|
|
|
.find("input[type='radio']")
|
|
|
|
.attr("value");
|
|
|
|
selected_behaviour = selected_behaviour === "true"; // Convert to bool
|
|
|
|
user_settings.enter_sends = selected_behaviour;
|
|
|
|
$(`.enter_sends_${!selected_behaviour}`).hide();
|
|
|
|
$(`.enter_sends_${selected_behaviour}`).show();
|
|
|
|
|
|
|
|
// Refocus in the content box so you can continue typing or
|
|
|
|
// press Enter to send.
|
|
|
|
$("#compose-textarea").trigger("focus");
|
|
|
|
|
2022-12-04 06:43:20 +01:00
|
|
|
channel.patch({
|
2021-12-10 09:07:42 +01:00
|
|
|
url: "/json/settings",
|
|
|
|
data: {enter_sends: selected_behaviour},
|
|
|
|
});
|
2022-12-04 06:46:40 +01:00
|
|
|
e.stopPropagation();
|
|
|
|
instance.hide();
|
2021-12-10 09:07:42 +01:00
|
|
|
});
|
|
|
|
},
|
|
|
|
onHidden(instance) {
|
|
|
|
instance.destroy();
|
|
|
|
compose_enter_sends_popover_displayed = false;
|
|
|
|
},
|
|
|
|
});
|
2022-11-29 08:05:14 +01:00
|
|
|
|
|
|
|
tippy_no_propagation(".actions_hover .zulip-icon-ellipsis-v-solid", {
|
|
|
|
// The is our minimum supported width for mobile. We shouldn't
|
|
|
|
// make the popover wider than this.
|
|
|
|
maxWidth: "320px",
|
|
|
|
placement: "bottom",
|
|
|
|
popperOptions: {
|
|
|
|
modifiers: [
|
|
|
|
{
|
|
|
|
// The placement is set to bottom, but if that placement does not fit,
|
|
|
|
// the opposite top placement will be used.
|
|
|
|
name: "flip",
|
|
|
|
options: {
|
|
|
|
fallbackPlacements: ["top", "left"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
onShow(instance) {
|
|
|
|
on_show_prep(instance);
|
|
|
|
const $row = $(instance.reference).closest(".message_row");
|
|
|
|
const message_id = rows.id($row);
|
|
|
|
message_lists.current.select_id(message_id);
|
|
|
|
const args = popover_menus_data.get_actions_popover_content_context(message_id);
|
|
|
|
instance.setContent(parse_html(render_actions_popover_content(args)));
|
|
|
|
$row.addClass("has_popover has_actions_popover");
|
|
|
|
message_actions_popover_displayed = true;
|
|
|
|
},
|
|
|
|
onMount(instance) {
|
|
|
|
if (message_actions_popover_keyboard_toggle) {
|
|
|
|
popovers.focus_first_action_popover_item();
|
|
|
|
}
|
|
|
|
message_actions_popover_keyboard_toggle = false;
|
|
|
|
|
|
|
|
// We want click events to propagate to `instance` so that
|
|
|
|
// instance.hide gets called.
|
|
|
|
const $popper = $(instance.popper);
|
|
|
|
$popper.one("click", ".respond_button", (e) => {
|
|
|
|
// Arguably, we should fetch the message ID to respond to from
|
|
|
|
// e.target, but that should always be the current selected
|
|
|
|
// message in the current message list (and
|
|
|
|
// compose_actions.respond_to_message doesn't take a message
|
|
|
|
// argument).
|
|
|
|
compose_actions.quote_and_reply({trigger: "popover respond"});
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
instance.hide();
|
|
|
|
});
|
|
|
|
|
|
|
|
$popper.one("click", ".popover_edit_message, .popover_view_source", (e) => {
|
|
|
|
const message_id = $(e.currentTarget).data("message-id");
|
|
|
|
const $row = message_lists.current.get_row(message_id);
|
|
|
|
message_edit.start($row);
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
instance.hide();
|
|
|
|
});
|
|
|
|
|
|
|
|
$popper.one("click", ".popover_move_message", (e) => {
|
|
|
|
const message_id = $(e.currentTarget).data("message-id");
|
|
|
|
const message = message_lists.current.get(message_id);
|
|
|
|
stream_popover.build_move_topic_to_stream_popover(
|
|
|
|
message.stream_id,
|
|
|
|
message.topic,
|
|
|
|
message,
|
|
|
|
);
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
instance.hide();
|
|
|
|
});
|
|
|
|
|
|
|
|
$popper.one("click", ".mark_as_unread", (e) => {
|
|
|
|
const message_id = $(e.currentTarget).data("message-id");
|
|
|
|
unread_ops.mark_as_unread_from_here(message_id);
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
instance.hide();
|
|
|
|
});
|
|
|
|
|
|
|
|
$popper.one("click", ".popover_toggle_collapse", (e) => {
|
|
|
|
const message_id = $(e.currentTarget).data("message-id");
|
|
|
|
const $row = message_lists.current.get_row(message_id);
|
|
|
|
const message = message_lists.current.get(rows.id($row));
|
|
|
|
if ($row) {
|
|
|
|
if (message.collapsed) {
|
|
|
|
condense.uncollapse($row);
|
|
|
|
} else {
|
|
|
|
condense.collapse($row);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
instance.hide();
|
|
|
|
});
|
|
|
|
|
|
|
|
$popper.one("click", ".rehide_muted_user_message", (e) => {
|
|
|
|
const message_id = $(e.currentTarget).data("message-id");
|
|
|
|
const $row = message_lists.current.get_row(message_id);
|
|
|
|
const message = message_lists.current.get(rows.id($row));
|
|
|
|
const message_container = message_lists.current.view.message_containers.get(
|
|
|
|
message.id,
|
|
|
|
);
|
|
|
|
if ($row && !message_container.is_hidden) {
|
|
|
|
message_lists.current.view.hide_revealed_message(message_id);
|
|
|
|
}
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
instance.hide();
|
|
|
|
});
|
|
|
|
|
|
|
|
$popper.one("click", ".view_edit_history", (e) => {
|
|
|
|
const message_id = $(e.currentTarget).data("message-id");
|
|
|
|
const $row = message_lists.current.get_row(message_id);
|
|
|
|
const message = message_lists.current.get(rows.id($row));
|
|
|
|
message_edit_history.show_history(message);
|
|
|
|
$("#message-history-cancel").trigger("focus");
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
instance.hide();
|
|
|
|
});
|
|
|
|
|
|
|
|
$popper.one("click", ".view_read_receipts", (e) => {
|
|
|
|
const message_id = $(e.currentTarget).data("message-id");
|
|
|
|
read_receipts.show_user_list(message_id);
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
instance.hide();
|
|
|
|
});
|
|
|
|
|
|
|
|
$popper.one("click", ".delete_message", (e) => {
|
|
|
|
const message_id = $(e.currentTarget).data("message-id");
|
|
|
|
message_edit.delete_message(message_id);
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
instance.hide();
|
|
|
|
});
|
|
|
|
|
|
|
|
$popper.one("click", ".reaction_button", (e) => {
|
|
|
|
const message_id = $(e.currentTarget).data("message-id");
|
|
|
|
// Don't propagate the click event since `toggle_emoji_popover` opens a
|
|
|
|
// emoji_picker which we don't want to hide after actions popover is hidden.
|
|
|
|
e.stopPropagation();
|
|
|
|
e.preventDefault();
|
|
|
|
// HACK: Because we need the popover to be based off an
|
|
|
|
// element that definitely exists in the page even if the
|
|
|
|
// message wasn't sent by us and thus the .reaction_hover
|
|
|
|
// element is not present, we use the message's
|
|
|
|
// .fa-chevron-down element as the base for the popover.
|
|
|
|
const elem = $(".selected_message .actions_hover")[0];
|
|
|
|
emoji_picker.toggle_emoji_popover(elem, message_id, true);
|
|
|
|
instance.hide();
|
|
|
|
});
|
|
|
|
|
|
|
|
new ClipboardJS($popper.find(".copy_link")[0]).on("success", (e) => {
|
|
|
|
// e.trigger returns the DOM element triggering the copy action
|
|
|
|
const message_id = e.trigger.dataset.messageId;
|
|
|
|
const $row = $(`[zid='${CSS.escape(message_id)}']`);
|
|
|
|
$row.find(".alert-msg")
|
|
|
|
.text($t({defaultMessage: "Copied!"}))
|
|
|
|
.css("display", "block")
|
|
|
|
.delay(1000)
|
|
|
|
.fadeOut(300);
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
// The Clipboard library works by focusing to a hidden textarea.
|
|
|
|
// We unfocus this so keyboard shortcuts, etc., will work again.
|
|
|
|
$(":focus").trigger("blur");
|
|
|
|
}, 0);
|
|
|
|
instance.hide();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onHidden(instance) {
|
|
|
|
const $row = $(instance.reference).closest(".message_row");
|
|
|
|
$row.removeClass("has_popover has_actions_popover");
|
|
|
|
instance.destroy();
|
|
|
|
message_actions_popover_displayed = false;
|
|
|
|
message_actions_popover_keyboard_toggle = false;
|
|
|
|
},
|
|
|
|
});
|
2021-06-17 19:05:34 +02:00
|
|
|
}
|