mirror of
https://github.com/zulip/zulip.git
synced 2025-10-30 11:33:51 +00:00
compose: Extract compose.toggle_entry_sends_ui function.
This commit extracts the code for hiding and showing the send button according to 'enter_sends' setting value in a separate function.
This commit is contained in:
@@ -1096,8 +1096,7 @@ test("initialize", ({override, mock_template}) => {
|
||||
|
||||
// select_on_focus()
|
||||
|
||||
$("#compose-send-button").fadeOut = noop;
|
||||
$("#compose-send-button").fadeIn = noop;
|
||||
override(compose, "toggle_enter_sends_ui", noop);
|
||||
let channel_patch_called = false;
|
||||
override(channel, "patch", (params) => {
|
||||
assert.equal(params.url, "/json/settings");
|
||||
|
||||
@@ -124,6 +124,15 @@ export function empty_topic_placeholder() {
|
||||
return $t({defaultMessage: "(no topic)"});
|
||||
}
|
||||
|
||||
export function toggle_enter_sends_ui() {
|
||||
const send_button = $("#compose-send-button");
|
||||
if (page_params.enter_sends) {
|
||||
send_button.fadeOut();
|
||||
} else {
|
||||
send_button.fadeIn();
|
||||
}
|
||||
}
|
||||
|
||||
export function create_message_object() {
|
||||
// Topics are optional, and we provide a placeholder if one isn't given.
|
||||
let topic = compose_state.topic();
|
||||
|
||||
@@ -1085,13 +1085,8 @@ export function initialize() {
|
||||
$("form#send_message_form").on("keyup", handle_keyup);
|
||||
|
||||
$("#enter_sends").on("click", () => {
|
||||
const send_button = $("#compose-send-button");
|
||||
page_params.enter_sends = $("#enter_sends").is(":checked");
|
||||
if (page_params.enter_sends) {
|
||||
send_button.fadeOut();
|
||||
} else {
|
||||
send_button.fadeIn();
|
||||
}
|
||||
compose.toggle_enter_sends_ui();
|
||||
|
||||
// Refocus in the content box so you can continue typing or
|
||||
// press Enter to send.
|
||||
|
||||
Reference in New Issue
Block a user