shkola/wp-content/themes/dekart/assets/js/camp.js
2026-05-10 23:07:59 +03:00

110 lines
4.2 KiB
JavaScript

var swiper = new Swiper(".camp-swiper-foto-thumbsSlider", {
spaceBetween: 10,
slidesPerView: 7,
freeMode: true,
watchSlidesVisibility: true,
watchSlidesProgress: true,
});
var swiper2 = new Swiper(".camp-swiper-foto", {
spaceBetween: 10,
slidesPerView: 1,
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev",
},
thumbs: {
swiper: swiper,
},
});
const btnCloseModalPrograms = document.querySelector('.btn-close-programs');
const btnCloseModalMentors = document.querySelector('.btn-close-mentors');
const modalPrograms = document.querySelector('.modal-programs');
const modalMentors = document.querySelector('.modal-mentors');
const modalCampRequestForm = document.querySelector('.modal-camp-request-form');
btnCloseModalPrograms.addEventListener("click", function (event) {
modalPrograms.classList.remove('open');
});
btnCloseModalMentors.addEventListener("click", function (event) {
modalMentors.classList.remove('open');
});
document.addEventListener("click", function (event) {
const target = event.target;
if (target.classList.contains("btn-close-request-form-camp")) {
modalCampRequestForm.style="display: none;";
return;
}
const campBtn = target.closest('.btn-write-camp');
if (campBtn) {
if (campBtn.tagName === 'A') event.preventDefault();
modalCampRequestForm.style = "";
return;
}
if (target.classList.contains("btn-program")) {
const card = target.closest('.programs__card');
modalPrograms.querySelector('.modal-programs__img').innerHTML = card.querySelector('.programs__image').outerHTML;
modalPrograms.querySelector('.programs__item_title').textContent = card.querySelector('.programs__name').textContent;
modalPrograms.querySelector('.programs__item_price').textContent = card.querySelector('.programs__price').textContent;
modalPrograms.querySelector('.programs__content').innerHTML = card.querySelector('.programs_content').innerHTML;
modalPrograms.classList.add('open');
return;
}
if (target.classList.contains("btn-mentors")) {
modalMentors.querySelector('.modal-programs__img').innerHTML = target.parentNode.querySelector('.mentors__item_img').outerHTML;
modalMentors.querySelector('.modal-mentors_name').textContent = target.parentNode.querySelector('.mentors__item_name').textContent;
modalMentors.querySelector('.modal-mentors_job').textContent = target.parentNode.querySelector('.mentors__item_text').textContent;
modalMentors.querySelector('.mentors__about-col_text').textContent = target.parentNode.querySelector('.mentor_education').textContent;
modalMentors.querySelector('.modal-mentors__directions').innerHTML = target.parentNode.querySelector('.HTMLdirection').innerHTML;
modalMentors.querySelector('.mentors__experience-col_text').textContent = target.parentNode.querySelector('.mentor_experience').textContent;
modalMentors.querySelector('.modal-additional__education_list').innerHTML = target.parentNode.querySelector('.mentor_add_experience').innerHTML;
modalMentors.classList.add('open');
return;
}
});
(function() {
if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return;
const animatedSections = [
'.hero-media-search__container',
'.about-us__wrapper',
'.infograph h2', '.infograph .camp_text', '.infograph-wrapper',
'.programs h2', '\.programs__grid > article',
'.mentors h2', '.mentors-wrapper > div',
'.routine h2', '.routine__item',
'.foto h2', '.camp-foto-wrapper',
'.camp-reviews-wrapper',
'.camp-faq h2', '.faq-wrapper',
'.camp-contact h2', '.contact-wrapper',
].join(',');
const els = document.querySelectorAll(animatedSections);
if (!els.length) return;
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
observer.unobserve(entry.target);
}
});
}, { threshold: 0.1, rootMargin: '0px 0px -50px 0px' });
els.forEach(el => {
el.classList.add('fade-up');
observer.observe(el);
});
document.querySelectorAll('.programs__grid > article, .mentors-wrapper > div').forEach((card, i) => {
card.style.transitionDelay = (i * 0.08) + 's';
});
})();