mirror of https://github.com/zulip/zulip.git
stream_create: Extract create_stream.
This commit is contained in:
parent
989d58fd06
commit
054f7db63b
|
@ -143,6 +143,27 @@ function get_principals() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function create_stream() {
|
||||||
|
var stream = $.trim($("#create_stream_name").val());
|
||||||
|
var description = $.trim($("#create_stream_description").val());
|
||||||
|
var is_invite_only = $('#stream_creation_form input[name=privacy]:checked').val() === "invite-only";
|
||||||
|
var principals = get_principals();
|
||||||
|
|
||||||
|
// You are always subscribed to streams you create.
|
||||||
|
principals.push(people.my_current_email());
|
||||||
|
|
||||||
|
created_stream = stream;
|
||||||
|
|
||||||
|
var announce = (!!page_params.notifications_stream &&
|
||||||
|
$('#announce-new-stream input').prop('checked'));
|
||||||
|
|
||||||
|
ajaxSubscribeForCreation(stream,
|
||||||
|
description,
|
||||||
|
principals,
|
||||||
|
is_invite_only,
|
||||||
|
announce
|
||||||
|
);
|
||||||
|
}
|
||||||
exports.new_stream_clicked = function (stream) {
|
exports.new_stream_clicked = function (stream) {
|
||||||
// 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.
|
||||||
|
@ -292,30 +313,13 @@ $(function () {
|
||||||
$(".subscriptions").on("submit", "#stream_creation_form", function (e) {
|
$(".subscriptions").on("submit", "#stream_creation_form", function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var stream = $.trim($("#create_stream_name").val());
|
var stream = $.trim($("#create_stream_name").val());
|
||||||
var description = $.trim($("#create_stream_description").val());
|
|
||||||
|
|
||||||
var name_ok = stream_name_error.validate_for_submit(stream);
|
var name_ok = stream_name_error.validate_for_submit(stream);
|
||||||
|
|
||||||
if (!name_ok) {
|
if (!name_ok) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
create_stream();
|
||||||
var principals = get_principals();
|
|
||||||
|
|
||||||
// You are always subscribed to streams you create.
|
|
||||||
principals.push(people.my_current_email());
|
|
||||||
|
|
||||||
created_stream = stream;
|
|
||||||
|
|
||||||
var announce = (!!page_params.notifications_stream &&
|
|
||||||
$('#announce-new-stream input').prop('checked'));
|
|
||||||
|
|
||||||
ajaxSubscribeForCreation(stream,
|
|
||||||
description,
|
|
||||||
principals,
|
|
||||||
$('#stream_creation_form input[name=privacy]:checked').val() === "invite-only",
|
|
||||||
announce
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".subscriptions").on("input", "#create_stream_name", function () {
|
$(".subscriptions").on("input", "#create_stream_name", function () {
|
||||||
|
|
Loading…
Reference in New Issue