<script>
document.addEventListener("DOMContentLoaded", function(){
function createBoxes(){
if(document.querySelectorAll('.t-store__prod-popup__info .js-product-option').length){
$('.t-store__prod-popup__info .js-product-option').each(function(){
let elOption = $(this);
elOption.append('<div class="t-product__option-chbx-wrapper t-descr"></div>');
elOption.find('select option').each(function(){
let optionTxt = $(this).text();
elOption.find('.t-product__option-chbx-wrapper').append('<div class="t-product__option-chbx">'+optionTxt+'</div>');
});
elOption.find('select option').remove();
});
};
};
setTimeout(function () {
if(document.querySelectorAll('.t-store__product-snippet').length) createBoxes();
}, 1500);
$(document).on('click', '.t-product__option-chbx' , function(e){
let wrapElem = $(this).closest('.js-product-option');
$(this).toggleClass('active-chx-box');
let optionTxt = '';
let numChBox = 0;
wrapElem.find('.active-chx-box').each(function(){
optionTxt+= $(this).text()+'; ';
numChBox++;
});
wrapElem.find('.js-product-option-name').attr('data-option-checked', numChBox);
if(numChBox){
wrapElem.find('.js-product-option-name').addClass('show-num-box');
}else{
wrapElem.find('.js-product-option-name').removeClass('show-num-box');
};
wrapElem.find('select option').remove();
if(optionTxt!=''){
wrapElem.find('select').append('<option value="'+optionTxt+'" data-product-variant-price="">'+optionTxt+'</option>');
};
});
$(document).on('click', '.t-store__prod-popup__info .js-product-option-name' , function(e){
let wrapOpt = $(this).closest('.js-product-option');
if( !$(this).hasClass('active-opt-box') ) $('.js-product-option').removeClass('active-opt-box');
wrapOpt.toggleClass('active-opt-box');
});
document.addEventListener('click', function(e){
let prodElem = e.target.closest('a[href*="/tproduct/"]');
let optionMix = e.target.closest('.active-opt-box');
if (prodElem != null) {
setTimeout(function () { createBoxes() }, 1000);
};
if (optionMix == null) {
$('.js-product-option').removeClass('active-opt-box');
};
});
});
</script>
<style>
.t-product__option-chbx-wrapper {
width: max-content;
background-color: #f9f9f9;
border-radius: 5px;
padding: 5px 10px;
font-size: 14px;
display: none;
position: absolute;
z-index: 99;
margin-top: 5px;
box-shadow: 0 0 4px 0 #dddddd;
}
.t-product__option-chbx {
padding: 5px;
cursor: pointer;
position: relative;
padding-left: 25px;
}
.t-product__option-chbx:hover {
text-decoration: underline;
}
.t-product__option-chbx:before {
content: "";
width: 14px;
height: 14px;
position: absolute;
left: 0px;
border: 1px solid #7c7c7c;
}
.t-product__option-chbx.active-chx-box:after {
content: "";
background-image: url(https://static.tildacdn.com/tild6538-3266-4466-a233-626136623637/check_icon_135782.svg);
width: 15px;
height: 15px;
position: absolute;
background-size: contain;
background-repeat: no-repeat;
left: 0;
}
.t-product__option-chbx.active-chx-box {
text-decoration: underline;
}
#allrecords .js-product-option .t-product__option-variants {
display: none;
}
.js-product-option-name.t-product__option-title {
border: 1px solid #e2e2e2;
padding: 5px 6px;
border-radius: 5px;
width: max-content;
position: relative;
cursor: pointer;
}
.js-product-option-name.t-product__option-title:after {
content: "";
background-image: url(https://static.tildacdn.com/tild6563-3530-4235-a332-373739613866/down_icon-iconscom_6.svg);
display: inline-block;
width: 13px;
height: 13px;
background-size: contain;
background-repeat: no-repeat;
margin-left: 8px;
position: relative;
top: 2px;
}
.active-opt-box .t-product__option-chbx-wrapper {
display: block;
}
.active-opt-box .js-product-option-name.t-product__option-title {
background-color: #f9f9f9;
}
.active-opt-box .js-product-option-name.t-product__option-title:after {
transform: rotate(180deg);
}
.js-product-option-name.t-product__option-title.show-num-box:before {
content: "+"attr(data-option-checked);
margin-right: 7px;
color: #4CAF50;
}
.js-product-option.t-product__option {
width: min-content;
}
</style>