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/components.js to ES6 module.

Anders Kaseorga175826a5a60
diff --git a/.eslintrc.json b/.eslintrc.json
index 54920248087..8dfe9a348aa 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -152,7 +152,6 @@
"color_data": false,
"colorspace": false,
"common": false,
- "components": false,
"compose": false,
"compose_actions": false,
"compose_fade": false,
diff --git a/static/js/bundles/app.js b/static/js/bundles/app.js
index b5a1f29f6ab..11823172b7d 100644
--- a/static/js/bundles/app.js
+++ b/static/js/bundles/app.js
@@ -20,7 +20,6 @@ import "../keydown_util";
import "../rtl";
import "../fold_dict";
import "../scroll_util";
-import "../components";
import "../feedback_widget";
import "../localstorage";
import "../drafts";
diff --git a/static/js/components.js b/static/js/components.js
index 96e3f94d99a..8bc80361f47 100644
--- a/static/js/components.js
+++ b/static/js/components.js
@@ -1,5 +1,3 @@
-"use strict";
-
/* USAGE:
Toggle x = components.toggle({
selected: Integer selected_index,
@@ -12,7 +10,7 @@
}).get();
*/
-exports.toggle = function (opts) {
+export function toggle(opts) {
const component = (function render_component(opts) {
const _component = $("<div class='tab-switcher'></div>");
if (opts.html_class) {
@@ -166,6 +164,4 @@ exports.toggle = function (opts) {
};
return prototype;
-};
-
-window.components = exports;
+}
diff --git a/static/js/global.d.ts b/static/js/global.d.ts
index e67d96ec374..c9748f67dfd 100644
--- a/static/js/global.d.ts
+++ b/static/js/global.d.ts
@@ -25,7 +25,6 @@ declare let click_handlers: any;
declare let color_data: any;
declare let colorspace: any;
declare let common: any;
-declare let components: any;
declare let compose: any;
declare let compose_actions: any;
declare let composebox_typeahead: any;
diff --git a/static/js/info_overlay.js b/static/js/info_overlay.js
index 7c797d102e8..09c54c9c030 100644
--- a/static/js/info_overlay.js
+++ b/static/js/info_overlay.js
@@ -1,5 +1,7 @@
"use strict";
+const components = require("./components");
+
// Make it explicit that our toggler is undefined until
// set_up_toggler is called.
exports.toggler = undefined;
diff --git a/static/js/settings_toggle.js b/static/js/settings_toggle.js
index 53874000f6a..91520879811 100644
--- a/static/js/settings_toggle.js
+++ b/static/js/settings_toggle.js
@@ -1,5 +1,7 @@
"use strict";
+const components = require("./components");
+
let toggler;
exports.highlight_toggle = function (tab_name) {
diff --git a/static/js/subs.js b/static/js/subs.js
index f9b4701f60b..3701b36bd59 100644
--- a/static/js/subs.js
+++ b/static/js/subs.js
@@ -7,6 +7,7 @@ const render_subscription_settings = require("../templates/subscription_settings
const render_subscription_table_body = require("../templates/subscription_table_body.hbs");
const render_subscriptions = require("../templates/subscriptions.hbs");
+const components = require("./components");
const people = require("./people");
const search_util = require("./search_util");
const util = require("./util");