|
|
|
|
@@ -768,21 +768,12 @@ document.querySelectorAll('.close-popup').forEach((btn) => {
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// overlay?.addEventListener('click', (e) => {
|
|
|
|
|
// if (e.target === overlay) {
|
|
|
|
|
// overlay.classList.remove('active');
|
|
|
|
|
// document.body.style.overflow = '';
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
function openImagePopup(src) {
|
|
|
|
|
// const img = imagePopup?.querySelector('img');
|
|
|
|
|
const img = imagePopup.querySelector('.img-popup-img');
|
|
|
|
|
const video = imagePopup.querySelector('.video-popup-player');
|
|
|
|
|
|
|
|
|
|
// if (img && src) {
|
|
|
|
|
// img.src = src;
|
|
|
|
|
// }
|
|
|
|
|
video.pause();
|
|
|
|
|
// video.src = '';
|
|
|
|
|
video.style.display = 'none';
|
|
|
|
|
@@ -810,9 +801,7 @@ function openVideoPopup(src, poster = '') {
|
|
|
|
|
|
|
|
|
|
video.style.display = 'block';
|
|
|
|
|
video.pause();
|
|
|
|
|
// if (poster) {
|
|
|
|
|
// video.poster = poster;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
video.removeAttribute('poster');
|
|
|
|
|
|
|
|
|
|
if (poster) {
|
|
|
|
|
@@ -820,8 +809,6 @@ function openVideoPopup(src, poster = '') {
|
|
|
|
|
}
|
|
|
|
|
video.src = src;
|
|
|
|
|
video.load();
|
|
|
|
|
// video.currentTime = 0;
|
|
|
|
|
// video.play();
|
|
|
|
|
|
|
|
|
|
imagePopup.classList.add('active');
|
|
|
|
|
document.body.style.overflow = 'hidden';
|
|
|
|
|
@@ -879,12 +866,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
|
|
renderMedia(mediaData);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// document.querySelectorAll('.wrapper').forEach((item) => {
|
|
|
|
|
// item.addEventListener('click', (e) => {
|
|
|
|
|
// e.preventDefault();
|
|
|
|
|
// openPortfolioPopup();
|
|
|
|
|
// });
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
document.querySelector('.gallery-thumbnail .wrapper')?.addEventListener('click', (e) => {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
openPopupByIndex(0);
|
|
|
|
|
@@ -956,121 +938,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
|
|
updateUI();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// const relatedCards = [
|
|
|
|
|
// ...document.querySelectorAll('[data-related-section="gallery"] .related-card'),
|
|
|
|
|
// ];
|
|
|
|
|
|
|
|
|
|
// let currentPopupIndex = 0;
|
|
|
|
|
|
|
|
|
|
// function openPopupByIndex(index) {
|
|
|
|
|
// const card = relatedCards[index];
|
|
|
|
|
// if (!card) return;
|
|
|
|
|
|
|
|
|
|
// currentPopupIndex = index;
|
|
|
|
|
// const media = card.querySelector('.media-container');
|
|
|
|
|
|
|
|
|
|
// if (!media) return;
|
|
|
|
|
// const type = media.dataset.type;
|
|
|
|
|
// const src = media.dataset.src;
|
|
|
|
|
|
|
|
|
|
// if (type === 'image') {
|
|
|
|
|
// const popupImg = imagePopup.querySelector('.img-wrapper img');
|
|
|
|
|
|
|
|
|
|
// if (popupImg) {
|
|
|
|
|
// popupImg.src = src;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// imagePopup.classList.add('active');
|
|
|
|
|
// } else if (type === 'video') {
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// document.body.style.overflow = 'hidden';
|
|
|
|
|
|
|
|
|
|
// updatePopupButtons();
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// function updatePopupButtons() {
|
|
|
|
|
// const allPopups = document.querySelectorAll('.portfolio-popup.active');
|
|
|
|
|
|
|
|
|
|
// allPopups.forEach((popup) => {
|
|
|
|
|
// const nextBtn = popup.querySelector('.next-popup');
|
|
|
|
|
// const prevBtn = popup.querySelector('.prev-popup');
|
|
|
|
|
|
|
|
|
|
// if (!nextBtn || !prevBtn) return;
|
|
|
|
|
|
|
|
|
|
// if (currentPopupIndex <= 0) {
|
|
|
|
|
// prevBtn.classList.add('disabled');
|
|
|
|
|
// } else {
|
|
|
|
|
// prevBtn.classList.remove('disabled');
|
|
|
|
|
// }
|
|
|
|
|
// if (currentPopupIndex >= relatedCards.length - 1) {
|
|
|
|
|
// nextBtn.classList.add('disabled');
|
|
|
|
|
// } else {
|
|
|
|
|
// nextBtn.classList.remove('disabled');
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// relatedCards.forEach((card, index) => {
|
|
|
|
|
// card.addEventListener('click', (e) => {
|
|
|
|
|
// if (e.target.closest('.play-btn')) return;
|
|
|
|
|
// if (e.target.closest('.related-content p')) return;
|
|
|
|
|
// openPopupByIndex(index);
|
|
|
|
|
// });
|
|
|
|
|
// });
|
|
|
|
|
// document.querySelectorAll('.next-popup').forEach((btn) => {
|
|
|
|
|
// btn.addEventListener('click', () => {
|
|
|
|
|
// if (currentPopupIndex >= relatedCards.length - 1) return;
|
|
|
|
|
|
|
|
|
|
// currentPopupIndex++;
|
|
|
|
|
// overlay.classList.remove('active');
|
|
|
|
|
// imagePopup.classList.remove('active');
|
|
|
|
|
// openPopupByIndex(currentPopupIndex);
|
|
|
|
|
// });
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// document.querySelectorAll('.prev-popup').forEach((btn) => {
|
|
|
|
|
// btn.addEventListener('click', () => {
|
|
|
|
|
// if (currentPopupIndex <= 0) return;
|
|
|
|
|
|
|
|
|
|
// currentPopupIndex--;
|
|
|
|
|
// overlay.classList.remove('active');
|
|
|
|
|
// imagePopup.classList.remove('active');
|
|
|
|
|
|
|
|
|
|
// openPopupByIndex(currentPopupIndex);
|
|
|
|
|
// });
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// window.addEventListener('keydown', (e) => {
|
|
|
|
|
// const popupIsOpen =
|
|
|
|
|
// overlay.classList.contains('active') || imagePopup.classList.contains('active');
|
|
|
|
|
|
|
|
|
|
// if (!popupIsOpen) return;
|
|
|
|
|
|
|
|
|
|
// if (e.key === 'ArrowRight') {
|
|
|
|
|
// if (currentPopupIndex < relatedCards.length - 1) {
|
|
|
|
|
// currentPopupIndex++;
|
|
|
|
|
// overlay.classList.remove('active');
|
|
|
|
|
// imagePopup.classList.remove('active');
|
|
|
|
|
// openPopupByIndex(currentPopupIndex);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// if (e.key === 'ArrowLeft') {
|
|
|
|
|
// if (currentPopupIndex > 0) {
|
|
|
|
|
// currentPopupIndex--;
|
|
|
|
|
// overlay.classList.remove('active');
|
|
|
|
|
// imagePopup.classList.remove('active');
|
|
|
|
|
// openPopupByIndex(currentPopupIndex);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// if (e.key === 'Escape') {
|
|
|
|
|
// overlay.classList.remove('active');
|
|
|
|
|
// imagePopup.classList.remove('active');
|
|
|
|
|
// document.body.style.overflow = '';
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
const relatedCards = [
|
|
|
|
|
...document.querySelectorAll('[data-related-section="gallery"] .related-card'),
|
|
|
|
|
];
|
|
|
|
|
@@ -1089,27 +957,6 @@ const galleryItems = [
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// function openPopupByIndex(index) {
|
|
|
|
|
// const card = relatedCards[index];
|
|
|
|
|
|
|
|
|
|
// if (!card) return;
|
|
|
|
|
|
|
|
|
|
// currentPopupIndex = index;
|
|
|
|
|
|
|
|
|
|
// const media = card.querySelector('.media-container');
|
|
|
|
|
|
|
|
|
|
// const type = media.dataset.type;
|
|
|
|
|
// const src = media.dataset.src;
|
|
|
|
|
// const poster = media.dataset.poster;
|
|
|
|
|
|
|
|
|
|
// if (type === 'video') {
|
|
|
|
|
// openVideoPopup(src, poster);
|
|
|
|
|
// } else {
|
|
|
|
|
// openImagePopup(src);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// updatePopupButtons();
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
function openPopupByIndex(index) {
|
|
|
|
|
const item = galleryItems[index];
|
|
|
|
|
@@ -1140,17 +987,7 @@ function openPopupByIndex(index) {
|
|
|
|
|
|
|
|
|
|
updatePopupButtons();
|
|
|
|
|
}
|
|
|
|
|
// function updatePopupButtons() {
|
|
|
|
|
// const nextBtn = imagePopup.querySelector('.next-popup');
|
|
|
|
|
// const prevBtn = imagePopup.querySelector('.prev-popup');
|
|
|
|
|
|
|
|
|
|
// if (!nextBtn || !prevBtn) return;
|
|
|
|
|
// prevBtn.disabled = currentPopupIndex === 0;
|
|
|
|
|
// nextBtn.disabled = currentPopupIndex === galleryItems.length - 1;
|
|
|
|
|
|
|
|
|
|
// prevBtn.classList.toggle('disabled', currentPopupIndex === 0);
|
|
|
|
|
// nextBtn.classList.toggle('disabled', currentPopupIndex === galleryItems.length - 1);
|
|
|
|
|
// }
|
|
|
|
|
function updatePopupButtons() {
|
|
|
|
|
document.querySelectorAll('.next-popup').forEach((btn) => {
|
|
|
|
|
btn.disabled = currentPopupIndex === galleryItems.length - 1;
|
|
|
|
|
@@ -1164,13 +1001,7 @@ function updatePopupButtons() {
|
|
|
|
|
btn.classList.toggle('disabled', currentPopupIndex === 0);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
// relatedCards.forEach((card, index) => {
|
|
|
|
|
// card.addEventListener('click', (e) => {
|
|
|
|
|
// if (e.target.closest('.play-btn')) return;
|
|
|
|
|
|
|
|
|
|
// openPopupByIndex(index);
|
|
|
|
|
// });
|
|
|
|
|
// });
|
|
|
|
|
document.querySelector('.gallery-thumbnail .wrapper')?.addEventListener('click', (e) => {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
openPopupByIndex(0);
|
|
|
|
|
@@ -1183,17 +1014,7 @@ relatedCards.forEach((card, index) => {
|
|
|
|
|
openPopupByIndex(index + 1);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
// imagePopup.querySelector('.next-popup').addEventListener('click', () => {
|
|
|
|
|
// if (currentPopupIndex >= galleryItems.length - 1) return;
|
|
|
|
|
|
|
|
|
|
// openPopupByIndex(currentPopupIndex + 1);
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// imagePopup.querySelector('.prev-popup').addEventListener('click', () => {
|
|
|
|
|
// if (currentPopupIndex <= 0) return;
|
|
|
|
|
|
|
|
|
|
// openPopupByIndex(currentPopupIndex - 1);
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
document.querySelectorAll('.next-popup').forEach((btn) => {
|
|
|
|
|
btn.addEventListener('click', () => {
|
|
|
|
|
|