mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-09 10:18:50 +01:00
29 lines
1 KiB
TypeScript
29 lines
1 KiB
TypeScript
import {isMobile} from "../util/functions";
|
|
import {Dialog} from "./index";
|
|
|
|
export const confirmDialog = (title: string, text: string, confirm?: () => void, cancel?: () => void) => {
|
|
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.destroy();
|
|
});
|
|
btnsElement[1].addEventListener("click", () => {
|
|
if (confirm) {
|
|
confirm();
|
|
}
|
|
dialog.destroy();
|
|
});
|
|
};
|