diff --git a/wp-content/themes/cosmopet/modules/header/module-controller.php b/wp-content/themes/cosmopet/modules/header/module-controller.php index 8d074cc..09f52bd 100644 --- a/wp-content/themes/cosmopet/modules/header/module-controller.php +++ b/wp-content/themes/cosmopet/modules/header/module-controller.php @@ -1,4 +1,10 @@ \ No newline at end of file diff --git a/wp-content/themes/cosmopet/modules/layout/module-controller.php b/wp-content/themes/cosmopet/modules/layout/module-controller.php index f59beeb..c41f59c 100644 --- a/wp-content/themes/cosmopet/modules/layout/module-controller.php +++ b/wp-content/themes/cosmopet/modules/layout/module-controller.php @@ -1,9 +1,8 @@ by class "scroll_link" -const smoothLinks = document.querySelectorAll('.scroll_link'); -for (let smoothLink of smoothLinks) { - smoothLink.addEventListener('click', function (e) { - e.preventDefault(); - const id = smoothLink.getAttribute('href'); - - document.querySelector(id).scrollIntoView({ - behavior: 'smooth', - block: 'start' - }); - }); -}; -// Header menu document.addEventListener('DOMContentLoaded', function () { - let body = document.querySelector('body'); - let header = document.querySelector('.header'); - jQuery('.header-lang').on('click', function(){ - jQuery(this).find('ul').toggle() - }) - - /* Здесь было открытие/закрытие моб.меню */ - // let headerBars = document.querySelector('.header_bars'); - // let headerClose = document.querySelector('.header_close'); - // jQuery(".header_bars").on('click', function(){jQuery('.header_navs').toggleClass('active')}) - // headerBars.addEventListener('click', function () { - // header.classList.add('mobile-open'); - // body.classList.add('no-scroll'); - // }); - - // function removeActiveClass() { - // header.classList.remove('mobile-open'); - // body.classList.remove('no-scroll'); - // } - - // headerClose.addEventListener('click', removeActiveClass); - - jQuery(".header_bars").on('click', function(){jQuery('.header_navs').toggleClass('active')}) - - /* start: aboutSlider */ - // var slider = carousel_init(); - // function carousel_init() { - // var carousel = document.querySelectorAll('.carousel'); - // if (window.innerWidth > 421) { - // var options = { - // numVisible: 5, - // // indicators: true, - // } - // } else if (window.innerWidth < 421) { - // var options = { - // numVisible: 3, - // // indicators: true, - // } - // } - // var instances = M.Carousel.init(carousel, options); - // document.querySelectorAll('.about_slider_nav').forEach(btn => { - // btn.addEventListener('click', function (e) { - // // window.t = e.target.closest('button') - // // console.log(t) - // if (e.target.closest('button').classList.contains('next')) { - // instances[0].next(); - // }else{ - // instances[0].prev(); - // } - // }); - // }); - // return instances; - // } - - /* GP | Start: Анимация в блоке "Отзывы ветеринаров" */ - // const reviewsItems = jQuery('.reviews_item') - // setInterval(() => { - // if (jQuery(reviewsItems[0]).is(':visible')) { - // jQuery(reviewsItems[0]).hide() - // jQuery(reviewsItems[1]).show() - // } else { - // jQuery(reviewsItems[0]).show() - // jQuery(reviewsItems[1]).hide() - // } - - // setTimeout(() => { - // if (jQuery(reviewsItems[2]).is(':visible')) { - // jQuery(reviewsItems[2]).hide() - // jQuery(reviewsItems[3]).show() - // } else { - // jQuery(reviewsItems[2]).show() - // jQuery(reviewsItems[3]).hide() - // } - // }, 3000); - - // setTimeout(() => { - // if (jQuery(reviewsItems[4]).is(':visible')) { - // jQuery(reviewsItems[4]).hide() - // jQuery(reviewsItems[5]).show() - // } else { - // jQuery(reviewsItems[4]).show() - // jQuery(reviewsItems[5]).hide() - // } - // }, 6000); - // }, 9000); - /* GP | End: Анимация в блоке "Отзывы ветеринаров" */ - - /* GP | Start: blogosphere__swiper */ - - // function carousel_init_new() { - // const carousel = document.querySelector('.blogosphere__swiper'); - // let options = {}; // Переменная для хранения текущих параметров - - // // Функция для обновления настроек в зависимости от размера экрана - // function setOptions() { - // if (window.innerWidth > 421) { - // options = { - // numVisible: 5, - // onCycleTo: (el) => { - // const slides = carousel.querySelectorAll('.carousel-item'); - - // slides.forEach((slide) => { - // const video = slide.querySelector('video'); - // if (video) { - // video.pause(); - // } - // }); - // } - // }; - // } else { - // options = { - // numVisible: 3, - // }; - // } - - - // } - - // // Инициализация карусели с текущими параметрами - // function initCarousel() { - // setOptions(); // Устанавливаем параметры при инициализации - // M.Carousel.init(carousel, options); // Инициализация карусели с новыми параметрами - // } - - // // Инициализация карусели при загрузке страницы - // initCarousel(); - - // // Обновляем карусель при изменении размера окна - // window.addEventListener('resize', function () { - // // Уничтожаем старую карусель и создаем новую с обновленными параметрами - // if (carousel) { - // carousel.M_Carousel.destroy(); - // } - // initCarousel(); - // }); - - // // Прямое добавление обработчиков на кнопки - // const nextBtn = document.querySelector('.blogosphere__btn.next'); - // const prevBtn = document.querySelector('.blogosphere__btn.prev'); - - // if (nextBtn && prevBtn) { - // nextBtn.addEventListener('click', (e) => { - // e.preventDefault(); - // e.stopPropagation(); - // if (carousel) { - // carousel.M_Carousel.next(); - // } - // }); - - // prevBtn.addEventListener('click', (e) => { - // e.preventDefault(); - // e.stopPropagation(); - // if (carousel) { - // carousel.M_Carousel.prev(); - // } - // }); - // } - // } - - // // Инициализация карусели - // carousel_init_new(); - - /* GP | End: */ - - let home = new Swiper(".home__swiper ", { slidesPerView: 1, spaceBetween: 1000, @@ -439,7 +260,6 @@ document.addEventListener('DOMContentLoaded', function () { }) }); - document.addEventListener('DOMContentLoaded', function () { const sliders = document.querySelectorAll('.reviews_item-swiper'); sliders.forEach((slider, index) => { diff --git a/wp-content/themes/cosmopet/static/js/header.js b/wp-content/themes/cosmopet/static/js/header.js new file mode 100644 index 0000000..fafc334 --- /dev/null +++ b/wp-content/themes/cosmopet/static/js/header.js @@ -0,0 +1,9 @@ +document.addEventListener('DOMContentLoaded', function () { + let body = document.querySelector('body'); + let header = document.querySelector('.header'); + jQuery('.header-lang').on('click', function(){ + jQuery(this).find('ul').toggle() + }) + + jQuery(".header_bars").on('click', function(){jQuery('.header_navs').toggleClass('active')}) +}) \ No newline at end of file diff --git a/wp-content/themes/cosmopet/static/js/script.js b/wp-content/themes/cosmopet/static/js/script.js new file mode 100644 index 0000000..39144ed --- /dev/null +++ b/wp-content/themes/cosmopet/static/js/script.js @@ -0,0 +1,12 @@ +const smoothLinks = document.querySelectorAll('.scroll_link'); +for (let smoothLink of smoothLinks) { + smoothLink.addEventListener('click', function (e) { + e.preventDefault(); + const id = smoothLink.getAttribute('href'); + + document.querySelector(id).scrollIntoView({ + behavior: 'smooth', + block: 'start' + }); + }); +};