497 lines
14 KiB
JavaScript
497 lines
14 KiB
JavaScript
jQuery(function ($) {
|
|
if ($('#simple-blog-box').length) {
|
|
var swiper = new Swiper('#simple-blog-box', {
|
|
slidesPerView: 3,
|
|
spaceBetween: 30,
|
|
navigation: {
|
|
nextEl: '.elementor-swiper-button-next',
|
|
prevEl: '.elementor-swiper-button-prev',
|
|
},
|
|
loop: true,
|
|
})
|
|
}
|
|
})
|
|
|
|
jQuery(document).ready(function ($) {
|
|
$(document).on(
|
|
'click',
|
|
'.form-control-select-custom .custom-dropdown li',
|
|
function () {
|
|
const $selectedOption = $(this)
|
|
const $customWrapper = $selectedOption.closest(
|
|
'.form-control-select-custom'
|
|
)
|
|
const originalSelectId = $customWrapper.data('product-attribute')
|
|
const $originalSelect = $(`#group_${originalSelectId}`)
|
|
|
|
$customWrapper.find('.custom-dropdown li').removeClass('active')
|
|
$selectedOption.addClass('active')
|
|
|
|
$originalSelect.val($selectedOption.data('value')).change()
|
|
}
|
|
)
|
|
|
|
$(document).on('change', '.form-control-select-standard', function () {
|
|
const $originalSelect = $(this)
|
|
const originalSelectId = $originalSelect.attr('id').replace('group_', '')
|
|
const $customWrapper = $(
|
|
`.form-control-select-custom[data-product-attribute="${originalSelectId}"]`
|
|
)
|
|
const value = $originalSelect.val()
|
|
|
|
$customWrapper.find('.custom-dropdown li').removeClass('active')
|
|
$customWrapper
|
|
.find(`.custom-dropdown li[data-value="${value}"]`)
|
|
.addClass('active')
|
|
})
|
|
|
|
$(document).on('click', '.control-label-nav', function () {
|
|
$('.control-label-nav').not(this).removeClass('active')
|
|
$('.control-label-nav').not(this).parent().parent().removeClass('active')
|
|
$('.control-label-nav')
|
|
.not(this)
|
|
.siblings('.form-control-select-custom')
|
|
.slideUp()
|
|
|
|
$(this).toggleClass('active')
|
|
$(this).parent().parent().toggleClass('active')
|
|
// $(this).siblings('.form-control-select-custom').slideToggle()
|
|
$(this)
|
|
.siblings('.form-control-select-custom')
|
|
.slideToggle(function () {
|
|
const $dropdown = $(this).find('.custom-dropdown')
|
|
const $items = $dropdown.find('li')
|
|
|
|
if ($items.length > 5) {
|
|
const itemHeight = $items.first().outerHeight(true)
|
|
const maxHeight = itemHeight * 5
|
|
const gap = 16
|
|
|
|
$dropdown.css({
|
|
'max-height': maxHeight + gap * 4 + 'px',
|
|
})
|
|
}
|
|
})
|
|
})
|
|
})
|
|
|
|
jQuery(document).ready(function ($) {
|
|
if ($('#product').length) {
|
|
const additionalInfo = $('.product-additional-info')
|
|
|
|
if (additionalInfo.length) {
|
|
const elementsToCopy = []
|
|
|
|
const selectors = ['.single_raty', '#oblicz-rate', '#caraty']
|
|
|
|
selectors.forEach((selector) => {
|
|
const element = additionalInfo.find(selector)
|
|
if (element.length) {
|
|
elementsToCopy.push(element.clone())
|
|
}
|
|
})
|
|
|
|
if (elementsToCopy.length) {
|
|
const item0 = $('.blockreassurance_product .item-0')
|
|
|
|
if (item0.length) {
|
|
const blockRaty = $(
|
|
'<div class="block-raty"><div class="block-raty--wrapper"></div></div>'
|
|
)
|
|
const wrapper = blockRaty.find('.block-raty--wrapper')
|
|
|
|
elementsToCopy.forEach((element) => {
|
|
wrapper.append(element)
|
|
})
|
|
|
|
item0.append(blockRaty)
|
|
}
|
|
}
|
|
}
|
|
|
|
$('.blockreassurance_product .item-0 .block-description').on(
|
|
'click',
|
|
function () {
|
|
const blockRaty = $('.blockreassurance_product .item-0 .block-raty')
|
|
if (blockRaty.length) {
|
|
blockRaty.slideToggle()
|
|
}
|
|
}
|
|
)
|
|
}
|
|
})
|
|
|
|
jQuery(document).ready(function ($) {
|
|
if ($('#product').length) {
|
|
$('.accordion-item').addClass('active')
|
|
$('.accordion-item-body').show()
|
|
|
|
$('.accordion-item-header').click(function () {
|
|
$('.accordion-item-body').slideUp()
|
|
$('.accordion-item').removeClass('active')
|
|
|
|
if ($(this).next('.accordion-item-body').is(':hidden')) {
|
|
$(this).next('.accordion-item-body').slideDown()
|
|
$(this).parent().addClass('active')
|
|
}
|
|
})
|
|
|
|
$('.product-description-box .product-description-box-img').css(
|
|
'top',
|
|
$('#header-panel-box').height() + 64
|
|
)
|
|
}
|
|
})
|
|
|
|
// document.addEventListener('click', (event) => {
|
|
// const toggleButton = event.target.closest('.search-toggle')
|
|
|
|
// if (toggleButton) {
|
|
// const filtersContainer = document.querySelector('#search_filters')
|
|
// const filtersContent = filtersContainer?.querySelector('.content')
|
|
|
|
// if (filtersContainer && filtersContent) {
|
|
// // Pokaż/ukryj zawartość
|
|
// const isContentVisible = filtersContent.style.display === 'grid'
|
|
// filtersContent.style.display = isContentVisible ? 'none' : 'grid'
|
|
|
|
// // Obróć obrazek w przycisku
|
|
// const img = toggleButton.querySelector('img')
|
|
// if (img && img.src.includes('chevron-up.svg')) {
|
|
// img.style.transform = isContentVisible
|
|
// ? 'rotate(0deg)'
|
|
// : 'rotate(180deg)'
|
|
// }
|
|
|
|
// // Dodaj/usuń klasę active na kontenerze
|
|
// filtersContainer.classList.toggle('active', !isContentVisible)
|
|
// }
|
|
// }
|
|
// })
|
|
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
function moveContent(retries = 20) {
|
|
// 20 * 500ms = 10s
|
|
var eratyElement = document.getElementById('eraty')
|
|
var wrapperElement = document.querySelector('.block-raty--wrapper')
|
|
|
|
if (eratyElement && wrapperElement) {
|
|
var eratyContent = eratyElement.innerHTML
|
|
eratyElement.innerHTML = ''
|
|
var newContent = document.createElement('div')
|
|
newContent.innerHTML = eratyContent
|
|
wrapperElement.appendChild(newContent)
|
|
} else if (retries > 0) {
|
|
setTimeout(() => moveContent(retries - 1), 500)
|
|
}
|
|
}
|
|
|
|
moveContent()
|
|
})
|
|
|
|
jQuery(document).ready(function ($) {
|
|
var windowHeight = $(window).height()
|
|
var dropdownMenuHeight = 0
|
|
|
|
function updateWindowHeight() {
|
|
windowHeight = $(window).height()
|
|
}
|
|
|
|
function checkOpenMenus() {
|
|
$('nav.leo-megamenu .leo-top-menu .navbar-nav li .dropdown-menu').each(
|
|
function () {
|
|
if ($(this).is(':visible')) {
|
|
var $menu = $(this)
|
|
dropdownMenuHeight = $menu.outerHeight()
|
|
|
|
// var offsetTop = $menu.offset().top
|
|
var offsetTop = $('header').height() - 20
|
|
// console.log('Offset top: ' + offsetTop + 'px',);
|
|
|
|
var maxHeight = windowHeight - offsetTop - 30
|
|
// console.log('Max height: ' + maxHeight + 'px',);
|
|
|
|
$menu.css('max-height', maxHeight + 'px')
|
|
}
|
|
}
|
|
)
|
|
}
|
|
|
|
function resetMaxHeights() {
|
|
$('nav.leo-megamenu .leo-top-menu .navbar-nav li .dropdown-menu').css(
|
|
'max-height',
|
|
''
|
|
)
|
|
}
|
|
|
|
updateWindowHeight()
|
|
|
|
$(window).resize(function () {
|
|
updateWindowHeight()
|
|
console.log('Window height: ' + windowHeight + 'px')
|
|
})
|
|
|
|
$('nav.leo-megamenu .leo-top-menu .navbar-nav > li').hover(
|
|
function () {
|
|
checkOpenMenus()
|
|
},
|
|
function () {
|
|
resetMaxHeights()
|
|
}
|
|
)
|
|
})
|
|
|
|
jQuery(document).ready(function ($) {
|
|
$('body').on('click', 'section.facet .show-more', function (e) {
|
|
e.preventDefault()
|
|
|
|
let $currentFacet = $(this).closest('section.facet')
|
|
|
|
$('section.facet')
|
|
.not($currentFacet)
|
|
.each(function () {
|
|
$(this).find('.toggle-facets .show-more-text').show()
|
|
$(this).find('.toggle-facets .show-less-text').hide()
|
|
$(this).find('.facet-items-hidden').slideUp()
|
|
})
|
|
|
|
$(this).find('.toggle-facets .show-more-text').toggle()
|
|
$(this).find('.toggle-facets .show-less-text').toggle()
|
|
$currentFacet.find('.facet-items-hidden').slideToggle()
|
|
})
|
|
})
|
|
|
|
// jQuery(document).ready(function ($) {
|
|
// var $btnBox = $('.scroll-brn-box')
|
|
|
|
// $(window).on('scroll', function () {
|
|
// if ($(this).scrollTop() > $(window).height() / 2) {
|
|
// $btnBox.addClass('active')
|
|
// } else {
|
|
// $btnBox.removeClass('active')
|
|
// }
|
|
// })
|
|
// })
|
|
|
|
jQuery(document).ready(function ($) {
|
|
$('body').append(`
|
|
<div class="scroll-brn-box">
|
|
<a href="#header" class="scroll-top-btn">
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="10" height="12" viewBox="0 0 10 12" fill="none">
|
|
<path d="M5 12L5 2" stroke="#fff"></path>
|
|
<path d="M1 5C2.33333 4.91228 5 3.78947 5 -3.56644e-07" stroke="#fff"></path>
|
|
<path d="M9 5C7.66667 4.91228 5 3.78947 5 2.05257e-08" stroke="#fff"></path>
|
|
</svg>
|
|
</a>
|
|
</div>
|
|
`)
|
|
|
|
var $btnBox = $('.scroll-brn-box')
|
|
|
|
$(window).on('scroll', function () {
|
|
if ($(this).scrollTop() > $(window).height() / 2) {
|
|
$btnBox.addClass('active')
|
|
} else {
|
|
$btnBox.removeClass('active')
|
|
}
|
|
})
|
|
});
|
|
|
|
/* custom.js — LEKKIE przeniesienie sekcji .custom-buttons
|
|
Góra: klony top-level bloków (dzieci #category-description) z WYŁĄCZNIE .custom-buttons
|
|
Dół: oryginał bez sekcji .custom-buttons
|
|
NIE DZIAŁA podczas edycji w Elementor/Creative Elements.
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
// --- GUARD: nie uruchamiaj w trybie edycji (Elementor / Creative Elements) ---
|
|
function isEditing() {
|
|
var href = String(location.href || '');
|
|
var ref = String(document.referrer || '');
|
|
var topHref = '';
|
|
try { topHref = String(window.top.location.href || ''); } catch (e) { /* cross-origin fallback */ }
|
|
|
|
// Zbiorcza „słomka” do przeszukania (ramka, referrer, parent)
|
|
var haystack = (href + ' ' + ref + ' ' + topHref).toLowerCase();
|
|
|
|
// 1) Najpewniejsze: kontroler zaplecza CE
|
|
if (haystack.indexOf('controller=adminceeditor') !== -1) return true;
|
|
|
|
// 2) Podgląd/edycja elementora/CE
|
|
if (haystack.indexOf('elementor-preview') !== -1) return true;
|
|
|
|
// 3) Klasy/markery edytora na body w tej ramce
|
|
var body = document.body;
|
|
if (body && /\b(elementor-editor-active|ce-editor-active|ce-editing)\b/i.test(body.className)) return true;
|
|
|
|
// 4) Panele edytora w oknie nadrzędnym (gdy front leci w iframe)
|
|
if (window.self !== window.top) {
|
|
try {
|
|
if (window.top.document.querySelector('#elementor-panel, .elementor-panel, #ce-editor, .ce-editor, .ce-panel')) {
|
|
return true;
|
|
}
|
|
} catch (e) { /* ignoruj brak dostępu */ }
|
|
}
|
|
|
|
// 5) Ręczny wyłącznik
|
|
if (window.__CE_DISABLE_MOVE === true) return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
// Wstaw ZARAZ po definicji isEditing()
|
|
if (isEditing()) return;
|
|
|
|
var SOURCE_SEL = '#category-description';
|
|
var TARGET_SEL = '.row.\\31 11'; // .row.111 (esc)
|
|
var WRAP_ID = 'moved-category-structure';
|
|
var BUTTON_SEC = 'section.custom-buttons, section.custom-buttons1';
|
|
var ANY_SEC = 'section'; // lub 'section.elementor-top-section' jeśli chcesz zawęzić
|
|
|
|
var didFinish = false;
|
|
var obs = null;
|
|
var debounceId = null;
|
|
|
|
function ensureWrapper(target) {
|
|
var wrap = document.getElementById(WRAP_ID);
|
|
if (!wrap) {
|
|
wrap = document.createElement('div');
|
|
wrap.id = WRAP_ID;
|
|
wrap.className = 'moved-category-structure';
|
|
target.parentNode.insertBefore(wrap, target);
|
|
}
|
|
return wrap;
|
|
}
|
|
|
|
function topLevelBlocks(src) {
|
|
var out = [];
|
|
for (var i = 0; i < src.children.length; i++) {
|
|
var el = src.children[i];
|
|
if (el.nodeType === 1) out.push(el);
|
|
}
|
|
return out;
|
|
}
|
|
|
|
function cloneBlockWithOnlyButtons(block) {
|
|
var clone = block.cloneNode(true);
|
|
clone.querySelectorAll(ANY_SEC + ':not(.custom-buttons):not(.custom-buttons1)').forEach(function (sec) {
|
|
sec.remove();
|
|
});
|
|
clone.querySelectorAll('.ce-edit-btn, .ce-edit-outline').forEach(function (n) { n.remove(); });
|
|
if (!clone.querySelector(BUTTON_SEC)) return null;
|
|
return clone;
|
|
}
|
|
|
|
function syncOnce() {
|
|
if (didFinish) return true;
|
|
|
|
var src = document.querySelector(SOURCE_SEL);
|
|
var target = document.querySelector(TARGET_SEL);
|
|
if (!src || !target) return false;
|
|
|
|
var blocks = topLevelBlocks(src);
|
|
var blocksWithButtons = blocks.filter(function (b) { return !!b.querySelector(BUTTON_SEC); });
|
|
if (!blocksWithButtons.length) return false;
|
|
|
|
var wrap = ensureWrapper(target);
|
|
|
|
var frag = document.createDocumentFragment();
|
|
blocksWithButtons.forEach(function (b) {
|
|
var prunedClone = cloneBlockWithOnlyButtons(b);
|
|
if (prunedClone) frag.appendChild(prunedClone);
|
|
});
|
|
|
|
if (!frag.firstChild) return false;
|
|
|
|
while (wrap.firstChild) wrap.removeChild(wrap.firstChild);
|
|
wrap.appendChild(frag);
|
|
|
|
src.querySelectorAll(BUTTON_SEC).forEach(function (sec) {
|
|
if (sec && sec.parentNode) sec.parentNode.removeChild(sec);
|
|
});
|
|
|
|
didFinish = true;
|
|
if (obs) obs.disconnect();
|
|
return true;
|
|
}
|
|
|
|
function trySyncDebounced() {
|
|
if (debounceId) return;
|
|
debounceId = setTimeout(function () {
|
|
debounceId = null;
|
|
if (syncOnce() && obs) obs.disconnect();
|
|
}, 50);
|
|
}
|
|
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', trySyncDebounced, { once: true });
|
|
} else {
|
|
trySyncDebounced();
|
|
}
|
|
|
|
obs = new MutationObserver(trySyncDebounced);
|
|
obs.observe(document.body || document.documentElement, { childList: true, subtree: true });
|
|
|
|
if (window.prestashop && typeof window.prestashop.on === 'function') {
|
|
['updateProductList', 'updatedCart', 'updatedProduct'].forEach(function (ev) {
|
|
window.prestashop.on(ev, trySyncDebounced);
|
|
});
|
|
}
|
|
|
|
(function hookHistory() {
|
|
var _ps = history.pushState, _rs = history.replaceState;
|
|
function onNav() { trySyncDebounced(); }
|
|
history.pushState = function () { _ps.apply(this, arguments); onNav(); };
|
|
history.replaceState = function () { _rs.apply(this, arguments); onNav(); };
|
|
window.addEventListener('popstate', onNav);
|
|
})();
|
|
})();
|
|
|
|
$(document).ready(function () {
|
|
|
|
function toggleChatWidget(isOpen) {
|
|
var $widget = $('div[data-testid="widgetButtonFrame"]');
|
|
var $scrollBox = $('.scroll-brn-box')
|
|
|
|
if ($widget.length) {
|
|
if (isOpen) {
|
|
$widget.hide();
|
|
$scrollBox.hide();
|
|
} else {
|
|
$widget.show();
|
|
$scrollBox.show();
|
|
}
|
|
}
|
|
}
|
|
|
|
function checkCartState() {
|
|
var $cart = $('.elementor-cart__container');
|
|
var isOpen = $cart.hasClass('elementor-cart--shown');
|
|
toggleChatWidget(isOpen);
|
|
}
|
|
|
|
$('a[href*="koszyk"][class*="elementor-button"]').on('click', function () {
|
|
setTimeout(checkCartState, 300);
|
|
});
|
|
|
|
$(document).on('click', '.elementor-cart__close-button', function () {
|
|
setTimeout(checkCartState, 300);
|
|
});
|
|
|
|
$(document).on('click', '.elementor-cart__container.elementor-lightbox.elementor-cart--shown', function (e) {
|
|
if (e.target === this) {
|
|
setTimeout(checkCartState, 300);
|
|
}
|
|
});
|
|
|
|
const cartContainer = document.querySelector('.elementor-cart__container');
|
|
if (cartContainer) {
|
|
const observer = new MutationObserver(() => checkCartState());
|
|
observer.observe(cartContainer, { attributes: true, attributeFilter: ['class'] });
|
|
}
|
|
|
|
checkCartState();
|
|
});
|
|
|