';
$(this).next().append(loader);
let length_fabrics = parseInt($('.custom_filter_results_' + product_option_filter_id).length) + parseInt($('.fabric_filtered_results_' + product_option_filter_id + ' .base_filters').length);
$('.option.fabric_filtered_results_' + product_option_filter_id + ' .base_filters').each(function (i, v) {
selectedFilterValues.push($(this).attr("id"));
optionID = $(this).find('input').attr("3d-option-id");
});
let option_filter_id = optionID;
//document.getElementsByClassName('filter_option_sidebar')[0].getAttribute('data-filter-product-option-id');
let product_id = $('input[name="product_id"]').val();
let add_price = document.getElementsByClassName('filter_option_sidebar')[0].getAttribute('data-add-price');
let currency = document.getElementById("currecny_symbol").value;
let data = {'fabrics_ids': selectedFilterValues, "optionId" : option_filter_id,"product_id" : product_id,"length": length_fabrics,"product_option_id" : product_option_filter_id };
var domain = window.location.host;
var protocol = window.location.protocol;
var baseURL = protocol + '//' + domain + '/image/cache/';
if (isRequestPending) {
// If a request is already pending, don't make another request
return;
}
//////////////////// first request for fabric////////////////////////
isRequestPending = true;
fetch("index.php?route=product/design/paginate_fabrics", {
method: "POST", // or 'PUT',
headers: {
'Accept': 'application/json',
'Content-type': 'application/json'
},
body: JSON.stringify(data)
}).then(response => response.json()) // Convert response to JSON
.then(data => {
let string = ''
let modal = '';
let d_fabric_price = '(' + currency + ' ' + parseInt(document.querySelector('span.price-old').innerText.replace(/[^0-9]/gi, '')) + ')';
// $('.c_price').text(currency + ' ' +document.querySelector('span.text-price').innerText.replace(/[^0-9]/gi, ''));
if (data.data.length > 0) {
data.data.forEach((element) => {
string += '
';
string += '
';
});
$('.fabric_filtered_results_' + product_option_filter_id).append(string);
$("#input-option"+product_option_filter_id).find('.selected-option').click();
}
else {
if (loaded_product_options.includes(product_option_filter_id) == false) {
loaded_product_options.push(product_option_filter_id)
}
}
})
.catch(error => {
// handle the error
console.log(error)
}).finally(() => {
isRequestPending = false;
})
setTimeout(function () {
$(".loader_" + product_option_filter_id).remove();
}, 500)
}
});
function removeHtmlTagsAndDecode(encodedText) {
// Create a DOMParser to parse the encoded HTML
const parser = new DOMParser();
const decodedHtml = parser.parseFromString(encodedText, 'text/html');
// Get the text content
return decodedHtml.body.textContent;
}
$('.menu-flex-container').on('click', function () {
$('.filter_option_sidebar .checkbox input').prop('checked', false);
// let p_o_id = $('.filter_option_sidebar').attr('data-filter-product-option-id');
// $('.fabric_filtered_results_' + p_o_id + ' .base_filters').show();
// $('.custom_filter_results_' + p_o_id).remove();
// $('.input-option'+p_o_id+'-option').find('label:first').click();
$('.filter_close_button').click();
});
$(document).on('click','.filter_removal', function () {
let filter_id = $(this).parent().attr('data-filter-id');
let optionId = $(this).parent().attr('data-option-id');
$('.filter_option_sidebar input[name="filter['+optionId+'][]"][value="'+filter_id+'"]').prop("checked", false)
$('.filter_'+optionId+'_'+filter_id).each(function () {
if($(this).find('label').hasClass('selected-option') == false)
{
$(this).remove();
}
});
// let element = document.getElementsByClassName("filter_option_sidebar")[0];
// let event = new Event('change');
// element.dispatchEvent(event);
setTimeout(function () {
//remove filtered fabrics if all filters removed
let $length = $('#input-option'+optionId+' .filter_removal').length;
console.log($length)
if($length == 0)
{
// $('.custom_filter_results_' + optionId).remove();
$('.custom_filter_results_' + optionId).each(function () {
if($(this).find('label').hasClass('selected-option') == false)
{
$(this).remove();
}
else{
$(this).show();
}
});
$('#input-option'+optionId+' .selected-filter-values').remove();
$('.fabric_filtered_results_' + optionId + ' .base_filters').show();
setTimeout(function () {
console.log('executed',loaded_product_options)
// $('#input-option'+optionId).find('.selected-option').click();
const index = loaded_product_options.indexOf(optionId);
if (index > -1) { // only splice array when item is found
loaded_product_options.splice(index, 1); // 2nd parameter means remove one item only
}
console.log('after clear',loaded_product_options)
$('#input-option'+optionId).prev().click();// this we need 2 times as code is been done this way so that 1 it will close and other it will open the div. this will close
$('#input-option'+optionId).prev().click();// this will
}, 300)
}
}, 300)
$(this).parent().remove();
});
-->
$(function($) {$("img.lazy").Lazy();});-->
DISCLAIMER: All style photos are copyrighted by the publisher or photographer. We makes no copyright claim to these photos.
We use cookies to offer you the best experience on our site. By continuing to browse the site, You are agree to use cookies. For obtain more informations please Click here