user_profile: Move show_button_spinner to correct module.

It's only used in one place, from code that we moved to
user_profile.js in recent weeks.
This commit is contained in:
Tim Abbott 2023-09-27 10:09:10 -07:00
parent 9e9326b5df
commit b3c44864fa
2 changed files with 24 additions and 24 deletions

View File

@ -27,25 +27,6 @@ const section = {
bots: {}, bots: {},
}; };
export function show_button_spinner($button) {
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,
});
}
export function hide_button_spinner($button) {
const $spinner = $button.find(".modal__spinner");
$button.prop("disabled", false);
$button.find("span").show();
loading.destroy_indicator($spinner);
}
function compare_a_b(a, b) { function compare_a_b(a, b) {
if (a > b) { if (a > b) {
return 1; return 1;

View File

@ -23,6 +23,7 @@ import * as hash_util from "./hash_util";
import {$t, $t_html} from "./i18n"; import {$t, $t_html} from "./i18n";
import * as integration_url_modal from "./integration_url_modal"; import * as integration_url_modal from "./integration_url_modal";
import * as ListWidget from "./list_widget"; import * as ListWidget from "./list_widget";
import * as loading from "./loading";
import * as overlays from "./overlays"; import * as overlays from "./overlays";
import {page_params} from "./page_params"; import {page_params} from "./page_params";
import * as people from "./people"; import * as people from "./people";
@ -30,7 +31,6 @@ import * as popovers from "./popovers";
import * as settings_config from "./settings_config"; import * as settings_config from "./settings_config";
import * as settings_data from "./settings_data"; import * as settings_data from "./settings_data";
import * as settings_profile_fields from "./settings_profile_fields"; import * as settings_profile_fields from "./settings_profile_fields";
import * as settings_users from "./settings_users";
import * as stream_data from "./stream_data"; import * as stream_data from "./stream_data";
import * as stream_ui_updates from "./stream_ui_updates"; import * as stream_ui_updates from "./stream_ui_updates";
import * as sub_store from "./sub_store"; import * as sub_store from "./sub_store";
@ -51,6 +51,25 @@ const INCOMING_WEBHOOK_BOT_TYPE = 2;
const OUTGOING_WEBHOOK_BOT_TYPE = "3"; const OUTGOING_WEBHOOK_BOT_TYPE = "3";
const EMBEDDED_BOT_TYPE = "4"; const EMBEDDED_BOT_TYPE = "4";
export function show_button_spinner($button) {
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,
});
}
export function hide_button_spinner($button) {
const $spinner = $button.find(".modal__spinner");
$button.prop("disabled", false);
$button.find("span").show();
loading.destroy_indicator($spinner);
}
function compare_by_name(a, b) { function compare_by_name(a, b) {
return util.strcmp(a.name, b.name); return util.strcmp(a.name, b.name);
} }
@ -498,7 +517,7 @@ export function show_edit_bot_info_modal(user_id, $container) {
const $submit_btn = $("#user-profile-modal .dialog_submit_button"); const $submit_btn = $("#user-profile-modal .dialog_submit_button");
const $cancel_btn = $("#user-profile-modal .dialog_exit_button"); const $cancel_btn = $("#user-profile-modal .dialog_exit_button");
settings_users.show_button_spinner($submit_btn); show_button_spinner($submit_btn);
$cancel_btn.prop("disabled", true); $cancel_btn.prop("disabled", true);
channel.patch({ channel.patch({
@ -520,7 +539,7 @@ export function show_edit_bot_info_modal(user_id, $container) {
$("#bot-edit-form") $("#bot-edit-form")
.closest(".simplebar-content-wrapper") .closest(".simplebar-content-wrapper")
.animate({scrollTop: 0}, "fast"); .animate({scrollTop: 0}, "fast");
settings_users.hide_button_spinner($submit_btn); hide_button_spinner($submit_btn);
$cancel_btn.prop("disabled", false); $cancel_btn.prop("disabled", false);
}, },
}); });
@ -744,7 +763,7 @@ export function show_edit_user_info_modal(user_id, $container) {
const $submit_btn = $("#user-profile-modal .dialog_submit_button"); const $submit_btn = $("#user-profile-modal .dialog_submit_button");
const $cancel_btn = $("#user-profile-modal .dialog_exit_button"); const $cancel_btn = $("#user-profile-modal .dialog_exit_button");
settings_users.show_button_spinner($submit_btn); show_button_spinner($submit_btn);
$cancel_btn.prop("disabled", true); $cancel_btn.prop("disabled", true);
channel.patch({ channel.patch({
@ -763,7 +782,7 @@ export function show_edit_user_info_modal(user_id, $container) {
$("#edit-user-form") $("#edit-user-form")
.closest(".simplebar-content-wrapper") .closest(".simplebar-content-wrapper")
.animate({scrollTop: 0}, "fast"); .animate({scrollTop: 0}, "fast");
settings_users.hide_button_spinner($submit_btn); hide_button_spinner($submit_btn);
$cancel_btn.prop("disabled", false); $cancel_btn.prop("disabled", false);
}, },
}); });