Task: 6607 | Перенос materialize slider на главную

pull/29/head
parent d4a8de8552
commit e7e3a83be4
  1. 11
      wp-content/themes/cosmopet/functions.php
  2. 89
      wp-content/themes/cosmopet/modules/layout/assets/js/gp-main.js
  3. 6
      wp-content/themes/cosmopet/modules/layout/assets/js/materialize.min.js
  4. 69
      wp-content/themes/cosmopet/templates/front-page/front-page.twig

@ -24,6 +24,12 @@ add_filter( 'timber/integrations', function ( array $integrations ): array {
return $integrations;
} );
function theme_enqueue_scripts() {
// Swiper
wp_enqueue_script( 'gp-front-page-materialize', get_template_directory_uri() . '/modules/layout/assets/js/materialize.min.js', array(), null, true );
}
add_action('wp_enqueue_scripts', 'theme_enqueue_scripts');
add_action('timber/init', function() {
// Инициализируем WooCommerce интеграцию
@ -50,6 +56,8 @@ add_action('after_setup_theme', function() {
//Подруключение всех ajax controller если запрос сделан по ajax
@ -1340,4 +1348,5 @@ function custom_handle_activation_request() {
}
}
}
}

@ -414,41 +414,62 @@ if (document.querySelector('.header').classList.contains('white')) {
}
// scroll
document.addEventListener('DOMContentLoaded', function () {
const aboutSwiper = new Swiper('.about_slider', {
loop: true,
centeredSlides: true,
grabCursor: true,
slidesPerView: 'auto',
spaceBetween: 30,
effect: 'coverflow',
coverflowEffect: {
rotate: 0,
stretch: 0,
depth: 150,
modifier: 2.5,
slideShadows: false,
},
navigation: {
nextEl: '.about_slider_nav.next',
prevEl: '.about_slider_nav.prev',
},
breakpoints: {
0: {
slidesPerView: 1.5,
},
480: {
slidesPerView: 2.5,
},
768: {
slidesPerView: 3.5,
},
1024: {
slidesPerView: 5,
},
},
// document.addEventListener('DOMContentLoaded', function () {
// const aboutSwiper = new Swiper('.about_slider', {
// loop: true,
// centeredSlides: true,
// grabCursor: true,
// slidesPerView: 'auto',
// spaceBetween: 30,
// effect: 'coverflow',
// coverflowEffect: {
// rotate: 0,
// stretch: 0,
// depth: 150,
// modifier: 2.5,
// slideShadows: false,
// },
// navigation: {
// nextEl: '.about_slider_nav.next',
// prevEl: '.about_slider_nav.prev',
// },
// breakpoints: {
// 0: {
// slidesPerView: 1.5,
// },
// 480: {
// slidesPerView: 2.5,
// },
// 768: {
// slidesPerView: 3.5,
// },
// 1024: {
// slidesPerView: 5,
// },
// },
// });
// });
var slider = carousel_init();
function carousel_init() {
var carousel = document.querySelectorAll('.carousel');
var options = {
numVisible: window.innerWidth > 421 ? 5 : 3,
indicators: false // Removed dots
};
var instances = M.Carousel.init(carousel, options);
document.querySelectorAll('.about_slider_nav').forEach(btn => {
btn.addEventListener('click', function (e) {
if (e.target.closest('button').classList.contains('next')) {
instances[0].next();
} else {
instances[0].prev();
}
});
});
});
return instances;
}
document.addEventListener('DOMContentLoaded', function () {
const petsSlider = new Swiper(".discount_cosmodog__slider", {

File diff suppressed because one or more lines are too long

@ -95,69 +95,66 @@
{% endif %}
<div class="container-fluid">
<div class="about_slider swiper">
<div class="swiper-buttons">
<button class="about_slider_nav prev">
<img src="/wp-content/themes/cosmopet/static/front-page/img/slider-prev.svg" alt="">
</button>
<button class="about_slider_nav next">
<img src="/wp-content/themes/cosmopet/static/front-page/img/slider-next.svg" alt="">
</button>
</div>
<div class="swiper-wrapper">
<div class="slide swiper-slide carousel-item">
<div class="about_slider">
<button class="about_slider_nav next">
<img src="/wp-content/themes/cosmopet/static/front-page/img/slider-next.svg" alt="Next">
</button>
<button class="about_slider_nav prev">
<img src="/wp-content/themes/cosmopet/static/front-page/img/slider-prev.svg" alt="Previous">
</button>
<div class="carousel">
<div class="carousel-item">
<img src="/wp-content/themes/cosmopet/static/front-page/img/about_slider-img1.png" alt="">
<div class="slide_info">
<h3 class="slide_title">Пребиотики MOS и FOS</h3>
<h3 class="slide_title">
{% if site_region == 'ru' %}МОС и ФОС пребиотики{% elseif site_region == 'ae' %}MOS and FOS prebiotics{% endif %}
</h3>
<p class="slide_text">
Поддерживают здоровый баланс кишечной микрофлоры и снижают риск
возникновения
заболеваний кишечника
{% if site_region == 'ru' %}Поддерживают здоровый баланс микрофлоры кишечника и снижают риск заболеваний ЖКТ{% elseif site_region == 'ae' %}Maintain a healthy balance of intestinal microflora and reduces the risk of intestinal diseases{% endif %}
</p>
</div>
</div>
<div class="slide swiper-slide carousel-item">
<div class="carousel-item">
<img src="/wp-content/themes/cosmopet/static/front-page/img/about_slider-img2.png" alt="">
<div class="slide_info">
<h3 class="slide_title">Омега 3 и жирные кислоты</h3>
<h3 class="slide_title">
{% if site_region == 'ru' %}Омега 3 и жирные кислоты{% elseif site_region == 'ae' %}Omega 3 and fatty acids{% endif %}
</h3>
<p class="slide_text">
Улучшают работу мозга и поддерживают его активность в норме,
сохраняют здоровье
кожи и блеск шерсти
{% if site_region == 'ru' %}Улучшают работу мозга и сохраняют его активность, обеспечивают здоровье кожи и блеск шерсти{% elseif site_region == 'ae' %}They improve the functioning of the brain and maintain its normal activity, preserve the health of the skin and the shine of the coat{% endif %}
</p>
</div>
</div>
<div class="slide swiper-slide swiper-slide-active carousel-item">
<div class="carousel-item active">
<img src="/wp-content/themes/cosmopet/static/front-page/img/about_slider-img3.png" alt="">
<div class="slide_info">
<h3 class="slide_title">Юкка Шидигера</h3>
<h3 class="slide_title">
{% if site_region == 'ru' %}Юкка Шидигера{% elseif site_region == 'ae' %}Yucca schidigera{% endif %}
</h3>
<p class="slide_text">
Стимулирует пищеварение и связывает вещества, отвечающие за
специфический запах
стула. Результат: туалет как по часам<br> (а неприятного запаха<br> – меньше).
{% if site_region == 'ru' %}Стимулирует пищеварение, связывает вещества, вызывающие неприятный запах фекалий. Результат — регулярный стул с меньшим запахом{% elseif site_region == 'ae' %}It stimulates digestion, even binding the substances responsible for the specific smell of dog and cat faeces. As a result bowel-emptying occurs like clockwork (and with less odour!){% endif %}
</p>
</div>
</div>
<div class="slide swiper-slide carousel-item">
<div class="carousel-item">
<img src="/wp-content/themes/cosmopet/static/front-page/img/about_slider-img4.png" alt="">
<div class="slide_info">
<h3 class="slide_title">Кальций, фосфор и витамин D</h3>
<h3 class="slide_title">
{% if site_region == 'ru' %}Кальций, фосфор и витамин D{% elseif site_region == 'ae' %}Calcium, phosphorus and vitamin D{% endif %}
</h3>
<p class="slide_text">
В оптимальном соотношении поддерживают здоровье костей,
способствуют
восстановлению суставов и поддержанию их подвижности
{% if site_region == 'ru' %}В оптимальном соотношении поддерживают здоровье костей, способствуют восстановлению суставов и подвижности{% elseif site_region == 'ae' %}In their optimal ratio, they support bone health, promote joint restoration and help maintain mobility{% endif %}
</p>
</div>
</div>
<div class="slide swiper-slide carousel-item">
<div class="carousel-item">
<img src="/wp-content/themes/cosmopet/static/front-page/img/about_slider-img5.png" alt="">
<div class="slide_info">
<h3 class="slide_title">E-protein</h3>
<h3 class="slide_title">
{% if site_region == 'ru' %}Энтопротеин{% elseif site_region == 'ae' %}E-protein{% endif %}
</h3>
<p class="slide_text">
Легкоперевариваемый энтопротеин, который к тому же превосходит по
питательности
традиционное мясо. Будучи новым источником белка не вызывает аллергии<br> у питомцев
{% if site_region == 'ru' %}Легкоперевариваемый энтопротеин, который к тому же превосходит по питательности традиционное мясо. Будучи новым источником белка, не вызывает аллергии у питомцев{% elseif site_region == 'ae' %}An easily digestible E-protein, nutritionally superior to traditional meat; being a novel source of protein, does not cause allergies in pets{% endif %}
</p>
</div>
</div>

Loading…
Cancel
Save