diff --git a/static/js/alert_popup.ts b/static/js/alert_popup.ts new file mode 100644 index 0000000000..889caf8d74 --- /dev/null +++ b/static/js/alert_popup.ts @@ -0,0 +1,16 @@ +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); + }); + + $(".alert-box").on("click", ".stackframe .expand", function () { + $(this).parent().siblings(".code-context").toggle("fast"); + }); +} diff --git a/static/js/click_handlers.js b/static/js/click_handlers.js index 1278ad8269..4ac8519c4d 100644 --- a/static/js/click_handlers.js +++ b/static/js/click_handlers.js @@ -643,15 +643,6 @@ export function initialize() { server_events.restart_get_events({dont_block: true}); }); - // 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); - }); - $("#settings_page").on("click", ".collapse-settings-btn", () => { settings_toggle.toggle_org_setting_collapse(); }); @@ -660,10 +651,6 @@ export function initialize() { popovers.hide_all(); }); - $(".alert-box").on("click", ".stackframe .expand", function () { - $(this).parent().siblings(".code-context").toggle("fast"); - }); - // COMPOSE // NB: This just binds to current elements, and won't bind to elements diff --git a/static/js/ui_init.js b/static/js/ui_init.js index 94bc73bea8..695a7df803 100644 --- a/static/js/ui_init.js +++ b/static/js/ui_init.js @@ -8,6 +8,7 @@ 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"; @@ -473,6 +474,7 @@ export function initialize_everything() { const user_status_params = pop_fields("user_status"); + alert_popup.initialize(); alert_words.initialize(alert_words_params); emojisets.initialize(); people.initialize(page_params.user_id, people_params); diff --git a/tools/test-js-with-node b/tools/test-js-with-node index a13bcf4ba3..581522b112 100755 --- a/tools/test-js-with-node +++ b/tools/test-js-with-node @@ -36,6 +36,7 @@ USAGE = """ # We do not yet require 100% line coverage for these files: EXEMPT_FILES = { "static/js/admin.js", + "static/js/alert_popup.ts", "static/js/archive.js", "static/js/attachments_ui.js", "static/js/avatar.js",