fix dialog size and open

This commit is contained in:
null
2024-03-04 20:29:29 +01:00
parent e33c59ea9c
commit 71e1ec06e4
5 changed files with 85 additions and 80 deletions
+19 -20
View File
@@ -1,26 +1,25 @@
document.addEventListener('DOMContentLoaded', documentReady, false);
window.onmessage = (event) => {
if (event.data == "close") {
document.querySelector("dialog[open]").close();
function documentReady() {
const iframe = document.querySelector("iframe");
const dialog = document.querySelector("dialog");
iframe.onload = () => {
dialog.style.height = iframe.contentWindow.document.body.getBoundingClientRect().height + "px";
}
}
function documentReady() {
const iframe = document.querySelector("iframe");
iframe.onload=(event) => {
const openDialog = document.querySelector("dialog[open]");
if (openDialog) {
openDialog.close();
window.location.reload();
} else {
const dialog = document.querySelector("dialog")
if (iframe.contentWindow.location.href.split("/").pop() === "create") {
dialog.className = 'create';
} else {
dialog.className = 'update';
}
dialog.showModal()
}
window.onmessage = (event) => {
if (event.data == "close") {
const dialog = document.querySelector("dialog[open]");
const iframe = document.querySelector("iframe");
dialog.close();
iframe.src = "about:blank"
}
}
function onOpenDialog(href) {
const iframe = document.querySelector("iframe");
const dialog = document.querySelector("dialog");
iframe.contentWindow.location = href;
dialog.showModal();
}