static: Move click handlers for alert-box to a separate module.

ui_init is also modified to ensure that the click handlers will still
be correctly initialized.
This commit is contained in:
PIG208
2021-03-26 03:34:51 +08:00
committed by Tim Abbott
parent ba14168d57
commit 36e90195e0
4 changed files with 19 additions and 13 deletions

16
static/js/alert_popup.ts Normal file
View File

@@ -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");
});
}

View File

@@ -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

View File

@@ -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);

View File

@@ -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",