mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
confirm_dialog: Rename variables and classes used in templates.
This commit renames the variables, functions used in confirm_dialog.js and classes and ids used in confirm_dialog.hbs. This change is made so that we can easily migrate edit_fields_modal to use this same code with some more changes. We will change the file names and correspondingly import variables in the next commit.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import $ from "jquery";
|
||||
|
||||
import render_confirm_dialog from "../templates/confirm_dialog.hbs";
|
||||
import render_confirm_dialog_heading from "../templates/confirm_dialog_heading.hbs";
|
||||
import render_dialog_widget from "../templates/confirm_dialog.hbs";
|
||||
import render_dialog_heading from "../templates/confirm_dialog_heading.hbs";
|
||||
|
||||
import * as blueslip from "./blueslip";
|
||||
import * as overlays from "./overlays";
|
||||
@@ -27,29 +27,29 @@ import * as settings_data from "./settings_data";
|
||||
that will close the dialog via overlays.close_active_modal.
|
||||
|
||||
5) We assume that since this is a modal, you will
|
||||
only ever have one confirm dialog active at any
|
||||
only ever have one dialog active at any
|
||||
time.
|
||||
|
||||
6) If a modal wants a loading spinner, it should pass loading_spinner: true.
|
||||
This will show a loading spinner when the yes button is clicked.
|
||||
The caller is responsible for calling hide_confirm_dialog_spinner()
|
||||
The caller is responsible for calling hide_dialog_spinner()
|
||||
to hide the spinner in both success and error handlers.
|
||||
*/
|
||||
|
||||
export function hide_confirm_dialog_spinner() {
|
||||
$(".confirm_dialog_submit_button .loader").hide();
|
||||
$(".confirm_dialog_submit_button span").show();
|
||||
$(".confirm_dialog_submit_button").prop("disabled", false);
|
||||
$("#confirm_dialog_modal .close-modal-btn").prop("disabled", false);
|
||||
export function hide_dialog_spinner() {
|
||||
$(".dialog_submit_button .loader").hide();
|
||||
$(".dialog_submit_button span").show();
|
||||
$(".dialog_submit_button").prop("disabled", false);
|
||||
$("#dialog_widget_modal .close-modal-btn").prop("disabled", false);
|
||||
}
|
||||
|
||||
export function show_confirm_dialog_spinner() {
|
||||
$(".confirm_dialog_submit_button .loader").css("display", "inline-block");
|
||||
$(".confirm_dialog_submit_button span").hide();
|
||||
$(".confirm_dialog_submit_button").prop("disabled", true);
|
||||
$("#confirm_dialog_modal .close-modal-btn").prop("disabled", true);
|
||||
export function show_dialog_spinner() {
|
||||
$(".dialog_submit_button .loader").css("display", "inline-block");
|
||||
$(".dialog_submit_button span").hide();
|
||||
$(".dialog_submit_button").prop("disabled", true);
|
||||
$("#dialog_widget_modal .close-modal-btn").prop("disabled", true);
|
||||
if (!settings_data.using_dark_theme()) {
|
||||
$(".confirm_dialog_submit_button object").on("load", function () {
|
||||
$(".dialog_submit_button object").on("load", function () {
|
||||
const doc = this.getSVGDocument();
|
||||
const $svg = $(doc).find("svg");
|
||||
$svg.find("rect").css("fill", "#000");
|
||||
@@ -58,8 +58,8 @@ export function show_confirm_dialog_spinner() {
|
||||
}
|
||||
|
||||
export function launch(conf) {
|
||||
const html = render_confirm_dialog({fade: conf.fade});
|
||||
const confirm_dialog = $(html);
|
||||
const html = render_dialog_widget({fade: conf.fade});
|
||||
const dialog = $(html);
|
||||
|
||||
const conf_fields = [
|
||||
// The next three fields should be safe HTML. If callers
|
||||
@@ -78,43 +78,43 @@ export function launch(conf) {
|
||||
}
|
||||
}
|
||||
|
||||
conf.parent.append(confirm_dialog);
|
||||
conf.parent.append(dialog);
|
||||
|
||||
// Close any existing modals--on settings screens you can
|
||||
// have multiple buttons that need confirmation.
|
||||
if (overlays.is_modal_open()) {
|
||||
overlays.close_modal("#confirm_dialog_modal");
|
||||
overlays.close_modal("#dialog_widget_modal");
|
||||
}
|
||||
|
||||
confirm_dialog.find(".confirm_dialog_heading").html(
|
||||
render_confirm_dialog_heading({
|
||||
dialog.find(".dialog_heading").html(
|
||||
render_dialog_heading({
|
||||
heading_text: conf.html_heading,
|
||||
link: conf.help_link,
|
||||
}),
|
||||
);
|
||||
confirm_dialog.find(".confirm_dialog_body").append(conf.html_body);
|
||||
dialog.find(".dialog_body").append(conf.html_body);
|
||||
|
||||
const submit_button_span = confirm_dialog.find(".confirm_dialog_submit_button span");
|
||||
const submit_button_span = dialog.find(".dialog_submit_button span");
|
||||
|
||||
submit_button_span.html(conf.html_submit_button);
|
||||
|
||||
const submit_button = confirm_dialog.find(".confirm_dialog_submit_button");
|
||||
const submit_button = dialog.find(".dialog_submit_button");
|
||||
// Set up handlers.
|
||||
submit_button.on("click", () => {
|
||||
if (conf.loading_spinner) {
|
||||
show_confirm_dialog_spinner();
|
||||
show_dialog_spinner();
|
||||
} else {
|
||||
overlays.close_modal("#confirm_dialog_modal");
|
||||
overlays.close_modal("#dialog_widget_modal");
|
||||
}
|
||||
conf.on_click();
|
||||
});
|
||||
|
||||
confirm_dialog.on("hidden.bs.modal", () => {
|
||||
confirm_dialog.remove();
|
||||
dialog.on("hidden.bs.modal", () => {
|
||||
dialog.remove();
|
||||
});
|
||||
|
||||
// Open the modal
|
||||
overlays.open_modal("#confirm_dialog_modal");
|
||||
overlays.open_modal("#dialog_widget_modal");
|
||||
|
||||
conf.parent.on("shown.bs.modal", () => {
|
||||
submit_button.trigger("focus");
|
||||
|
||||
Reference in New Issue
Block a user