mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-15 21:25:28 +01:00
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
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: `<div class="b3-dialog__content">
|
|
<div class="ft__breakword">${text}</div>
|
|
</div>
|
|
<div class="b3-dialog__action">
|
|
<button class="b3-button b3-button--cancel">${window.siyuan.languages.cancel}</button><div class="fn__space"></div>
|
|
<button class="b3-button b3-button--text" id="confirmDialogConfirmBtn">${window.siyuan.languages.confirm}</button>
|
|
</div>`,
|
|
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();
|
|
});
|
|
};
|