js: Convert static/js/panels.js to ES6 module.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-02-27 16:27:14 -08:00 committed by Tim Abbott
parent dc95f06b62
commit 934d4e4e10
10 changed files with 22 additions and 28 deletions

View File

@ -145,7 +145,6 @@
"message_list": false,
"narrow": false,
"page_params": false,
"panels": false,
"pointer": false,
"realm_night_logo": false,
"recent_topics": false,

View File

@ -121,7 +121,6 @@ const user_status = zrequire("user_status");
const emoji = zrequire("emoji", "shared/js/emoji");
const server_events_dispatch = zrequire("server_events_dispatch");
zrequire("panels");
function dispatch(ev) {
server_events_dispatch.dispatch_normal_event(ev);

View File

@ -83,7 +83,7 @@ const message_viewport = {
initialize() {},
};
rewiremock("../../static/js/message_viewport").with(message_viewport);
set_global("panels", {initialize() {}});
rewiremock("../../static/js/panels").with({initialize() {}});
rewiremock("../../static/js/popovers").with({initialize() {}});
rewiremock("../../static/js/reload").with({initialize() {}});
rewiremock("../../static/js/scroll_bar").with({initialize() {}});

View File

@ -38,7 +38,6 @@ import "../dropdown_list_widget";
import "../settings_profile_fields";
import "../settings";
import "../ui_init";
import "../panels";
import "../recent_topics";
import "../search_pill_widget";
import "../desktop_integration";

View File

@ -18,7 +18,6 @@ declare let message_events: any;
declare let message_list: any;
declare let narrow: any;
declare let page_params: any;
declare let panels: any;
declare let pointer: any;
declare let recent_topics: any;
declare let search_pill_widget: any;

View File

@ -1,11 +1,9 @@
"use strict";
import {localstorage} from "./localstorage";
import * as notifications from "./notifications";
import * as unread_ui from "./unread_ui";
import * as util from "./util";
const {localstorage} = require("./localstorage");
const notifications = require("./notifications");
const unread_ui = require("./unread_ui");
const util = require("./util");
const resize_app = function () {
export function resize_app() {
const panels_height = $("#panels").height();
$("body > .app").height("calc(100% - " + panels_height + "px)");
@ -16,9 +14,7 @@ const resize_app = function () {
$(".header").height() +
Number.parseInt($(".header").css("paddingBottom"), 10);
$("#floating_recipient_bar").css("top", frb_top + "px");
};
exports.resize_app = resize_app;
}
const show_step = function ($process, step) {
$process
@ -51,7 +47,7 @@ function should_show_notifications(ls) {
);
}
exports.check_profile_incomplete = function () {
export function check_profile_incomplete() {
if (!page_params.is_admin) {
return;
}
@ -67,24 +63,24 @@ exports.check_profile_incomplete = function () {
} else {
$("[data-process='profile-incomplete']").hide();
}
};
}
exports.initialize = function () {
export function initialize() {
const ls = localstorage();
if (page_params.insecure_desktop_app) {
exports.open($("[data-process='insecure-desktop-app']"));
open($("[data-process='insecure-desktop-app']"));
} else if (page_params.warn_no_email === true && page_params.is_admin) {
// if email has not been set up and the user is the admin,
// display a warning to tell them to set up an email server.
exports.open($("[data-process='email-server']"));
open($("[data-process='email-server']"));
} else if (should_show_notifications(ls)) {
exports.open($("[data-process='notifications']"));
open($("[data-process='notifications']"));
} else if (unread_ui.should_display_bankruptcy_banner()) {
exports.open($("[data-process='bankruptcy']"));
open($("[data-process='bankruptcy']"));
} else {
// TODO: This should be restructured with separate check and
// show calls.
exports.check_profile_incomplete();
check_profile_incomplete();
}
// Configure click handlers.
@ -127,12 +123,10 @@ exports.initialize = function () {
$(this).click();
}
});
};
}
exports.open = function ($process) {
export function open($process) {
$("[data-process]").hide();
$process.show();
resize_app();
};
window.panels = exports;
}

View File

@ -15,6 +15,7 @@ const muting = require("./muting");
const narrow_state = require("./narrow_state");
const navigate = require("./navigate");
const notifications = require("./notifications");
const panels = require("./panels");
const people = require("./people");
const recent_senders = require("./recent_senders");
const stream_data = require("./stream_data");

View File

@ -3,6 +3,7 @@ import autosize from "autosize";
import * as condense from "./condense";
import * as message_viewport from "./message_viewport";
import * as navigate from "./navigate";
import * as panels from "./panels";
import * as popovers from "./popovers";
import * as util from "./util";

View File

@ -17,6 +17,7 @@ import * as narrow_state from "./narrow_state";
import * as night_mode from "./night_mode";
import * as notifications from "./notifications";
import * as overlays from "./overlays";
import * as panels from "./panels";
import * as peer_data from "./peer_data";
import * as people from "./people";
import * as reactions from "./reactions";

View File

@ -34,6 +34,7 @@ import * as muting from "./muting";
import * as navigate from "./navigate";
import * as notifications from "./notifications";
import * as overlays from "./overlays";
import * as panels from "./panels";
import * as people from "./people";
import * as pm_conversations from "./pm_conversations";
import * as pm_list from "./pm_list";