From a175826a5a60b4ea49e3cf92d817604be05c589b Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Wed, 10 Feb 2021 07:46:49 -0800 Subject: [PATCH] js: Convert static/js/components.js to ES6 module. Signed-off-by: Anders Kaseorg --- .eslintrc.json | 1 - static/js/bundles/app.js | 1 - static/js/components.js | 8 ++------ static/js/global.d.ts | 1 - static/js/info_overlay.js | 2 ++ static/js/settings_toggle.js | 2 ++ static/js/subs.js | 1 + 7 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 5492024808..8dfe9a348a 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 b5a1f29f6a..11823172b7 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 96e3f94d99..8bc80361f4 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 = $("
"); 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 e67d96ec37..c9748f67df 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 7c797d102e..09c54c9c03 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 53874000f6..9152087981 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 f9b4701f60..3701b36bd5 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");