import {isMobile} from "../util/functions"; import {Dialog} from "./index"; export const confirmDialog = (title: string, text: string, confirm?: (dialog?: Dialog) => void, cancel?: (dialog: Dialog) => void) => { if (!text && !title) { confirm(); return; } const dialog = new Dialog({ title, content: `
${text}
`, width: isMobile() ? "92vw" : "520px", }); const btnsElement = dialog.element.querySelectorAll(".b3-button"); btnsElement[0].addEventListener("click", () => { if (cancel) { cancel(dialog); } dialog.destroy(); }); btnsElement[1].addEventListener("click", () => { if (confirm) { confirm(dialog); } dialog.destroy(); }); };