Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

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

Anders Kaseorgfb93be0d94c1
diff --git a/.eslintrc.json b/.eslintrc.json
index 9147ea8dc02..444f28b6d8e 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -179,7 +179,6 @@
"realm_night_logo": false,
"recent_topics": false,
"reminder": false,
- "scroll_bar": false,
"search": false,
"search_pill_widget": false,
"search_suggestion": false,
diff --git a/frontend_tests/node_tests/dispatch.js b/frontend_tests/node_tests/dispatch.js
index e118d09af82..87a39bcbd7c 100644
--- a/frontend_tests/node_tests/dispatch.js
+++ b/frontend_tests/node_tests/dispatch.js
@@ -46,7 +46,8 @@ const realm_icon = set_global("realm_icon", {});
const realm_logo = set_global("realm_logo", {});
const reload = {__esModule: true};
rewiremock("../../static/js/reload").with(reload);
-const scroll_bar = set_global("scroll_bar", {});
+const scroll_bar = {__esModule: true};
+rewiremock("../../static/js/scroll_bar").with(scroll_bar);
const settings_account = set_global("settings_account", {});
const settings_bots = set_global("settings_bots", {});
const settings_display = set_global("settings_display", {});
diff --git a/frontend_tests/node_tests/ui_init.js b/frontend_tests/node_tests/ui_init.js
index 7800337308e..7ffa30556f0 100644
--- a/frontend_tests/node_tests/ui_init.js
+++ b/frontend_tests/node_tests/ui_init.js
@@ -86,7 +86,7 @@ rewiremock("../../static/js/message_viewport").with(message_viewport);
set_global("panels", {initialize() {}});
set_global("popovers", {initialize() {}});
rewiremock("../../static/js/reload").with({initialize() {}});
-set_global("scroll_bar", {initialize() {}});
+rewiremock("../../static/js/scroll_bar").with({initialize() {}});
const server_events = set_global("server_events", {initialize() {}});
set_global("settings_sections", {initialize() {}});
rewiremock("../../static/js/settings_panel_menu").with({initialize() {}});
diff --git a/static/js/bundles/app.js b/static/js/bundles/app.js
index bed77c0b4d5..1d7919f3f50 100644
--- a/static/js/bundles/app.js
+++ b/static/js/bundles/app.js
@@ -27,7 +27,6 @@ import "../reload";
import "../compose_actions";
import "../subs";
import "../ui";
-import "../scroll_bar";
import "../gear_menu";
import "../stream_popover";
import "../popovers";
diff --git a/static/js/global.d.ts b/static/js/global.d.ts
index 0b7a62c9f72..3d95ade3bff 100644
--- a/static/js/global.d.ts
+++ b/static/js/global.d.ts
@@ -52,7 +52,6 @@ declare let realm_icon: any;
declare let realm_logo: any;
declare let recent_topics: any;
declare let reminder: any;
-declare let scroll_bar: any;
declare let search: any;
declare let search_pill_widget: any;
declare let search_suggestion: any;
diff --git a/static/js/scroll_bar.js b/static/js/scroll_bar.js
index e5fdc60a65e..8d71353898c 100644
--- a/static/js/scroll_bar.js
+++ b/static/js/scroll_bar.js
@@ -1,6 +1,5 @@
-"use strict";
+import {media_breakpoints} from "./css_variables";
-const {media_breakpoints} = require("./css_variables");
// A few of our width properties in Zulip depend on the width of the
// browser scrollbar that is generated at the far right side of the
// page, which unfortunately varies depending on the browser and
@@ -35,7 +34,7 @@ function getScrollbarWidth() {
let sbWidth;
-exports.initialize = function () {
+export function initialize() {
// Workaround for browsers with fixed scrollbars
sbWidth = getScrollbarWidth();
@@ -71,10 +70,10 @@ exports.initialize = function () {
"</style>",
);
}
- exports.set_layout_width();
-};
+ set_layout_width();
+}
-exports.set_layout_width = function () {
+export function set_layout_width() {
// This logic unfortunately leads to a flash of mispositioned
// content when reloading a Zulip browser window. More details
// are available in the comments on the max-width of 1400px in
@@ -90,6 +89,4 @@ exports.set_layout_width = function () {
$(".fixed-app .app-main").css("max-width", 1400 + sbWidth + "px");
$("#compose-container").css("max-width", 1400 + sbWidth + "px");
}
-};
-
-window.scroll_bar = exports;
+}
diff --git a/static/js/server_events_dispatch.js b/static/js/server_events_dispatch.js
index 07edad28e0f..d42379b25fb 100644
--- a/static/js/server_events_dispatch.js
+++ b/static/js/server_events_dispatch.js
@@ -11,6 +11,7 @@ import * as night_mode from "./night_mode";
import * as peer_data from "./peer_data";
import * as people from "./people";
import * as reload from "./reload";
+import * as scroll_bar from "./scroll_bar";
import * as settings_config from "./settings_config";
import * as stream_data from "./stream_data";
import * as stream_events from "./stream_events";
diff --git a/static/js/ui_init.js b/static/js/ui_init.js
index cdd1852926b..9ae1ab5351d 100644
--- a/static/js/ui_init.js
+++ b/static/js/ui_init.js
@@ -31,6 +31,7 @@ const pm_list = require("./pm_list");
const reload = require("./reload");
const resize = require("./resize");
const rows = require("./rows");
+const scroll_bar = require("./scroll_bar");
const sent_messages = require("./sent_messages");
const settings_panel_menu = require("./settings_panel_menu");
const settings_toggle = require("./settings_toggle");
diff --git a/static/js/zcommand.js b/static/js/zcommand.js
index 28ee951a11b..efa9f151377 100644
--- a/static/js/zcommand.js
+++ b/static/js/zcommand.js
@@ -4,6 +4,7 @@ import * as channel from "./channel";
import * as common from "./common";
import * as feedback_widget from "./feedback_widget";
import * as night_mode from "./night_mode";
+import * as scroll_bar from "./scroll_bar";
/*