Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
js: Convert static/js/info_overlay.js to ES6 module.
Anders Kaseorg3a90ec30d5aa
diff --git a/.eslintrc.json b/.eslintrc.jsonindex 73adaae386b..f5813d99f2e 100644--- a/.eslintrc.json+++ b/.eslintrc.json@@ -153,7 +153,6 @@"home_msg_list": false,"hotspots": false,"i18n": false,- "info_overlay": false,"input_pill": false,"jQuery": false,"list_util": false,diff --git a/frontend_tests/node_tests/hashchange.js b/frontend_tests/node_tests/hashchange.jsindex 033c95dd2f7..c4b89a6f866 100644--- a/frontend_tests/node_tests/hashchange.js+++ b/frontend_tests/node_tests/hashchange.js@@ -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", {});diff --git a/frontend_tests/node_tests/hotkey.js b/frontend_tests/node_tests/hotkey.jsindex 4bd1901ce32..4a38a33a95e 100644--- a/frontend_tests/node_tests/hotkey.js+++ b/frontend_tests/node_tests/hotkey.js@@ -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", {});diff --git a/static/js/bundles/app.js b/static/js/bundles/app.jsindex 150b6c9814f..3ae9535d282 100644--- a/static/js/bundles/app.js+++ b/static/js/bundles/app.js@@ -26,7 +26,6 @@ import "../narrow";import "../reload";import "../compose_actions";import "../subs";-import "../info_overlay";import "../ui";import "../night_mode";import "../ui_util";diff --git a/static/js/global.d.ts b/static/js/global.d.tsindex df8fc50a63f..924ea34e5a1 100644--- a/static/js/global.d.ts+++ b/static/js/global.d.ts@@ -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;diff --git a/static/js/hashchange.js b/static/js/hashchange.jsindex dde7c162d33..b2e7ec3f843 100644--- a/static/js/hashchange.js+++ b/static/js/hashchange.js@@ -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");diff --git a/static/js/info_overlay.js b/static/js/info_overlay.jsindex 755c155c256..8c0a9ef745c 100644--- a/static/js/info_overlay.js+++ b/static/js/info_overlay.js@@ -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");+}