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

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-02-10 08:10:39 -08:00 committed by Tim Abbott
parent 4360a13dd6
commit 1ec9304eee
6 changed files with 5 additions and 10 deletions

View File

@ -249,7 +249,6 @@
"settings_toggle": false,
"settings_user_groups": false,
"settings_users": false,
"spoilers": false,
"starred_messages": false,
"stream_color": false,
"stream_data": false,

View File

@ -88,7 +88,6 @@ zrequire("color_data");
zrequire("stream_data");
zrequire("muting");
zrequire("condense");
zrequire("spoilers");
zrequire("lightbox");
zrequire("overlays");
zrequire("message_view_header");

View File

@ -154,7 +154,6 @@ import "../compose_ui";
import "../panels";
import "../recent_topics";
import "../search_pill_widget";
import "../spoilers";
import "../desktop_integration";
// Import styles

View File

@ -9,6 +9,7 @@ const alert_words = require("./alert_words");
const favicon = require("./favicon");
const people = require("./people");
const settings_config = require("./settings_config");
const spoilers = require("./spoilers");
const stream_ui_updates = require("./stream_ui_updates");
const notice_memory = new Map();

View File

@ -1,5 +1,3 @@
"use strict";
function collapse_spoiler(spoiler) {
const spoiler_height = spoiler.height();
@ -35,7 +33,7 @@ function expand_spoiler(spoiler) {
});
}
exports.hide_spoilers_in_notification = (content) => {
export const hide_spoilers_in_notification = (content) => {
content.find(".spoiler-block").each((i, elem) => {
$(elem).find(".spoiler-content").remove();
let text = $(elem).find(".spoiler-header").text().trim();
@ -48,7 +46,7 @@ exports.hide_spoilers_in_notification = (content) => {
return content;
};
exports.initialize = function () {
export function initialize() {
$("body").on("click", ".spoiler-header", function (e) {
const button = $(this).children(".spoiler-button");
const arrow = button.children(".spoiler-arrow");
@ -90,6 +88,4 @@ exports.initialize = function () {
expand_spoiler(spoiler_content);
}
});
};
window.spoilers = exports;
}

View File

@ -16,6 +16,7 @@ const invite = require("./invite");
const markdown_config = require("./markdown_config");
const people = require("./people");
const pm_conversations = require("./pm_conversations");
const spoilers = require("./spoilers");
const topic_zoom = require("./topic_zoom");
const tutorial = require("./tutorial");
const typing = require("./typing");