Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

jquery: Simplify $topic_not_mandatory_placeholder toggling.

Prakhar Pratyusha5c9ae1576d0
diff --git a/web/src/compose_recipient.ts b/web/src/compose_recipient.ts
index 813da682ab1..0d31ec005da 100644
--- a/web/src/compose_recipient.ts
+++ b/web/src/compose_recipient.ts
@@ -373,11 +373,7 @@ export function update_topic_displayed_text(
$topic_not_mandatory_placeholder.hide();
function update_placeholder_visibility(): void {
- if ($input.val() === "") {
- $topic_not_mandatory_placeholder.addClass("visible");
- } else {
- $topic_not_mandatory_placeholder.removeClass("visible");
- }
+ $topic_not_mandatory_placeholder.toggleClass("visible", $input.val() === "");
}
if (is_empty_string_topic && !has_topic_focus && recipient_widget_hidden) {
diff --git a/web/src/message_edit.ts b/web/src/message_edit.ts
index 2cdff153b84..c75e84059d1 100644
--- a/web/src/message_edit.ts
+++ b/web/src/message_edit.ts
@@ -519,11 +519,10 @@ function handle_inline_topic_edit_change(this: HTMLInputElement): void {
if (!realm.realm_mandatory_topics) {
const $topic_not_mandatory_placeholder = $(".inline-topic-edit-placeholder");
- if ($inline_topic_edit_input.val() === "") {
- $topic_not_mandatory_placeholder.addClass("inline-topic-edit-placeholder-visible");
- } else {
- $topic_not_mandatory_placeholder.removeClass("inline-topic-edit-placeholder-visible");
- }
+ $topic_not_mandatory_placeholder.toggleClass(
+ "inline-topic-edit-placeholder-visible",
+ $inline_topic_edit_input.val() === "",
+ );
}
}
diff --git a/web/src/stream_popover.ts b/web/src/stream_popover.ts
index 45ac6983621..d459856f068 100644
--- a/web/src/stream_popover.ts
+++ b/web/src/stream_popover.ts
@@ -759,15 +759,10 @@ export async function build_move_topic_to_stream_popover(
function update_topic_input_placeholder_visibility(topic_input_value: string): void {
if (!realm.realm_mandatory_topics) {
const $topic_not_mandatory_placeholder = $(".move-topic-new-topic-placeholder");
- if (topic_input_value === "") {
- $topic_not_mandatory_placeholder.addClass(
- "move-topic-new-topic-placeholder-visible",
- );
- } else {
- $topic_not_mandatory_placeholder.removeClass(
- "move-topic-new-topic-placeholder-visible",
- );
- }
+ $topic_not_mandatory_placeholder.toggleClass(
+ "move-topic-new-topic-placeholder-visible",
+ topic_input_value === "",
+ );
}
}