Furniture is currently available for white glove delivery service in South Florida and Greater Chicago areas. Planning an event outside those areas? Please contact us to explore your long-distance delivery needs.

Loading...
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).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); }); }); }); --> `; }).join(''); /* productHtml += $.map(product.product_media, function(image, i) { return '
Product Image ' + (i + 1) + '
'; }).join(''); productHtml += `
`; */ productHtml += ` `; productHtml += `
`; productHtml += ` `; // product_variants_box productHtml += `
`; productHtml += `
`; // set the product details as the first variation by default // productHtml += ``; productHtml += ``; // add additional variations const total_variants = product.product_variants.length; //product.product_variants_count if (total_variants > 0) { // productHtml += 'hello' + total_variants; }; var variant_link = `${app_settings.root_url}/product/`; if (app_settings.use_handle === '0') { var variant_link = `${app_settings.root_url}/product.cfm?h=`; } if (total_variants > 0) { const show_variants_qty = Math.min(total_variants, 2); for (let i = 0; i < show_variants_qty; i++) { const variant = product.product_variants[i]; // Check if product_variant_media exists and has at least one element const mediaSrc = (variant.product_variant_media && variant.product_variant_media.length > 0) ? `${variant.product_variant_media[0]}` : 'https://placehold.co/50/4f46e4/FFFFFF?text=nuage'; /* const mediaSrc = variant.product_variant_media[0] ? `${variant.product_variant_media[0]}` : 'https://placehold.co/50/4f46e4/FFFFFF?text=nuage'; const mediaSrc = 'https://placehold.co/50/4f46e4/FFFFFF?text=nuage'; const mediaSrc = variant.product_variant_media[0] ? `${app_settings.products_media_url}/${variant.product_variant_media[0]}?width=50&aspect_ratio=100:101` : 'https://placehold.co/50/4f46e4/FFFFFF?text=nuage'; */ productHtml += ` ${variant.product_variant_name} `; } if (product.product_variants_count > 3) { productHtml += `+${product.product_variants_count - show_variants_qty - 1}`; // productHtml += `+${product.product_variants_count - show_variants_qty - 1}/${product.product_variants_count + 0}`; } } else { productHtml += `
0
`; } productHtml += `
`; if ($.isNumeric(product.product_swatch_id)) { var product_swatch_link = `${app_settings.root_url}/cart?add_to_cart&pid=${product.product_swatch_id}`; if (app_settings.use_handle === '0') { var product_swatch_link = `${app_settings.root_url}/cart.cfm?add_to_cart&pid=${product.product_swatch_id}`; } productHtml += `
Order Swatch
`; } // productHtml += `
order swatch
`; productHtml += `
`; // end product_variants_box productHtml += `
${product.product_name}
`; // productHtml += 'hello'; /* // Loop through all product media $.map(product.product_media, function(image, i) { return 'Product Image ' + (i + 1) + ''; }).join('') + '' + product.product_name + '' + '
'; // Loop through all product variants $.each(product.product_variants, function(vIndex, variant) { productHtml += '
' + // Loop through all variant media $.map(variant.product_variant_media, function(image, i) { return 'Variant Image ' + (i + 1) + ''; }).join('') + '' + variant.product_variant_name + '' + '
'; }); */ productHtml += `
`; productHtml += ' '; productsHtml += productHtml; }); if (resetContent) { $('#drum-products').empty(); // Clear existing content hasNextPage = true; // Start with the assumption that there are more pages $('#load-more').show(); // show the load-more button } // $('.products').html(productsHtml); // $('#drum-products').html(productsHtml); $('#drum-products').append(productsHtml); // Populate attributes /* var attributesHtml = ''; $.each(data.attributes, function(aIndex, attributeGroup) { var attributeGroupHtml = '
' + '
'; $.each(attributeGroup.attributes, function(attrIndex, attribute) { attributeGroupHtml += '' + attribute.attribute_name + ' (' + attribute.attribute_count + ')'; }); attributeGroupHtml += '
'; attributesHtml += attributeGroupHtml; }); $('.attributes').html(attributesHtml); */ function update_filter_values() { // create a map for easy lookup of totals const totalMap = {}; attributes.forEach(attr => { totalMap[attr.id] = attr.total; }); // loop through each option in the selectpicker $('.selectpicker option').each(function() { const id = $(this).val(); // get the id of the option const total = totalMap[id] !== undefined ? totalMap[id] : 0; // default to 0 if not found // Update the option text $(this).text(`${$(this).data('option-name')} (${total})`); }); // refresh the selectpicker to show the updated options $('.selectpicker').selectpicker('refresh'); } update_filter_values(); // select, add checkmark and update count // get the ids based on a condition /* const selectedIds = attributes .filter(attribute => attribute.status === 1) // adjust the condition as needed .map(attribute => String(attribute.id)); // map and convert ids to strings */ const selectedIds = data.attr_id.split(','); $('.selectpicker').selectpicker('deselectAll'); // Clear all selections // Use the dynamic selection to set the values $('.selectpicker').selectpicker('val', selectedIds); // this only works once! because overwrite // $('.selectpicker').selectpicker('val', ['2', '3', '5', '29']); // example for selecting multiple values // $('.selectpicker').selectpicker('val', ['blue', 'red', 'fabric1']); // example for selecting multiple values $('.selectpicker').each(function() { $(this).trigger('change'); }); // Update the selected attributes list const $selectedAttributesList = $('.selected_attributes_list'); $selectedAttributesList.empty(); // Clear existing buttons // Create buttons for each selected option selectedIds.forEach(id => { const $option = $('.selectpicker option[value="' + id + '"]'); const optionName = $option.data('option-name'); if (optionName) { const $button = $(``); // Add click handler to remove the selection when the button is clicked $button.on('click', function() { const valueToRemove = $(this).data('option-id'); // $('.selectpicker option[value="1"]').prop('selected', false); $(`.selectpicker option[value="${valueToRemove}"]`).prop('selected', false); // $('.selectpicker').selectpicker('refresh'); // no needed here, because I am calling the api to update results $('.selectpicker').each(function() { $(this).trigger('change'); }); $(this).remove(); // Remove the button fetch_api_data(true); /* $('.selectpicker').selectpicker('val', function(currentValues) { return currentValues.filter(value => value !== valueToRemove); }); */ // Update the selected attributes list again // updateSelectedAttributesList(); }); $selectedAttributesList.append($button); } if ($.trim($selectedAttributesList.html()) !== '') { $selectedAttributesList.addClass('pb-3'); } else { $selectedAttributesList.removeClass('pb-3'); } }); // Add a "Clear All" button if more than one option is selected if (selectedIds.length > 1) { const $clearAllButton = $(''); $clearAllButton.on('click', function() { // Clear all selections $('.selectpicker').selectpicker('deselectAll'); fetch_api_data(true); // $selectedAttributesList.empty(); // Clear the button list }); $selectedAttributesList.append($clearAllButton); } // Function to update the selected attributes list function updateSelectedAttributesList() { const currentSelectedIds = $('.selectpicker').val(); $selectedAttributesList.empty(); // Clear existing buttons currentSelectedIds.forEach(id => { const $option = $('.selectpicker option[value="' + id + '"]'); const optionName = $option.data('option-name'); if (optionName) { const $button = $(``); // Add click handler to remove the selection $button.on('click', function() { const valueToRemove = $(this).data('option-id'); // Deselect the option $('.selectpicker').selectpicker('val', function(currentValues) { return currentValues.filter(value => value !== valueToRemove); }); // Update the selected attributes list again $(this).remove(); // Remove the button updateSelectedAttributesList(); }); $selectedAttributesList.append($button); } }); // Add "Clear All" button if more than one option is selected if (currentSelectedIds.length > 1) { const $clearAllButton = $(''); $clearAllButton.on('click', function() { $('.selectpicker').selectpicker('deselectAll'); $selectedAttributesList.empty(); // Clear the button list }); $selectedAttributesList.append($clearAllButton); } } // Check if data.page_next exists and is not blank or null console.log('page_next:' + response.page_next); // if (typeof response.page_next === 'number') { if (response.page_next) { page = response.page_next; // Set the next page from the response } else { hasNextPage = false; // No more pages, stop further requests $('#load-more').hide(); // Optionally hide the load-more button (if using button trigger) } loading = false; // Reset loading state $('#product-loader').hide(); dmkt_app.product_swipper_refresh(); }, // success error: function(xhr, status, error) { console.error('AJAX request failed: ', status, error); $('.totals').text('Failed to load data.'); $('.products').text('Failed to load products.'); $('.attributes').text('Failed to load attributes.'); $('#product-loader').hide(); loading = false; } // error }); // ajax } // fetch_api_data $(document).ready(function() { function isInViewport(elem) { const rect = elem.getBoundingClientRect(); const offset = 500; // Set the offset to 300px return ( rect.bottom >= 0 - offset && // Bottom is at least '300px' above the top of the viewport rect.top <= (window.innerHeight || document.documentElement.clientHeight) + offset && // Top is at most 300px below the bottom of the viewport rect.left >= 0 && // Left side is within the viewport rect.right <= (window.innerWidth || document.documentElement.clientWidth) // Right side is within the viewport ); } function loadMoreIfVisible() { const loadMoreButton = $('#load-more')[0]; // Get the DOM element if (loadMoreButton && isInViewport(loadMoreButton)) { if (hasNextPage) { // console.log('loop1...'); fetch_api_data(); // the next line is causing swiper goes crazy, probably to many interactions // requestAnimationFrame(loadMoreIfVisible); // Continue checking } // console.log('loop2...'); } } loadMoreIfVisible(); // Initial call to start the loop // Trigger loading when scrolling near the bottom of the page $(window).scroll(function() { if (hasNextPage) { loadMoreIfVisible(); } /* if ($(window).scrollTop() + $(window).height() >= $(document).height() - 200) { if (hasNextPage) { fetch_api_data(); } } */ }); }); // Trigger loading more products on button click $('#load-more').click(function() { fetch_api_data(); }); // Trigger loading more products on button click $('#update-products').click(function() { fetch_api_data(); }); }); // document-ready -->