Clean up Pop-Up JS

Fix missing Width and Height data stopping images from loading
This commit is contained in:
Michał Gdula 2023-03-10 15:55:34 +00:00
parent b0a9271265
commit feadaba8a1
5 changed files with 146 additions and 180 deletions

View file

@ -2,34 +2,23 @@ function popUpShow(title, body, actions, content) {
// Stop scrolling // Stop scrolling
document.querySelector("html").style.overflow = "hidden"; document.querySelector("html").style.overflow = "hidden";
// Get popup elements
var popup = document.querySelector('.pop-up'); var popup = document.querySelector('.pop-up');
var popupContent = document.querySelector('.pop-up-content'); var popupContent = document.querySelector('.pop-up-content');
var popupActions = document.querySelector('.pop-up-controlls'); var popupActions = document.querySelector('.pop-up-controlls');
// Set tile and description // Set popup content
h3 = document.createElement('h3'); popupContent.innerHTML = `<h3>${title}</h3><p>${body}</p>${content}`;
h3.innerHTML = title;
p = document.createElement('p');
p.innerHTML = body;
popupContent.innerHTML = '';
popupContent.appendChild(h3);
popupContent.appendChild(p);
// Set content
if (content != '') {
popupContent.innerHTML += content;
}
// Set buttons that will be displayed // Set buttons that will be displayed
popupActions.innerHTML = ''; popupActions.innerHTML = actions;
if (actions != '') {
popupActions.innerHTML += actions;
}
popupActions.innerHTML += '<button class="pop-up__btn pop-up__btn-fill" onclick="popupDissmiss()">Nooooooo</button>'; popupActions.innerHTML += '<button class="pop-up__btn pop-up__btn-fill" onclick="popupDissmiss()">Nooooooo</button>';
// Show popup // Show popup
popup.classList.add('pop-up__active'); popup.style.display = 'block';
setTimeout(function() {
popup.classList.add('active')
}, 10);
} }
function popupDissmiss() { function popupDissmiss() {
@ -38,16 +27,16 @@ function popupDissmiss() {
var popup = document.querySelector('.pop-up'); var popup = document.querySelector('.pop-up');
popup.classList.add('pop-up__hide'); popup.classList.remove('active');
setTimeout(function() { setTimeout(function() {
popup.classList = 'pop-up'; popup.style.display = 'none';
}, 200); }, 200);
} }
document.addEventListener('keydown', function(event) { document.addEventListener('keydown', function(event) {
if (event.key === 'Escape') { if (event.key === 'Escape') {
if (document.querySelector('.pop-up').classList.contains('pop-up__active')) { if (document.querySelector('.pop-up').classList.contains('active')) {
popupDissmiss(); popupDissmiss();
} }
} }

View file

@ -18,8 +18,10 @@
src="/api/uploads/{{ image.file_name }}?w=1000&h=1000" src="/api/uploads/{{ image.file_name }}?w=1000&h=1000"
onload="imgFade(this)" style="opacity:0;" onload="imgFade(this)" style="opacity:0;"
onerror="this.src='/static/images/error.png'" onerror="this.src='/static/images/error.png'"
width="{{ image.image_exif.File.Width.raw }}" {% if "File" in image.image_exif %}
height="{{ image.image_exif.File.Height.raw }}" width="{{ image.image_exif.File.Width.raw }}"
height="{{ image.image_exif.File.Height.raw }}"
{% endif %}
/> />
</div> </div>

View file

@ -36,13 +36,6 @@
{% endif %} {% endif %}
</div> </div>
{% endif %} {% endif %}
<!--
<footer>
<a>V{{ config['APP_VERSION'] }}</a>
<p>Rights reserved to {{ config['ADMIN']['name'] }}</p>
</footer>
-->
{% endblock %} {% endblock %}
{% block script %} {% block script %}

View file

@ -21,130 +21,135 @@
height: 100vh height: 100vh
position: fixed position: fixed
top: 100% top: 0
left: 3.5rem left: 3.5rem
display: none
background-color: rgba($black, 0.8) background-color: rgba($black, 0.8)
opacity: 0 opacity: 0
z-index: 101
z-index: 101
transition: opacity 0.2s ease transition: opacity 0.2s ease
.pop-up__click-off .pop-up__click-off
width: 100vw width: 100vw
height: 100vh height: 100vh
height: 100dvh
position: absolute position: absolute
top: 0
left: 0
z-index: +1
.pop-up-wrapper
margin: 0
padding: 0
width: 621px
height: auto
position: absolute
bottom: 50%
left: 50%
transform: translate(-50%, 50%) scale(0.8)
display: flex
flex-direction: column
background-color: $white
border-radius: $rad
overflow: hidden
transition: transform 0.2s cubic-bezier(.68,-0.55,.27,1.55)
z-index: +2
.pop-up-content
margin: 0
padding: 0.5rem 0.5rem 0
width: 100%
height: auto
max-height: 50vh
display: flex
flex-direction: column
gap: 0.5rem
overflow-y: auto
overflow-x: hidden
text-size-adjust: auto;
text-overflow: ellipsis
h3
margin: 0
width: 100%
position: sticky
top: 0 top: 0
left: 0
font-size: 2.5rem z-index: +1
font-weight: 600
text-align: center .pop-up-wrapper
line-height: 1 margin: 0
padding: 0
width: 621px
height: auto
position: absolute
bottom: 50%
left: 50%
transform: translate(-50%, 50%) scale(0.8)
display: flex
flex-direction: column
color: $black
background-color: $white background-color: $white
border-radius: $rad
p overflow: hidden
z-index: +2
transition: transform 0.2s $animation-smooth
.pop-up-content
margin: 0 margin: 0
padding: 0.5rem 0.5rem 0
width: 100%
font-size: 1rem
font-weight: 500
text-align: center
line-height: 1
color: $black
img
margin: auto
padding: 0
width: auto
height: auto
max-width: 100%
max-height: 40vh
border-radius: $rad-inner
form
margin: 0
padding: 0
width: 100% width: 100%
height: auto height: auto
max-height: 50vh
display: flex display: flex
flex-direction: column flex-direction: column
gap: 0.5rem gap: 0.5rem
justify-content: center overflow-y: auto
overflow-x: hidden
text-size-adjust: auto;
text-overflow: ellipsis
.pop-up-controlls h3
margin: 0 margin: 0
padding: 0.5rem
width: 100% width: 100%
height: auto
display: flex position: sticky
flex-direction: row top: 0
justify-content: flex-end
gap: 0.5rem font-size: 2.5rem
font-weight: 600
text-align: center
line-height: 1
color: $black
background-color: $white
p
margin: 0
width: 100%
font-size: 1rem
font-weight: 500
text-align: center
line-height: 1
color: $black
img
margin: auto
padding: 0
width: auto
height: auto
max-width: 100%
max-height: 40vh
border-radius: $rad-inner
form
margin: 0
padding: 0
width: 100%
height: auto
display: flex
flex-direction: column
gap: 0.5rem
justify-content: center
.pop-up-controlls
margin: 0
padding: 0.5rem
width: 100%
height: auto
display: flex
flex-direction: row
justify-content: flex-end
gap: 0.5rem
&.active
opacity: 1
.pop-up-wrapper
transform: translate(-50%, 50%) scale(1)
.pop-up__btn .pop-up__btn
margin: 0 margin: 0
@ -209,21 +214,6 @@
text-decoration: underline text-decoration: underline
cursor: pointer cursor: pointer
.pop-up__active
opacity: 1
top: 0
.pop-up-wrapper
transform: translate(-50%, 50%) scale(1)
.pop-up__hide
opacity: 0
transition: opacity 0.2s ease
.pop-up-wrapper
transform: translate(-50%, 50%) scaleY(0)
transition: transform 0.2s ease
@media (max-width: $breakpoint) @media (max-width: $breakpoint)
.pop-up .pop-up
width: 100% width: 100%
@ -236,41 +226,32 @@
backdrop-filter: blur(0.5rem) backdrop-filter: blur(0.5rem)
.pop-up-wrapper .pop-up-wrapper
width: calc(100vw - 1rem) width: calc(100vw - 1rem)
max-height: calc(100vh - 1rem) max-height: calc(100vh - 1rem)
max-height: calc(100dvh - 1rem) max-height: calc(100dvh - 1rem)
left: 0.5rem left: 0.5rem
bottom: 0.5rem bottom: 0.5rem
border-radius: $rad border-radius: $rad
transform: translateY(5rem) transform: translateY(5rem)
.pop-up-content .pop-up-content
max-height: 100% max-height: 100%
img img
max-height: 50vh max-height: 50vh
.pop-up-controlls .pop-up-controlls
flex-direction: column flex-direction: column
justify-content: center justify-content: center
&.active
opacity: 1
.pop-up-wrapper
transform: translateY(0)
.pop-up__btn .pop-up__btn
width: 100% width: 100%
.pop-up__active
opacity: 1
top: unset
.pop-up-wrapper
transform: translateY(0)
.pop-up__hide
opacity: 0
transition: opacity 0.2s ease
.pop-up-wrapper
transform: translateY(5rem)
transition: transform 0.2s ease

View file

@ -18,9 +18,10 @@ $info: $blue
$rad: 6px $rad: 6px
$rad-inner: 3px $rad-inner: 3px
$font: "Work Sans", sans-serif $animation-smooth: cubic-bezier(0.76, 0, 0.17, 1)
$animation-bounce: cubic-bezier(.68,-0.55,.27,1.55)
// responsive breakpoint for mobile $font: "Work Sans", sans-serif
$breakpoint: 800px $breakpoint: 800px
@font-face @font-face