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

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-02-10 07:46:49 -08:00 committed by Tim Abbott
parent 6a6a91b977
commit a175826a5a
7 changed files with 7 additions and 9 deletions

View File

@ -152,7 +152,6 @@
"color_data": false,
"colorspace": false,
"common": false,
"components": false,
"compose": false,
"compose_actions": false,
"compose_fade": false,

View File

@ -20,7 +20,6 @@ import "../keydown_util";
import "../rtl";
import "../fold_dict";
import "../scroll_util";
import "../components";
import "../feedback_widget";
import "../localstorage";
import "../drafts";

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -1,5 +1,7 @@
"use strict";
const components = require("./components");
let toggler;
exports.highlight_toggle = function (tab_name) {

View File

@ -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");