message_edit: Show loading indicator inside the button.

We now show loading indicator inside the 'save' button
instead of hiding the buttons to show the loading
indicator. Both the save and clear buttons are disabled
when the request is processing. We do not change color
of the buttons just change the cursor to indicate that
button are disabled and nothing happens on clicking them.

The reason for disabling the cancel button is that it
is actually not possible to cancel the action once
loading has started, so it is actually better to disable
it only such that users are not confused.

This commit adds a wrapper div element around the button
because we wanted to add two css properties to the button-
 'pointer-events: none' such that nothing happens on click
and 'cursor: not-allowed' to indicate that buttons are
disabled. But these boht styles cannot be added to same
element because 'pointer-events: none' overrides the
'cursor: not-allowed' style and normal cursor is visible.
That's why we add a wrapper to add 'cursor: not-allowed'
style to it and add 'pointer-events: none' to the button.
This commit is contained in:
sahil839
2021-07-03 22:48:57 +05:30
committed by Tim Abbott
parent 3f0110d9c0
commit 8e7ad58557
3 changed files with 41 additions and 10 deletions

View File

@@ -192,17 +192,22 @@ export function update_message_topic_editing_pencil() {
}
export function hide_message_edit_spinner(row) {
const spinner = row.find(".message_edit_spinner");
loading.destroy_indicator(spinner);
$(".message_edit_form .message_edit_save").show();
$(".message_edit_form .message_edit_cancel").show();
row.find(".loader").hide();
row.find(".message_edit_save span").show();
row.find(".message_edit_save").removeClass("disable-btn");
row.find(".message_edit_cancel").removeClass("disable-btn");
}
export function show_message_edit_spinner(row) {
const spinner = row.find(".message_edit_spinner");
loading.make_indicator(spinner);
$(".message_edit_form .message_edit_save").hide();
$(".message_edit_form .message_edit_cancel").hide();
row.find(".loader").css("display", "inline-block");
row.find(".message_edit_save span").hide();
row.find(".message_edit_save").addClass("disable-btn");
row.find(".message_edit_cancel").addClass("disable-btn");
row.find("object").on("load", function () {
const doc = this.getSVGDocument();
const $svg = $(doc).find("svg");
$svg.find("rect").css("fill", "#000");
});
}
export function show_topic_edit_spinner(row) {