mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 19:36:12 +01:00
bootstrap backed replacements for JS prompt and alert
This commit is contained in:
31
src/public/javascripts/dialogs/info.js
Normal file
31
src/public/javascripts/dialogs/info.js
Normal file
@@ -0,0 +1,31 @@
|
||||
const $dialog = $("#info-dialog");
|
||||
const $infoContent = $("#info-dialog-content");
|
||||
const $okButton = $("#info-dialog-ok-button");
|
||||
|
||||
let resolve;
|
||||
|
||||
function info(message) {
|
||||
glob.activeDialog = $dialog;
|
||||
|
||||
$infoContent.text(message);
|
||||
|
||||
$dialog.modal();
|
||||
|
||||
return new Promise((res, rej) => {
|
||||
resolve = res;
|
||||
});
|
||||
}
|
||||
|
||||
$dialog.on('shown.bs.modal', () => $okButton.trigger("focus"));
|
||||
|
||||
$dialog.on("hidden.bs.modal", () => {
|
||||
if (resolve) {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
|
||||
$okButton.click(() => $dialog.modal("hide"));
|
||||
|
||||
export default {
|
||||
info
|
||||
}
|
||||
Reference in New Issue
Block a user