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

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-02-10 07:55:52 -08:00 committed by Tim Abbott
parent 9dd03998f8
commit 03f61c1eb2
5 changed files with 22 additions and 28 deletions

View File

@ -263,7 +263,6 @@
"spoilers": false, "spoilers": false,
"starred_messages": false, "starred_messages": false,
"stream_color": false, "stream_color": false,
"stream_create": false,
"stream_data": false, "stream_data": false,
"stream_edit": false, "stream_edit": false,
"stream_events": false, "stream_events": false,

View File

@ -69,7 +69,6 @@ import "../stream_data";
import "../stream_topic_history"; import "../stream_topic_history";
import "../stream_muting"; import "../stream_muting";
import "../stream_events"; import "../stream_events";
import "../stream_create";
import "../stream_edit"; import "../stream_edit";
import "../subs"; import "../subs";
import "../message_edit"; import "../message_edit";

View File

@ -130,7 +130,6 @@ declare let settings_user_groups: any;
declare let settings_users: any; declare let settings_users: any;
declare let starred_messages: any; declare let starred_messages: any;
declare let stream_color: any; declare let stream_color: any;
declare let stream_create: any;
declare let stream_data: any; declare let stream_data: any;
declare let stream_edit: any; declare let stream_edit: any;
declare let stream_events: any; declare let stream_events: any;

View File

@ -1,25 +1,23 @@
"use strict"; import render_announce_stream_docs from "../templates/announce_stream_docs.hbs";
import render_new_stream_users from "../templates/new_stream_users.hbs";
import render_subscription_invites_warning_modal from "../templates/subscription_invites_warning_modal.hbs";
const render_announce_stream_docs = require("../templates/announce_stream_docs.hbs"); import * as peer_data from "./peer_data";
const render_new_stream_users = require("../templates/new_stream_users.hbs"); import * as people from "./people";
const render_subscription_invites_warning_modal = require("../templates/subscription_invites_warning_modal.hbs");
const peer_data = require("./peer_data");
const people = require("./people");
let created_stream; let created_stream;
exports.reset_created_stream = function () { export function reset_created_stream() {
created_stream = undefined; created_stream = undefined;
}; }
exports.set_name = function (stream) { export function set_name(stream) {
created_stream = stream; created_stream = stream;
}; }
exports.get_name = function () { export function get_name() {
return created_stream; return created_stream;
}; }
class StreamSubscriptionError { class StreamSubscriptionError {
report_no_subs_to_stream() { report_no_subs_to_stream() {
@ -234,7 +232,7 @@ function create_stream() {
}); });
} }
exports.new_stream_clicked = function (stream_name) { export function new_stream_clicked(stream_name) {
// this changes the tab switcher (settings/preview) which isn't necessary // this changes the tab switcher (settings/preview) which isn't necessary
// to a add new stream title. // to a add new stream title.
subs.show_subs_pane.create_stream(); subs.show_subs_pane.create_stream();
@ -243,9 +241,9 @@ exports.new_stream_clicked = function (stream_name) {
if (stream_name !== "") { if (stream_name !== "") {
$("#create_stream_name").val(stream_name); $("#create_stream_name").val(stream_name);
} }
exports.show_new_stream_modal(); show_new_stream_modal();
$("#create_stream_name").trigger("focus"); $("#create_stream_name").trigger("focus");
}; }
function clear_error_display() { function clear_error_display() {
stream_name_error.clear_errors(); stream_name_error.clear_errors();
@ -253,7 +251,7 @@ function clear_error_display() {
stream_subscription_error.clear_errors(); stream_subscription_error.clear_errors();
} }
exports.show_new_stream_modal = function () { export function show_new_stream_modal() {
$("#stream-creation").removeClass("hide"); $("#stream-creation").removeClass("hide");
$(".right .settings").hide(); $(".right .settings").hide();
@ -270,7 +268,7 @@ exports.show_new_stream_modal = function () {
const container = $("#people_to_add"); const container = $("#people_to_add");
container.html(html); container.html(html);
exports.create_handlers_for_users(container); create_handlers_for_users(container);
// Make the options default to the same each time: // Make the options default to the same each time:
// public, "announce stream" on. // public, "announce stream" on.
@ -304,9 +302,9 @@ exports.show_new_stream_modal = function () {
e.preventDefault(); e.preventDefault();
}); });
}; }
exports.create_handlers_for_users = function (container) { export function create_handlers_for_users(container) {
// container should be $('#people_to_add')...see caller to verify // container should be $('#people_to_add')...see caller to verify
container.on("change", "#user-checkboxes input", update_announce_stream_state); container.on("change", "#user-checkboxes input", update_announce_stream_state);
@ -380,9 +378,9 @@ exports.create_handlers_for_users = function (container) {
e.preventDefault(); e.preventDefault();
}); });
}; }
exports.set_up_handlers = function () { export function set_up_handlers() {
const container = $("#stream-creation").expectOne(); const container = $("#stream-creation").expectOne();
container.on("change", "#make-invite-only input", update_announce_stream_state); container.on("change", "#make-invite-only input", update_announce_stream_state);
@ -466,6 +464,4 @@ exports.set_up_handlers = function () {
e.preventDefault(); e.preventDefault();
} }
}); });
}; }
window.stream_create = exports;

View File

@ -10,6 +10,7 @@ const render_subscriptions = require("../templates/subscriptions.hbs");
const components = require("./components"); const components = require("./components");
const people = require("./people"); const people = require("./people");
const search_util = require("./search_util"); const search_util = require("./search_util");
const stream_create = require("./stream_create");
const util = require("./util"); const util = require("./util");
exports.show_subs_pane = { exports.show_subs_pane = {