Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
settings: Extract common logic for show_spinner.
Maneesh Shukla666e7bf433f8
diff --git a/web/src/dialog_widget.ts b/web/src/dialog_widget.tsindex db81a4e1ec3..ee879afe298 100644--- a/web/src/dialog_widget.ts+++ b/web/src/dialog_widget.ts@@ -102,17 +102,8 @@ export function show_dialog_spinner(): void {$(`${dialog_widget_selector} .modal__btn`).prop("disabled", true);const $spinner = $(`${dialog_widget_selector} .modal__spinner`);- const dialog_submit_button_span_width = $(".dialog_submit_button span").width();- const dialog_submit_button_span_height = $(".dialog_submit_button span").height();- // Hide the submit button after computing its height, since submit- // buttons with long text might affect the size of the button.- $(".dialog_submit_button span").hide();-- loading.make_indicator($spinner, {- width: dialog_submit_button_span_width,- height: dialog_submit_button_span_height,- });+ loading.show_spinner($(".dialog_submit_button"), $spinner);}// Supports a callback to be called once the modal finishes closing.diff --git a/web/src/loading.ts b/web/src/loading.tsindex 1d749351212..f504ba6f571 100644--- a/web/src/loading.ts+++ b/web/src/loading.ts@@ -91,3 +91,18 @@ export function show_button_spinner($elt: JQuery, using_dark_theme: boolean): vo}$elt.css("display", "inline-block");}++export function show_spinner($button_element: JQuery, $spinner: JQuery): void {+ const span_width = $button_element.find(".submit-button-text").width();+ const span_height = $button_element.find(".submit-button-text").height();++ // Hide the submit button after computing its height, since submit+ // buttons with long text might affect the size of the button.+ $button_element.find(".submit-button-text").hide();++ // Create the loading indicator+ make_indicator($spinner, {+ width: span_width,+ height: span_height,+ });+}diff --git a/web/src/user_profile.ts b/web/src/user_profile.tsindex d0156e552e1..98a99c31bdd 100644--- a/web/src/user_profile.ts+++ b/web/src/user_profile.ts@@ -88,14 +88,8 @@ const EMBEDDED_BOT_TYPE = "4";export function show_button_spinner($button: JQuery): void {const $spinner = $button.find(".modal__spinner");- const dialog_submit_button_span_width = $button.find("span").width();- const dialog_submit_button_span_height = $button.find("span").height();$button.prop("disabled", true);- $button.find("span").hide();- loading.make_indicator($spinner, {- width: dialog_submit_button_span_width,- height: dialog_submit_button_span_height,- });+ loading.show_spinner($button, $spinner);}export function hide_button_spinner($button: JQuery): void {