From 7b60ce1d70b00b794d79fc30ec3b58d820e64106 Mon Sep 17 00:00:00 2001 From: PIG208 <359101898@qq.com> Date: Mon, 26 Apr 2021 00:26:03 +0800 Subject: [PATCH] js: Make alert_popup shared. It allows the click handler for the "x" button, and the stacktrace toggler to be shared between webapp and the portico pages. Reimplements #17801. --- static/js/alert_popup.ts | 24 +++++++++++------------- static/js/bundles/common.js | 1 + static/js/ui_init.js | 2 -- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/static/js/alert_popup.ts b/static/js/alert_popup.ts index 8425350b87..bac1718b30 100644 --- a/static/js/alert_popup.ts +++ b/static/js/alert_popup.ts @@ -1,16 +1,14 @@ import $ from "jquery"; -export function initialize(): void { - // this will hide the alerts that you click "x" on. - $("body").on("click", ".alert-box > div .exit", function () { - const $alert = $(this).closest(".alert-box > div"); - $alert.addClass("fade-out"); - setTimeout(() => { - $alert.removeClass("fade-out show"); - }, 300); - }); +// this will hide the alerts that you click "x" on. +$("body").on("click", ".alert-box > div .exit", function () { + const $alert = $(this).closest(".alert-box > div"); + $alert.addClass("fade-out"); + setTimeout(() => { + $alert.removeClass("fade-out show"); + }, 300); +}); - $(".alert-box").on("click", ".stackframe", function () { - $(this).siblings(".code-context").toggle("fast"); - }); -} +$(".alert-box").on("click", ".stackframe", function () { + $(this).siblings(".code-context").toggle("fast"); +}); diff --git a/static/js/bundles/common.js b/static/js/bundles/common.js index 527282ecb1..b500ba0bf5 100644 --- a/static/js/bundles/common.js +++ b/static/js/bundles/common.js @@ -3,6 +3,7 @@ import "core-js/features/symbol"; import "css.escape"; import "../webpack_public_path"; import "../../../tools/debug-require"; +import "../alert_popup"; import "../csrf"; import "../blueslip"; import "../../third/bootstrap/js/bootstrap"; diff --git a/static/js/ui_init.js b/static/js/ui_init.js index 28149a8c7c..e25ffffa82 100644 --- a/static/js/ui_init.js +++ b/static/js/ui_init.js @@ -8,7 +8,6 @@ import * as fenced_code from "../shared/js/fenced_code"; import render_edit_content_button from "../templates/edit_content_button.hbs"; import * as activity from "./activity"; -import * as alert_popup from "./alert_popup"; import * as alert_words from "./alert_words"; import * as blueslip from "./blueslip"; import * as bot_data from "./bot_data"; @@ -465,7 +464,6 @@ export function initialize_everything() { // template. compose.initialize(); message_lists.initialize(); - alert_popup.initialize(); alert_words.initialize(alert_words_params); emojisets.initialize(); people.initialize(page_params.user_id, people_params);