2020-06-07 19:04:43 +03:00
|
|
|
Function.noop = () => {};
|
|
|
|
|
2023-11-15 17:45:55 +03:00
|
|
|
function MessageBox(title, body, buttons, callbacks) {
|
2020-06-07 19:04:43 +03:00
|
|
|
if(u(".ovk-diag-cont").length > 0) return false;
|
|
|
|
|
2023-09-17 19:19:25 +03:00
|
|
|
document.querySelector("html").style.overflowY = "hidden"
|
2020-06-07 19:04:43 +03:00
|
|
|
let dialog = u(
|
|
|
|
`<div class="ovk-diag-cont">
|
|
|
|
<div class="ovk-diag">
|
|
|
|
<div class="ovk-diag-head">${title}</div>
|
|
|
|
<div class="ovk-diag-body">${body}</div>
|
|
|
|
<div class="ovk-diag-action"></div>
|
|
|
|
</div>
|
|
|
|
</div>`);
|
|
|
|
u("body").addClass("dimmed").append(dialog);
|
|
|
|
|
|
|
|
buttons.forEach((text, callback) => {
|
|
|
|
u(".ovk-diag-action").append(u(`<button class="button">${text}</button>`));
|
|
|
|
let button = u(u(".ovk-diag-action > button.button").last());
|
|
|
|
|
|
|
|
button.on("click", function(e) {
|
|
|
|
let __closeDialog = () => {
|
2023-11-15 11:41:18 +03:00
|
|
|
|
2023-11-15 17:45:55 +03:00
|
|
|
if(document.querySelector(".ovk-photo-view-dimmer") == null && document.querySelector(".ovk-fullscreen-player") == null) {
|
2023-10-03 19:40:13 +03:00
|
|
|
u("body").removeClass("dimmed");
|
2023-11-15 17:45:55 +03:00
|
|
|
document.querySelector("html").style.overflowY = "scroll"
|
2023-10-03 19:40:13 +03:00
|
|
|
}
|
2023-11-15 11:41:18 +03:00
|
|
|
|
2020-06-07 19:04:43 +03:00
|
|
|
u(".ovk-diag-cont").remove();
|
|
|
|
};
|
|
|
|
|
|
|
|
Reflect.apply(callbacks[callback], {
|
2021-10-13 20:50:16 +03:00
|
|
|
closeDialog: () => __closeDialog(),
|
|
|
|
$dialog: () => u(".ovk-diag-cont")
|
2020-06-07 19:04:43 +03:00
|
|
|
}, [e]);
|
|
|
|
|
|
|
|
__closeDialog();
|
|
|
|
});
|
|
|
|
});
|
2021-10-13 20:50:16 +03:00
|
|
|
|
|
|
|
return u(".ovk-diag-cont");
|
2020-07-17 19:25:55 +03:00
|
|
|
}
|