|
|
@@ -292,21 +292,43 @@ $(() => {
|
|
|
function displayImg(medias) {
|
|
|
if (!Array.isArray(medias))
|
|
|
medias = [ medias ];
|
|
|
+ if (medias.length > 1) {
|
|
|
+ $("#pch-fullPagePreview > a").removeClass("hidden");
|
|
|
+ $("#pch-fullPagePreview > .carousel-indicators").removeClass("hidden");
|
|
|
+ } else {
|
|
|
+ $("#pch-fullPagePreview > a").addClass("hidden");
|
|
|
+ $("#pch-fullPagePreview > .carousel-indicators").addClass("hidden");
|
|
|
+ }
|
|
|
const containerSize = document.getElementById("pch-fullPageMedia").getBoundingClientRect();
|
|
|
- return Promise.allSettled(medias.map(media => new Promise(ok => {
|
|
|
- let li = document.createElement("li");
|
|
|
+ let container = document.querySelector("#pch-fullPagePreview .carousel-inner");
|
|
|
+ container.textContent = "";
|
|
|
+ let carouselIndicators = document.querySelector("#pch-fullPagePreview .carousel-indicators");
|
|
|
+ carouselIndicators.textContent = "";
|
|
|
+ return Promise.allSettled(medias.map((media, index) => new Promise(ok => {
|
|
|
+ let item = document.createElement("div");
|
|
|
+ item.className = "carousel-item";
|
|
|
let img = document.createElement("img");
|
|
|
let requestSize = media.resize(containerSize.width, containerSize.height);
|
|
|
const requestSizeQuery = requestSize ? `&w=${requestSize.width}&h=${requestSize.height}` : "";
|
|
|
img.src = `${media.thumbnail}?q=6${requestSizeQuery}`;
|
|
|
- img.className = "img-fluid";
|
|
|
- img.addEventListener("load", () => {
|
|
|
- document.getElementById("pch-fullPagePreviewContainer").classList.remove("loading");
|
|
|
- ok();
|
|
|
- });
|
|
|
- li.appendChild(img);
|
|
|
- document.getElementById("pch-fullPagePreview").appendChild(li);
|
|
|
- })));
|
|
|
+ img.addEventListener("load", () => ok());
|
|
|
+ item.appendChild(img);
|
|
|
+ container.appendChild(item);
|
|
|
+ let carouselIndicator = document.createElement("button");
|
|
|
+ carouselIndicator.type = "button";
|
|
|
+ carouselIndicator.dataset.bsTarget = "#pch-fullPagePreview";
|
|
|
+ carouselIndicator.dataset.bsSlideTo = index;
|
|
|
+ if (!index) {
|
|
|
+ item.classList.add("active");
|
|
|
+ carouselIndicator.classList.add("active");
|
|
|
+ }
|
|
|
+ carouselIndicators.appendChild(carouselIndicator);
|
|
|
+ ++index;
|
|
|
+ }))).finally(() => {
|
|
|
+ document.getElementById("pch-fullPagePreviewContainer").classList.remove("loading");
|
|
|
+ if (medias.length > 1)
|
|
|
+ $(container.parentElement).carousel();
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
function _displayMediaFullPage(media, fileName, imgUrl, metaData, downloadLink, fileIds, writeAccess) {
|
|
|
@@ -320,7 +342,8 @@ $(() => {
|
|
|
document.getElementById("pch-fullPageDetail").appendChild(displayRemoveButton(fileIds));
|
|
|
document.getElementById("pch-fullPageDetail").appendChild(displayTags(metaData?.fixedTags || [], metaData?.tags || [], writeAccess));
|
|
|
document.getElementById("pch-fullPageDetail").appendChild(displayMetas(media, Object.assign({}, metaData || {}), !writeAccess));
|
|
|
- document.getElementById("pch-fullPagePreview").textContent = "";
|
|
|
+ document.querySelector("#pch-fullPagePreview .carousel-inner").textContent = "";
|
|
|
+ $("#pch-fullPagePreview.carousel").carousel("dispose");
|
|
|
return displayImg(media, imgUrl);
|
|
|
}
|
|
|
|