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

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-02-27 15:59:34 -08:00 committed by Tim Abbott
parent 5b2b2924be
commit 3a90ec30d5
7 changed files with 22 additions and 27 deletions

View File

@ -153,7 +153,6 @@
"home_msg_list": false,
"hotspots": false,
"i18n": false,
"info_overlay": false,
"input_pill": false,
"jQuery": false,
"list_util": false,

View File

@ -27,7 +27,8 @@ rewiremock("../../static/js/drafts").with(drafts);
set_global("favicon", {});
const floating_recipient_bar = {__esModule: true};
rewiremock("../../static/js/floating_recipient_bar").with(floating_recipient_bar);
const info_overlay = set_global("info_overlay", {});
const info_overlay = {__esModule: true};
rewiremock("../../static/js/info_overlay").with(info_overlay);
const message_viewport = {__esModule: true};
rewiremock("../../static/js/message_viewport").with(message_viewport);
const narrow = set_global("narrow", {});

View File

@ -73,7 +73,7 @@ rewiremock("../../static/js/drafts").with(drafts);
const hashchange = set_global("hashchange", {
in_recent_topics_hash: () => false,
});
set_global("info_overlay", {});
rewiremock("../../static/js/info_overlay").with({});
const lightbox = {__esModule: true};
rewiremock("../../static/js/lightbox").with(lightbox);
const list_util = set_global("list_util", {});

View File

@ -26,7 +26,6 @@ import "../narrow";
import "../reload";
import "../compose_actions";
import "../subs";
import "../info_overlay";
import "../ui";
import "../night_mode";
import "../ui_util";

View File

@ -30,7 +30,6 @@ declare let home_msg_list: any;
declare let hotkey: any;
declare let hotspots: any;
declare let i18n: any;
declare let info_overlay: any;
declare let input_pill: any;
declare let list_util: any;
declare let message_events: any;

View File

@ -2,6 +2,7 @@
const drafts = require("./drafts");
const floating_recipient_bar = require("./floating_recipient_bar");
const info_overlay = require("./info_overlay");
const invite = require("./invite");
const message_viewport = require("./message_viewport");
const top_left_corner = require("./top_left_corner");

View File

@ -1,14 +1,12 @@
"use strict";
const common = require("./common");
const components = require("./components");
const keydown_util = require("./keydown_util");
import * as common from "./common";
import * as components from "./components";
import * as keydown_util from "./keydown_util";
// Make it explicit that our toggler is undefined until
// set_up_toggler is called.
exports.toggler = undefined;
export let toggler;
exports.set_up_toggler = function () {
export function set_up_toggler() {
const opts = {
selected: 0,
child_wants_focus: true,
@ -24,8 +22,8 @@ exports.set_up_toggler = function () {
},
};
exports.toggler = components.toggle(opts);
const elem = exports.toggler.get();
toggler = components.toggle(opts);
const elem = toggler.get();
elem.addClass("large allow-overflow");
const modals = opts.values.map((item) => {
@ -39,8 +37,8 @@ exports.set_up_toggler = function () {
keydown_util.handle({
elem: modal,
handlers: {
left_arrow: exports.toggler.maybe_go_left,
right_arrow: exports.toggler.maybe_go_right,
left_arrow: toggler.maybe_go_left,
right_arrow: toggler.maybe_go_right,
},
});
}
@ -49,11 +47,11 @@ exports.set_up_toggler = function () {
common.adjust_mac_shortcuts(".hotkeys_table .hotkey kbd");
common.adjust_mac_shortcuts("#markdown-instructions kbd");
};
}
exports.show = function (target) {
if (!exports.toggler) {
exports.set_up_toggler();
export function show(target) {
if (!toggler) {
set_up_toggler();
}
const overlay = $(".informational-overlays");
@ -69,18 +67,16 @@ exports.show = function (target) {
}
if (target) {
exports.toggler.goto(target);
toggler.goto(target);
}
};
}
exports.maybe_show_keyboard_shortcuts = function () {
export function maybe_show_keyboard_shortcuts() {
if (overlays.is_active()) {
return;
}
if (popovers.any_active()) {
return;
}
exports.show("keyboard-shortcuts");
};
window.info_overlay = exports;
show("keyboard-shortcuts");
}