Loading...

Loading...

End of content

No more content to load

SHOW RESULTS'); typeDropdownMenu.append(typeSearchNowButton); $(".bs-deselect-all").text("Clear All"); function changeSelectedItemsCount(selectElement) { var selectedCount = $(selectElement).val().length; var selectName = $(selectElement).data('select-name'); var displayText = selectedCount > 0 ? selectName + ' ' + '' + selectedCount + '' : selectName; $(selectElement).parent().find('.filter-option-inner-inner').html(displayText); } // set up event listeners for all select elements with class .selectpicker $('.selectpicker').on('changed.bs.select', function () { changeSelectedItemsCount(this); }); // initialize the display text for each select element - the dropdown title: color, fabric, pattern... $('.selectpicker').each(function() { var selectName = $(this).data('select-name'); $(this).parent().find('.filter-option-inner-inner').text(selectName); }); $('.selectpicker').change(function() { var selectedValue = $(this).val(); // console.log('last selected group value:', selectedValue); // create an array to hold selected values var selectedValues = []; // loop through all selects with the name "filter-by" $('select[name="filter-by"]').each(function() { var values = $(this).val(); // this will be an array for multiple selects if (Array.isArray(values)) { // filter out empty values and concatenate selectedValues.push(...values.filter(value => value.trim() !== '')); } }); // concatenate the values into a string var concatenatedValues = selectedValues.join(','); console.log('all selected values:', concatenatedValues); g_attributes_selected = concatenatedValues }); }); // document.ready $(document).ready(function() { initializeInfiniteScroll(); // dmkt_app.product_swipper_refresh(); $(document).on('click', '.show-results-btn', function() { console.log('execute ajax update'); // fetch_api_data(); // var g_reset_content = true; $(window).scrollTop(0); // fetch_api_data(true); initializeInfiniteScroll(); }); }); /* destroy swipper // Create an Intersection Observer to detect when the product swiper goes out of view const observer = new IntersectionObserver(function(entries) { entries.forEach(function(entry) { const productSwipper = entry.target; // Check if the swiper is going out of view (isIntersecting === false) if (entry.isIntersecting === false) { console.log('IntersectionObserver triggered for: ', productSwipper); // Check if the swiper instance exists before trying to destroy it if (productSwipper.swiper) { console.log('Destroying swiper for: ', productSwipper); productSwipper.swiper.destroy(); productSwipper.swiper = null; // Optional: Clear the reference console.log('Swiper destroyed for: ', productSwipper); } } else { console.log('Swiper is still in view: ', productSwipper); } }); }, { threshold: 0.5 }); // Trigger when 50% of the element is out of view // Observe each product swiper document.querySelectorAll('.product_swipper').forEach(function(productSwipper) { observer.observe(productSwipper); }); // Fallback manual scroll event listener (in case IntersectionObserver isn't triggering as expected) window.addEventListener('scroll', function() { document.querySelectorAll('.product_swipper').forEach(function(productSwipper) { // Check if the product swiper is in the viewport manually const rect = productSwipper.getBoundingClientRect(); const isInViewport = rect.top >= 0 && rect.bottom <= window.innerHeight; // If swiper is out of view and it has an initialized swiper instance, destroy it if (!isInViewport && productSwipper.swiper) { console.log('Scroll event triggered for: ', productSwipper); console.log('Destroying swiper for: ', productSwipper); productSwipper.swiper.destroy(); productSwipper.swiper = null; // Optional: Clear the reference console.log('Swiper destroyed via scroll for: ', productSwipper); } }); }); */ // Event listener to detect when the user changes the color /* document.getElementById('colorSelect').addEventListener('change', function() { console.log('color changed'); selectedColor = this.value; // Update the selected color initializeInfiniteScroll(); // Reinitialize InfiniteScroll with the new color }); */ // load initial page // $infScroll.infiniteScroll('loadNextPage'); -->