document.addEventListener('DOMContentLoaded', function () {
const observer = new MutationObserver(function () {
if (document.body.innerText.includes('Záznam byl v pořádku uložen.')) {
if (typeof gtag === 'function') {
gtag('event', 'newsletter_signup', {
event_category: 'Newsletter',
event_label: 'Homepage',
value: 1
});
}
}
});
observer.observe(document.body, {childList: true, subtree: true});
});
$(document).ready(function() {
const urlParams = new URLSearchParams(window.location.search);
// Pokud je parametr showFilter roven 0
if (urlParams.get('showFilter') === '0') {
// Najde element podle ID a odebere třídu 'visible'
$('#filters').removeClass('visible');
}
function adjustSizeFilter() {
$('#dd\\[\\]279').closest('div').hide();
const bodyClass = $('body').attr('class') || '';
const isTargetCategory = /in-detske-.*(bundy|kabaty|vetrovky)/.test(bodyClass);
if (!isTargetCategory) return;
const sizeMapping = {
"86/92": "80/86",
"98/104": "92/98",
"110/116": "104/110",
"122/128": "116/122",
"134/140": "128/134",
"146/152": "140/146",
"158/164": "152/158"
};
const hiddenSizes = Object.values(sizeMapping);
const $section = $('.filter-section-parametric-id-5');
if ($section.length === 0) return;
$section.find('input[name="pv[]"]').each(function() {
const val = $(this).val();
if (hiddenSizes.includes(val)) {
$(this).closest('div').attr('style', 'display: none !important;');
}
});
Object.keys(sizeMapping).forEach(function(visibleSize) {
const hiddenSize = sizeMapping[visibleSize];
const $visibleInput = $section.find('input[value="' + visibleSize + '"]');
const $hiddenInput = $section.find('input[value="' + hiddenSize + '"]');
if ($visibleInput.length && $hiddenInput.length) {
const hiddenId = $hiddenInput.attr('id').replace('pv[]', '');
const filterId = $visibleInput.data('filter-id');
const paramName = 'pv' + filterId;
let currentDataUrl = $visibleInput.attr('data-url');
const updateUrl = function(url, id, shouldAdd) {
try {
let urlObj = new URL(url, window.location.origin);
let params = new URLSearchParams(urlObj.search);
let val = params.get(paramName);
let ids = val ? val.split(',') : [];
if (shouldAdd) {
if (!ids.includes(id)) ids.push(id);
} else {
ids = ids.filter(i => i !== id);
}
if (ids.length > 0) {
params.set(paramName, ids.join(','));
} else {
params.delete(paramName);
}
urlObj.search = params.toString();
return urlObj.pathname + urlObj.search.replace(/%2C/g, ',');
} catch (e) {
return url;
}
};
const isChecked = $visibleInput.prop('checked');
const newUrl = updateUrl(currentDataUrl, hiddenId, !isChecked);
$visibleInput.attr('data-url', newUrl);
}
});
}
adjustSizeFilter();
document.addEventListener('shoptet.contentUpdated', adjustSizeFilter);
document.addEventListener('shoptet.filtersApplied', adjustSizeFilter);
document.addEventListener('ShoptetDOMPageContentLoaded', adjustSizeFilter);
});
document.addEventListener("DOMContentLoaded", function () {
if (document.querySelector(".blog-photo-carousel")) {
new Swiper(".blog-photo-carousel", {
slidesPerView: 1.25,
spaceBetween: 12,
navigation: {
nextEl: ".blog-carousel-next",
prevEl: ".blog-carousel-prev"
},
breakpoints: {
576: {
slidesPerView: 2.2,
spaceBetween: 16
},
768: {
slidesPerView: 3,
spaceBetween: 16
},
1024: {
slidesPerView: 4,
spaceBetween: 20
}
}
});
}
});