Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

message_edit_history: Move click handlers to message_edit_history.js.

Ganesh Paware73644593cd4
diff --git a/static/js/click_handlers.js b/static/js/click_handlers.js
index 60cfeeff109..afd44911c58 100644
--- a/static/js/click_handlers.js
+++ b/static/js/click_handlers.js
@@ -21,7 +21,6 @@ import * as hash_util from "./hash_util";
import * as hotspots from "./hotspots";
import {$t} from "./i18n";
import * as message_edit from "./message_edit";
-import * as message_edit_history from "./message_edit_history";
import * as message_flags from "./message_flags";
import * as message_lists from "./message_lists";
import * as message_store from "./message_store";
@@ -29,7 +28,6 @@ import * as muting_ui from "./muting_ui";
import * as narrow from "./narrow";
import * as notifications from "./notifications";
import * as overlays from "./overlays";
-import {page_params} from "./page_params";
import * as popovers from "./popovers";
import * as reactions from "./reactions";
import * as recent_topics_ui from "./recent_topics_ui";
@@ -216,33 +214,6 @@ export function initialize() {
$(".tooltip").remove();
});
- $("body").on("mouseenter", ".message_edit_notice", (e) => {
- if (page_params.realm_allow_edit_history) {
- $(e.currentTarget).addClass("message_edit_notice_hover");
- }
- });
-
- $("body").on("mouseleave", ".message_edit_notice", (e) => {
- if (page_params.realm_allow_edit_history) {
- $(e.currentTarget).removeClass("message_edit_notice_hover");
- }
- });
-
- $("body").on("click", ".message_edit_notice", (e) => {
- popovers.hide_all();
- const message_id = rows.id($(e.currentTarget).closest(".message_row"));
- const row = message_lists.current.get_row(message_id);
- const message = message_lists.current.get(rows.id(row));
- const message_history_cancel_btn = $("#message-history-cancel");
-
- if (page_params.realm_allow_edit_history) {
- message_edit_history.show_history(message);
- message_history_cancel_btn.trigger("focus");
- }
- e.stopPropagation();
- e.preventDefault();
- });
-
$("body").on("click", ".reveal_hidden_message", (e) => {
// Hide actions popover to keep its options
// in sync with revealed/hidden state of
diff --git a/static/js/message_edit_history.js b/static/js/message_edit_history.js
index faefa7304a4..a3e5bed4c34 100644
--- a/static/js/message_edit_history.js
+++ b/static/js/message_edit_history.js
@@ -6,8 +6,12 @@ import render_message_history from "../templates/message_history.hbs";
import * as channel from "./channel";
import {$t_html} from "./i18n";
+import * as message_lists from "./message_lists";
import * as overlays from "./overlays";
+import {page_params} from "./page_params";
import * as people from "./people";
+import * as popovers from "./popovers";
+import * as rows from "./rows";
import * as timerender from "./timerender";
import * as ui_report from "./ui_report";
@@ -81,6 +85,33 @@ export function show_history(message) {
}
export function initialize() {
+ $("body").on("mouseenter", ".message_edit_notice", (e) => {
+ if (page_params.realm_allow_edit_history) {
+ $(e.currentTarget).addClass("message_edit_notice_hover");
+ }
+ });
+
+ $("body").on("mouseleave", ".message_edit_notice", (e) => {
+ if (page_params.realm_allow_edit_history) {
+ $(e.currentTarget).removeClass("message_edit_notice_hover");
+ }
+ });
+
+ $("body").on("click", ".message_edit_notice", (e) => {
+ popovers.hide_all();
+ const message_id = rows.id($(e.currentTarget).closest(".message_row"));
+ const row = message_lists.current.get_row(message_id);
+ const message = message_lists.current.get(rows.id(row));
+ const message_history_cancel_btn = $("#message-history-cancel");
+
+ if (page_params.realm_allow_edit_history) {
+ show_history(message);
+ message_history_cancel_btn.trigger("focus");
+ }
+ e.stopPropagation();
+ e.preventDefault();
+ });
+
// TODO: Migrate this modal to be rendered when
// opened rather than once at startup.
const rendered_message_history = render_message_history();