This commit is contained in:
GP_DEV
2025-06-01 12:38:35 +03:00
commit 54eb8e266f
21 changed files with 2178 additions and 0 deletions

View File

@@ -0,0 +1,110 @@
document.addEventListener('DOMContentLoaded', function() {
document.querySelectorAll('.gallery-block').forEach(function(block) {
const blockId = block.getAttribute('data-gallery-id');
initGalleryBlock(blockId);
});
});
function initGalleryBlock(blockId) {
const container = document.getElementById(blockId);
if (!container) return;
const swipers = {};
let lightbox;
function initSwiper(tabId) {
if (swipers[tabId]) {
swipers[tabId].destroy(true, true);
}
swipers[tabId] = new Swiper(`#${blockId} #swiper-${tabId}`, {
slidesPerView: 1.5,
spaceBetween: 20,
loop: true,
centeredSlides: true,
navigation: {
nextEl: `#${blockId} #swiper-${tabId} .swiper-button-next`,
prevEl: `#${blockId} #swiper-${tabId} .swiper-button-prev`,
},
on: {
slideChange: function() {
updateThumbnails(tabId, this.realIndex);
}
}
});
}
function initLightbox(tabId) {
if (lightbox) {
lightbox.destroy();
}
lightbox = GLightbox({
selector: `#${blockId} #tab-${tabId} .glightbox`
});
}
function updateThumbnails(tabId, activeIndex) {
const thumbnails = container.querySelectorAll(`#tab-${tabId} .thumbnail`);
thumbnails.forEach((thumb, index) => {
if (index === activeIndex) {
thumb.classList.add('active', '!border-blue-500');
thumb.classList.remove('border-transparent');
} else {
thumb.classList.remove('active', '!border-blue-500');
thumb.classList.add('border-transparent');
}
});
}
// Табы
container.querySelectorAll('.tab-button').forEach(button => {
button.addEventListener('click', () => {
const tabId = button.getAttribute('data-tab');
container.querySelectorAll('.tab-button').forEach(btn => {
btn.classList.remove('active', 'underline');
btn.classList.add('bg-gray-100');
});
button.classList.add('active', 'underline');
button.classList.remove('bg-gray-100');
container.querySelectorAll('.tab-content').forEach(content => {
content.classList.remove('block');
content.classList.add('hidden');
});
container.querySelector(`#tab-${tabId}`).classList.remove('hidden');
container.querySelector(`#tab-${tabId}`).classList.add('block');
setTimeout(() => {
initSwiper(tabId);
initLightbox(tabId);
}, 100);
});
});
// Thumbnails
container.addEventListener('click', (e) => {
if (e.target.closest('.thumbnail')) {
const thumbnail = e.target.closest('.thumbnail');
const index = parseInt(thumbnail.getAttribute('data-index'));
const activeTab = container.querySelector('.tab-content.block');
const tabId = activeTab.id.replace('tab-', '');
if (swipers[tabId]) {
swipers[tabId].slideToLoop(index);
}
updateThumbnails(tabId, index);
}
});
const firstTab = container.querySelector('.tab-button.active');
if (firstTab) {
const tabId = firstTab.getAttribute('data-tab');
setTimeout(() => {
initSwiper(tabId);
initLightbox(tabId);
}, 100);
}
}

View File

@@ -0,0 +1,136 @@
<?php
// Моковые данные (потом заменить на ACF поля)
$galleryData = [
'reception' => [
'title' => 'Зона ресепшен',
'images' => [
[
'src' => 'https://placehold.co/800x600/4a5568/ffffff?text=Ресепшен+1',
'thumb' => 'https://placehold.co/150x100/4a5568/ffffff?text=Р1',
'alt' => 'Ресепшен 1'
],
[
'src' => 'https://placehold.co/800x600/2d3748/ffffff?text=Ресепшен+2',
'thumb' => 'https://placehold.co/150x100/2d3748/ffffff?text=Р2',
'alt' => 'Ресепшен 2'
],
[
'src' => 'https://placehold.co/800x600/1a202c/ffffff?text=Ресепшен+3',
'thumb' => 'https://placehold.co/150x100/1a202c/ffffff?text=Р3',
'alt' => 'Ресепшен 3'
],
[
'src' => 'https://placehold.co/800x600/718096/ffffff?text=Ресепшен+4',
'thumb' => 'https://placehold.co/150x100/718096/ffffff?text=Р4',
'alt' => 'Ресепшен 4'
]
]
],
'gym' => [
'title' => 'Зона тренажерного зала',
'images' => [
[
'src' => 'https://placehold.co/800x600/dc2626/ffffff?text=Тренажёрный+1',
'thumb' => 'https://placehold.co/150x100/dc2626/ffffff?text=Т1',
'alt' => 'Тренажерный зал 1'
],
[
'src' => 'https://placehold.co/800x600/b91c1c/ffffff?text=Тренажёрный+2',
'thumb' => 'https://placehold.co/150x100/b91c1c/ffffff?text=Т2',
'alt' => 'Тренажерный зал 2'
],
[
'src' => 'https://placehold.co/800x600/991b1b/ffffff?text=Тренажёрный+3',
'thumb' => 'https://placehold.co/150x100/991b1b/ffffff?text=Т3',
'alt' => 'Тренажерный зал 3'
],
[
'src' => 'https://placehold.co/800x600/7f1d1d/ffffff?text=Тренажёрный+4',
'thumb' => 'https://placehold.co/150x100/7f1d1d/ffffff?text=Т4',
'alt' => 'Тренажерный зал 4'
],
[
'src' => 'https://placehold.co/800x600/ef4444/ffffff?text=Тренажёрный+5',
'thumb' => 'https://placehold.co/150x100/ef4444/ffffff?text=Т5',
'alt' => 'Тренажерный зал 5'
]
]
],
'group' => [
'title' => 'Залы для групповых тренировок',
'images' => [
[
'src' => 'https://placehold.co/800x600/059669/ffffff?text=Групповые+1',
'thumb' => 'https://placehold.co/150x100/059669/ffffff?text=Г1',
'alt' => 'Групповые тренировки 1'
],
[
'src' => 'https://placehold.co/800x600/047857/ffffff?text=Групповые+2',
'thumb' => 'https://placehold.co/150x100/047857/ffffff?text=Г2',
'alt' => 'Групповые тренировки 2'
],
[
'src' => 'https://placehold.co/800x600/065f46/ffffff?text=Групповые+3',
'thumb' => 'https://placehold.co/150x100/065f46/ffffff?text=Г3',
'alt' => 'Групповые тренировки 3'
]
]
]
];
$block_id = 'gallery-' . $block['id'];
?>
<div class="gallery-block"
id="<?php echo $block_id; ?>"
data-gallery-id="<?php echo $block_id; ?>">
<div class="container mx-auto">
<h2 class="text-[32px] font-bold mb-[30px]">Галерея</h2>
<div class="flex gap-[10px] mb-[30px]">
<?php foreach ($galleryData as $index => $tab): ?>
<button class="tab-button px-[24px] py-[12px] border-0 rounded-[25px] cursor-pointer transition-all <?php echo $index === 'reception' ? 'active underline' : ''; ?>"
data-tab="<?php echo $index; ?>">
<?php echo esc_html($tab['title']); ?>
</button>
<?php endforeach; ?>
</div>
</div>
<?php foreach ($galleryData as $tab_id => $tab_data): ?>
<div class="tab-content <?php echo $tab_id === 'reception' ? 'block' : 'hidden'; ?>"
id="tab-<?php echo $tab_id; ?>">
<div class="swiper gallery-swiper mb-[20px] h-[440px]" id="swiper-<?php echo $tab_id; ?>">
<div class="swiper-wrapper">
<?php foreach ($tab_data['images'] as $image): ?>
<div class="swiper-slide cursor-pointer min-h-[440px]">
<a href="<?php echo esc_url($image['src']); ?>"
class="glightbox block w-full h-full"
data-gallery="gallery-<?php echo $tab_id; ?>">
<img src="<?php echo esc_url($image['src']); ?>"
alt="<?php echo esc_attr($image['alt']); ?>"
class="w-full h-full object-cover">
</a>
</div>
<?php endforeach; ?>
</div>
<div class="swiper-button-next"></div>
<div class="swiper-button-prev"></div>
</div>
<div class="flex gap-[8px] overflow-x-auto">
<?php foreach ($tab_data['images'] as $thumb_index => $image): ?>
<div class="thumbnail flex-shrink-0 w-[80px] h-[60px] rounded-[5px] overflow-hidden cursor-pointer border-2 border-transparent <?php echo $thumb_index === 0 ? 'active !border-blue-500' : ''; ?>"
data-index="<?php echo $thumb_index; ?>">
<img src="<?php echo esc_url($image['thumb']); ?>"
alt="<?php echo esc_attr($image['alt']); ?>"
class="w-full h-full object-cover">
</div>
<?php endforeach; ?>
</div>
</div>
<?php endforeach; ?>
</div>