add download link

This commit is contained in:
Zhora Shalyapin 2025-01-13 16:10:05 +00:00
parent b21a486ee4
commit 2e6e65862a

37
main.js
View File

@ -474,12 +474,22 @@
swiperWrapper.classList.add("swiper-wrapper")
for (const file of files) {
let swiperSlide = document.createElement("div")
swiperSlide.classList.add("swiper-slide")
let downloadLink = document.createElement("a")
downloadLink.classList.add("swiper-download-link")
downloadLink.href = file.dataset.origin
downloadLink.text = "Скачать"
downloadLink.setAttribute("target", "_blank")
swiperSlide.appendChild(downloadLink)
let swiperFile = file.cloneNode(true)
if (swiperFile.dataset.origin)
swiperFile.src = swiperFile.dataset.origin
swiperFile.classList.add("swiper-slide")
swiperWrapper.appendChild(swiperFile)
swiperSlide.appendChild(swiperFile)
swiperWrapper.appendChild(swiperSlide)
}
swiperDiv.appendChild(swiperWrapper)
@ -812,7 +822,9 @@
dialog .preview,
.swiper {
max-width: 1000px;
width: 100%;
max-height: 500px;
height: 100%;
}
.swiper-button-next,
@ -825,13 +837,32 @@
align-items: center;
}
.swiper-wrapper > img.swiper-slide {
.swiper-wrapper > .swiper-slide {
width: 100%;
max-height: 500px;
height: 100%;
}
.swiper-slide img {
width: 100%;
max-height: 500px;
height: 100%;
object-fit: contain;
object-position: center;
}
.swiper-download-link {
display: block;
position: absolute;
top: 0;
right: 0;
background: white;
padding: 5px 10px;
margin: 5px;
border: 1px solid #ccc;
border-radius: 7.5px;
}
button.button-delete {
padding: 0;
border: 0;