redo of dialog

This commit is contained in:
Jonas Leder 2021-03-22 21:03:09 +01:00
parent df737d6c71
commit 2b916e2a53
3 changed files with 44 additions and 59 deletions

View file

@ -1,60 +1,40 @@
.dialog { .dialog {
opacity: 0;
height: 100%;
width: 100%;
position: fixed; position: fixed;
top: 0; z-index: 1;
left: 0; left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgb(0,0,0);
background-color: rgba(0,0,0,0.9);
background-color: rgba(0, 0, 0, 0.5); .close {
position: absolute;
.dialogContent { top: 15px;
position:relative; right: 35px;
left: 50%; color: #f1f1f1;
top: 50%; font-size: 40px;
transform: translate(-50%, -50%); font-weight: bold;
max-height: max-content; transition: 0.3s;
max-width: max-content;
background-color: white;
border: 10px solid rgb(86, 86, 86);
border-radius: 10px;
display: flex;
width: 80%;
height: 80%;
iframe {
width: 100%;
height: 100%;
border: none;
}
} }
.imageDialog{ .close:hover,
img { .close:focus {
max-width: 100%; color: #bbb;
max-height: 100%; text-decoration: none;
} cursor: pointer;
} }
} }
a.dialogClose{ .dialogContent {
float:right; padding-top: 20px;
margin-top:-30px; margin: auto;
margin-right:-30px; max-width: 80%;
cursor:pointer; max-height: 80%;
color: #fff; text-align: center;
border: 1px solid #AEAEAE; img {
border-radius: 30px; max-height: auto;
background: #605F61; max-width: 100%;
font-size: 31px; }
font-weight: bold;
display: inline-block;
line-height: 0;
padding: 11px 3px;
text-decoration: none;
}
.dialogClose:before {
content: "×";
} }

View file

@ -1,7 +1,3 @@
function createDialogIframe(url:string) {
createDialogHTML(`<iframe src="${url}">`);
}
function createDialogImage(url:string) { function createDialogImage(url:string) {
createDialogHTML(`<img src="${url}">`, "imageDialog"); createDialogHTML(`<img src="${url}">`, "imageDialog");
} }
@ -9,18 +5,19 @@ function createDialogImage(url:string) {
function createDialogHTML(html:string, customClasses = "") { function createDialogHTML(html:string, customClasses = "") {
let dialog = document.createElement("div"); let dialog = document.createElement("div");
dialog.classList.add("dialog"); dialog.classList.add("dialog");
dialog.onclick = function () {
fade(dialog, -0.04, true);
}
dialog.innerHTML = ` dialog.innerHTML = `
<span class="close">&times;</span>
<div class="dialogContent ${customClasses}"> <div class="dialogContent ${customClasses}">
<!-- <a class="dialogClose"></a> -->
${html} ${html}
</div>`; </div>`;
document.body.appendChild(dialog); document.body.appendChild(dialog);
fade(dialog, 0.04); fade(dialog, 0.04);
(<HTMLElement> dialog.querySelector(".close")).onclick = function (){
fade(dialog, -0.04, true);
}
} }
function fade(element:HTMLElement, value = 0.1, deleteAfterwards = false) { function fade(element:HTMLElement, value = 0.1, deleteAfterwards = false) {

8
website.iml Normal file
View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>