if( $(".realizacja-single-gallery").length)
{
$.cachedScript("/js/masonry_gzip.js", function ()
initMasonry(); // zaczytanie funkcji wykorzystującej dodatkową bibliotękę
}
//Dodatkowo małe zmiany w /data/gzip.php
if( $far[0] == '/js/all.js')
$far = getAllFiles("js/", "(.+).js", "(markerwithlabel|masonry).js");
function OwlFlexItemWidth($owl)
$owl.find('.owl-item').css('min-width', 'auto');
var firstWidth = $owl.find('.owl-item').first().outerWidth();
// Zaokrąglenie do 0.5 lub pełnej liczby
var widthRounded = Math.round(firstWidth * 2) / 2; // np. 283.797 → 284 lub 283.5
$owl.find('.owl-item').css('min-width', widthRounded + 'px');
// Przeliczenie szerokości całego owl-stage
var totalWidth = 0;
$owl.find('.owl-item').each(function()
totalWidth += $(this).outerWidth(true); // true = uwzględnia margin
});
$owl.find('.owl-stage').css('width', totalWidth + 'px');
function markLastRowFinal()
const winWidth = window.innerWidth;
// kolumny w zależności od szerokości okna
let columns = 1;
if (winWidth >= 1200) columns = 4;
else if (winWidth >= 992) columns = 3;
else if (winWidth >= 481) columns = 2;
$('.pagination-row').each(function ()
const $row = $(this);
const $items = $row.find('.product-item');
// reset klas
$items.removeClass(function (_, className)
return (className.match(/is-last-row*|is-before-last-row/g) || []).join(' ');
if ($items.length === 0) return; //
const tops = [];
$items.each(function ()
const top = $(this).offset().top;
if (!tops.includes(top)) tops.push(top);
if (tops.length < 2) return;
const maxTop = Math.max(...tops);
$lastRowItems = $items.filter(function ()
return $(this).offset().top === maxTop;
const count = $lastRowItems.length; /
$lastRowItems .addClass('is-last-row').addClass('is-last-row-' + count);
if (count === 1)
$lastRowItems.addClass('is-last-row-one-item');
else
$lastRowItems.first().addClass('is-last-row-first'); $lastRowItems.last().addClass('is-last-row-last');
if (count < columns)
let $target = $lastRowItems.first().prev('.product-item');
if ($target && $target.length)
$target.addClass('is-before-last-row');
$(window).on('load', markLastRowFinal);
$(window).on('resize', function ()
clearTimeout(window.__lastRowTimer); window.__lastRowTimer = setTimeout(markLastRowFinal, 150);