mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 06:53:25 +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()
|
// select_on_focus()
|
||||||
|
|
||||||
$("#compose-send-button").fadeOut = noop;
|
override(compose, "toggle_enter_sends_ui", noop);
|
||||||
$("#compose-send-button").fadeIn = noop;
|
|
||||||
let channel_patch_called = false;
|
let channel_patch_called = false;
|
||||||
override(channel, "patch", (params) => {
|
override(channel, "patch", (params) => {
|
||||||
assert.equal(params.url, "/json/settings");
|
assert.equal(params.url, "/json/settings");
|
||||||
|
|||||||
@@ -124,6 +124,15 @@ export function empty_topic_placeholder() {
|
|||||||
return $t({defaultMessage: "(no topic)"});
|
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() {
|
export function create_message_object() {
|
||||||
// Topics are optional, and we provide a placeholder if one isn't given.
|
// Topics are optional, and we provide a placeholder if one isn't given.
|
||||||
let topic = compose_state.topic();
|
let topic = compose_state.topic();
|
||||||
|
|||||||
@@ -1085,13 +1085,8 @@ export function initialize() {
|
|||||||
$("form#send_message_form").on("keyup", handle_keyup);
|
$("form#send_message_form").on("keyup", handle_keyup);
|
||||||
|
|
||||||
$("#enter_sends").on("click", () => {
|
$("#enter_sends").on("click", () => {
|
||||||
const send_button = $("#compose-send-button");
|
|
||||||
page_params.enter_sends = $("#enter_sends").is(":checked");
|
page_params.enter_sends = $("#enter_sends").is(":checked");
|
||||||
if (page_params.enter_sends) {
|
compose.toggle_enter_sends_ui();
|
||||||
send_button.fadeOut();
|
|
||||||
} else {
|
|
||||||
send_button.fadeIn();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Refocus in the content box so you can continue typing or
|
// Refocus in the content box so you can continue typing or
|
||||||
// press Enter to send.
|
// press Enter to send.
|
||||||
|
|||||||
Reference in New Issue
Block a user