You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
cosmopet-architecture/wp-content/themes/cosmopet/static/js/js-single-product/gp-product.js

152 lines
4.0 KiB

'use strict';
// slider gallery modal
const gallery = new Swiper('.gallery__slider', {
spaceBetween: 100,
pagination: {
el: '.swiper-pagination',
},
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
scrollbar: {
el: '.swiper-scrollbar',
},
});
let paginationButtons = document.querySelectorAll('.gallery-pagination__item');
paginationButtons.forEach(button => {
let index = button.dataset.countImg;
button.onclick = function () {
gallery.slideTo(index);
}
})
// open gallery
let detailImage= document.querySelectorAll('.detail__image');
detailImage.forEach(button => {
let index = button.dataset.countImg;
button.onclick = function () {
gallery.slideTo(index);
document.querySelector('.gallery').classList.add('active');
}
})
// close gallery
document.querySelector('.gallery__close').onclick = function () {
document.querySelector('.gallery').classList.remove('active');
}
// slider gallery modal
// slider gallery main phone
// createGalleryPhone('.detail__images', '.detail-images__wrapper', '.detail__image', 980);
const detailPhone = new Swiper('.detail__images-phone', {
spaceBetween: 100,
pagination: {
el: '.swiper-pagination',
},
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
scrollbar: {
el: '.swiper-scrollbar',
},
});
let detailImagesPhones = document.querySelectorAll('.detail-images-phone__image-block');
detailImagesPhones.forEach(button => {
button.onclick = function (e) {
let index = button.dataset.countImg;
gallery.slideTo(index);
document.querySelector('.gallery').classList.add('active');
}
})
// slider gallery main phone
// detail catalog
const detailCatalot = new Swiper('.detail__catalot', {
// Navigation arrows
navigation: {
nextEl: '.detail-catalot-control__button.next',
prevEl: '.detail-catalot-control__button.prev',
},
breakpoints: {
1600: {
slidesPerView: 4,
},
1200: {
slidesPerView: 3,
},
780: {
slidesPerView: 2,
},
100: {
slidesPerView: 1.1,
spaceBetween: 20
},
}
});
// detail catalog
//
//
//
jQuery(document).ready(function($) {
// Основные радио-кнопки выбора типа покупки
const $oneTimeRadio = $('input[value="no"][name="subscribe-to-action-input"]');
const $subscribeRadio = $('input[value="yes"][name="subscribe-to-action-input"]');
// Все чекбоксы вариантов подписки
const $subscriptionOptions = $('.wcsatt-options-product input[type="radio"]');
// Обработчик для One-time
$oneTimeRadio.on('change', function() {
if ($(this).is(':checked')) {
// Снимаем выделение со всех вариантов подписки
$subscriptionOptions.prop('checked', false);
}
});
// Обработчик для Subscribe
$subscribeRadio.on('change', function() {
if ($(this).is(':checked')) {
// Снимаем выделение с One-time
$oneTimeRadio.prop('checked', false);
// Если ни один вариант подписки не выбран, выбираем первый
if ($subscriptionOptions.filter(':checked').length === 0) {
$subscriptionOptions.first().prop('checked', true);
}
}
});
// Обработчик для вариантов подписки
$subscriptionOptions.on('change', function() {
if ($(this).is(':checked')) {
// Снимаем выделение с One-time
$oneTimeRadio.prop('checked', false);
// Активируем Subscribe
$subscribeRadio.prop('checked', true);
}
});
});