mirror of https://github.com/zulip/zulip.git
compose: Create a helper function to calculate input information.
Function retrieves the input information based on the target event and returns it as an object. It determines if the input is an edit form or a compose form and returns the appropriate banner container.
This commit is contained in:
parent
e22c44131b
commit
815aeccd04
|
@ -460,6 +460,15 @@ export function initialize() {
|
||||||
|
|
||||||
upload.feature_check($("#compose .compose_upload_file"));
|
upload.feature_check($("#compose .compose_upload_file"));
|
||||||
|
|
||||||
|
function get_input_info(event) {
|
||||||
|
const $edit_banners_container = $(event.target).closest(".edit_form_banners");
|
||||||
|
const is_edit_input = Boolean($edit_banners_container.length);
|
||||||
|
const $banner_container = $edit_banners_container.length
|
||||||
|
? $edit_banners_container
|
||||||
|
: $("#compose_banners");
|
||||||
|
return {is_edit_input, $banner_container};
|
||||||
|
}
|
||||||
|
|
||||||
$("body").on(
|
$("body").on(
|
||||||
"click",
|
"click",
|
||||||
`.${CSS.escape(compose_banner.CLASSNAMES.wildcard_warning)} .compose_banner_action_button`,
|
`.${CSS.escape(compose_banner.CLASSNAMES.wildcard_warning)} .compose_banner_action_button`,
|
||||||
|
@ -536,9 +545,7 @@ export function initialize() {
|
||||||
)} .compose_banner_action_button`,
|
)} .compose_banner_action_button`,
|
||||||
(event) => {
|
(event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const $edit_form = $(event.target)
|
const {$banner_container} = get_input_info(event);
|
||||||
.closest(".message_edit_form")
|
|
||||||
.find(".edit_form_banners");
|
|
||||||
const $invite_row = $(event.target).parents(".compose_banner");
|
const $invite_row = $(event.target).parents(".compose_banner");
|
||||||
|
|
||||||
const user_id = Number.parseInt($invite_row.data("user-id"), 10);
|
const user_id = Number.parseInt($invite_row.data("user-id"), 10);
|
||||||
|
@ -553,7 +560,7 @@ export function initialize() {
|
||||||
compose_banner.show_error_message(
|
compose_banner.show_error_message(
|
||||||
error_msg,
|
error_msg,
|
||||||
compose_banner.CLASSNAMES.generic_compose_error,
|
compose_banner.CLASSNAMES.generic_compose_error,
|
||||||
$edit_form.length ? $edit_form : $("#compose_banners"),
|
$banner_container,
|
||||||
$("#compose-textarea"),
|
$("#compose-textarea"),
|
||||||
);
|
);
|
||||||
$(event.target).prop("disabled", true);
|
$(event.target).prop("disabled", true);
|
||||||
|
|
Loading…
Reference in New Issue