mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 03:11:54 +00:00
user_status: Migrate from overlay to modal.
This also migrates from loading the modal dynamically rather than statically once at page initialization. With styling changes by tabbott to preserve the original look of the UI. Fixes #18278.
This commit is contained in:
@@ -7,20 +7,18 @@ import * as people from "./people";
|
||||
import * as user_status from "./user_status";
|
||||
|
||||
export function input_field() {
|
||||
return $(".user_status_overlay input.user_status");
|
||||
return $("#set_user_status_modal input.user_status");
|
||||
}
|
||||
|
||||
export function submit_button() {
|
||||
return $(".user_status_overlay .set_user_status");
|
||||
return $("#set_user_status_modal .set_user_status");
|
||||
}
|
||||
|
||||
export function open_overlay() {
|
||||
const overlay = $(".user_status_overlay");
|
||||
overlays.open_overlay({
|
||||
name: "user_status_overlay",
|
||||
overlay,
|
||||
on_close() {},
|
||||
});
|
||||
export function open_user_status_modal() {
|
||||
const rendered_set_status_overlay = render_set_status_overlay();
|
||||
$(".app").append(rendered_set_status_overlay);
|
||||
|
||||
overlays.open_modal("#set_user_status_modal", {autoremove: true});
|
||||
|
||||
const user_id = people.my_current_user_id();
|
||||
const old_status_text = user_status.get_status_text(user_id);
|
||||
@@ -34,8 +32,8 @@ export function open_overlay() {
|
||||
button.prop("disabled", true);
|
||||
}
|
||||
|
||||
export function close_overlay() {
|
||||
overlays.close_overlay("user_status_overlay");
|
||||
export function close_user_status_modal() {
|
||||
overlays.close_modal("#set_user_status_modal");
|
||||
}
|
||||
|
||||
export function submit_new_status() {
|
||||
@@ -45,14 +43,14 @@ export function submit_new_status() {
|
||||
const new_status_text = input_field().val().trim();
|
||||
|
||||
if (old_status_text === new_status_text) {
|
||||
close_overlay();
|
||||
close_user_status_modal();
|
||||
return;
|
||||
}
|
||||
|
||||
user_status.server_update({
|
||||
status_text: new_status_text,
|
||||
success() {
|
||||
close_overlay();
|
||||
close_user_status_modal();
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -86,9 +84,6 @@ export function clear_message() {
|
||||
}
|
||||
|
||||
export function initialize() {
|
||||
const rendered_set_status_overlay = render_set_status_overlay();
|
||||
$(".app").append(rendered_set_status_overlay);
|
||||
|
||||
$("body").on("click", ".user-status-value", (event) => {
|
||||
event.stopPropagation();
|
||||
const user_status_value = $(event.currentTarget).text();
|
||||
@@ -97,11 +92,11 @@ export function initialize() {
|
||||
update_button();
|
||||
});
|
||||
|
||||
$("body").on("click", ".user_status_overlay .set_user_status", () => {
|
||||
$("body").on("click", "#set_user_status_modal .set_user_status", () => {
|
||||
submit_new_status();
|
||||
});
|
||||
|
||||
$("body").on("keypress", ".user_status_overlay .user_status", (event) => {
|
||||
$("body").on("keypress", "#set_user_status_modal .user_status", (event) => {
|
||||
if (event.key === "Enter") {
|
||||
event.preventDefault();
|
||||
|
||||
@@ -109,7 +104,7 @@ export function initialize() {
|
||||
}
|
||||
});
|
||||
|
||||
$("body").on("keyup", ".user_status_overlay input.user_status", () => {
|
||||
$("body").on("keyup", "#set_user_status_modal input.user_status", () => {
|
||||
update_button();
|
||||
toggle_clear_message_button();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user