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

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-02-27 16:16:32 -08:00 committed by Tim Abbott
parent f577489aa4
commit 5ebc3f1477
8 changed files with 13 additions and 16 deletions

View File

@ -153,7 +153,6 @@
"panels": false,
"pointer": false,
"reactions": false,
"realm_logo": false,
"realm_night_logo": false,
"recent_topics": false,
"reminder": false,

View File

@ -49,7 +49,8 @@ rewiremock("../../static/js/notifications").with(notifications);
const reactions = set_global("reactions", {});
const realm_icon = {__esModule: true};
rewiremock("../../static/js/realm_icon").with(realm_icon);
const realm_logo = set_global("realm_logo", {});
const realm_logo = {__esModule: true};
rewiremock("../../static/js/realm_logo").with(realm_logo);
const reload = {__esModule: true};
rewiremock("../../static/js/reload").with(reload);
const scroll_bar = {__esModule: true};

View File

@ -71,6 +71,7 @@ const _ui_report = {
};
const _realm_logo = {
__esModule: true,
build_realm_logo_widget: noop,
};
@ -83,7 +84,7 @@ set_global("csrf_token", "token-stub");
set_global("FormData", _FormData);
set_global("jQuery", _jQuery);
rewiremock("../../static/js/loading").with(_loading);
set_global("realm_logo", _realm_logo);
rewiremock("../../static/js/realm_logo").with(_realm_logo);
rewiremock("../../static/js/ui_report").with(_ui_report);
rewiremock("../../static/js/list_widget").with(_ListWidget);

View File

@ -34,7 +34,6 @@ import "../message_events";
import "../server_events";
import "../zulip";
import "../templates";
import "../realm_logo";
import "../reminder";
import "../confirm_dialog";
import "../dropdown_list_widget";

View File

@ -26,7 +26,6 @@ declare let page_params: any;
declare let panels: any;
declare let pointer: any;
declare let reactions: any;
declare let realm_logo: any;
declare let recent_topics: any;
declare let reminder: any;
declare let search_pill_widget: any;

View File

@ -1,10 +1,8 @@
"use strict";
import * as channel from "./channel";
import * as settings_config from "./settings_config";
import * as upload_widget from "./upload_widget";
const channel = require("./channel");
const settings_config = require("./settings_config");
const upload_widget = require("./upload_widget");
exports.build_realm_logo_widget = function (upload_function, is_night) {
export function build_realm_logo_widget(upload_function, is_night) {
let logo_section_id = "#realm-day-logo-upload-widget";
let logo_source = page_params.realm_logo_source;
@ -49,7 +47,7 @@ exports.build_realm_logo_widget = function (upload_function, is_night) {
upload_function,
page_params.max_logo_file_size,
);
};
}
function change_logo_delete_button(logo_source, logo_delete_button, file_input) {
if (logo_source === "U") {
@ -62,7 +60,7 @@ function change_logo_delete_button(logo_source, logo_delete_button, file_input)
}
}
exports.rerender = function () {
export function rerender() {
const file_input = $("#realm-day-logo-upload-widget .image_file_input");
const night_file_input = $("#realm-night-logo-upload-widget .realm-logo-file-input");
$("#realm-day-logo-upload-widget .image-block").attr("src", page_params.realm_logo_url);
@ -104,6 +102,4 @@ exports.rerender = function () {
$("#realm-night-logo-upload-widget .image-delete-button"),
night_file_input,
);
};
window.realm_logo = exports;
}

View File

@ -18,6 +18,7 @@ import * as overlays from "./overlays";
import * as peer_data from "./peer_data";
import * as people from "./people";
import * as realm_icon from "./realm_icon";
import * as realm_logo from "./realm_logo";
import * as reload from "./reload";
import * as scroll_bar from "./scroll_bar";
import * as settings_config from "./settings_config";

View File

@ -8,6 +8,7 @@ const channel = require("./channel");
const loading = require("./loading");
const overlays = require("./overlays");
const realm_icon = require("./realm_icon");
const realm_logo = require("./realm_logo");
const settings_config = require("./settings_config");
const settings_ui = require("./settings_ui");
const stream_data = require("./stream_data");