Collections
{
loading = true;
fetch($event.detail.new_url)
.then(response => response.text())
.then(data => {
let html_div = document.createElement('div');
html_div.innerHTML = data;
const button = document.querySelector('#collections_pagination .button');
const href = button.getAttribute('href');
const url = new URL(href, window.location.origin);
const pageValue = url.searchParams.get('page');
if(pageValue && parseInt(pageValue) == parseInt(button.getAttribute('data-total-pages'))) {
document.querySelector('.pagination-navigation').style.display = 'none';
}
let html_dom = html_div.querySelector('#collections-grid').innerHTML;
if (document.querySelector('#collections-grid')){
document.querySelector('#collections-grid').innerHTML += html_dom;
}
showingResultCount = document.querySelectorAll('.collection-card').length
calculateProgressBarWidth(showingResultCount)
if (html_div.querySelector('#collections_pagination')){
let pagination_dom = html_div.querySelector('#collections_pagination').innerHTML;
if(document.querySelector('#collections_pagination')) {
document.querySelector('#collections_pagination').innerHTML = pagination_dom;
}
}
const elements = document.querySelectorAll('.product_card--content');
let maxHeight = 0;
elements.forEach(element => {
const height = element.clientHeight;
if (height > maxHeight) {
maxHeight = height;
}
});
elements.forEach(element => {
element.style.minHeight = maxHeight + 'px'
});
})
.catch(error => console.error('Error:', error))
.finally(() => loading = false);
})
" x-init="calculateProgressBarWidth(showingResultCount); this.urlParams = new URL(window.location.href)">