document.addEventListener('DOMContentLoaded',function(){console.log('DOM Loaded');var grid=document.querySelector('.gallery-grid');if(!grid){console.error('Gallery grid element not found.');return}
var iso=new Isotope(grid,{itemSelector:'.gallery-item',layoutMode:'fitRows'});function applyFilterFromFragment(){const hash=window.location.hash;if(hash){let filter=hash.substring(1);if(filter[0]=='_'){filter=filter.substring(1);window.location.hash=filter}
const filterValue='.'+filter;iso.arrange({filter:filterValue});document.querySelectorAll('.gallery-menu button').forEach(button=>{button.classList.remove('is-checked');if(button.getAttribute('data-filter')===filterValue){button.classList.add('is-checked')}})}else{filterValue='.all_bespoke'}}
applyFilterFromFragment();document.querySelectorAll('.take_slug').forEach(button=>{button.addEventListener('click',function(){const slug=this.getAttribute('data-filter').replace('.','');const newUrl=window.location.href.split('#')[0]+(slug?'#'+slug:'');window.location.href=newUrl})});var filtersElem=document.querySelector('.gallery-menu');if(filtersElem){filtersElem.addEventListener('click',function(event){if(event.target.tagName==='BUTTON'){console.log('Button clicked:',event.target.textContent);var filterValue=event.target.getAttribute('data-filter');console.log('Filter value:',filterValue);iso.arrange({filter:filterValue});const slug=filterValue.replace('.','');const newUrl=window.location.href.split('#')[0]+(slug?'#'+slug:'');window.history.pushState(null,null,newUrl)}})}else{console.error('Gallery menu element not found.')}
var buttonGroups=document.querySelectorAll('.gallery-menu button');buttonGroups.forEach(function(button){button.addEventListener('click',function(event){console.log('Button clicked (Change active class):',event.target.textContent);event.preventDefault();buttonGroups.forEach(function(btn){btn.classList.remove('is-checked')});button.classList.add('is-checked');var filterValue=button.getAttribute('data-filter');console.log('Filter value (Change active class):',filterValue);iso.arrange({filter:filterValue});const slug=filterValue.replace('.','');const newUrl=window.location.href.split('#')[0]+(slug?'#'+slug:'');window.history.pushState(null,null,newUrl)})});window.addEventListener('hashchange',applyFilterFromFragment)});jQuery(document).ready(function($){$(window).on('load',function(){let price_slider=$('.wpgb-facet-10');if(price_slider.length){console.log(price_slider);let slide_item=price_slider.find('.wpgb-range-facet');let min_val=slide_item.children('input:nth-child(1)').val();let max_val=slide_item.children('input:nth-child(2)').val();setTimeout(function(){price_slider.append(`<div class="price_inserter"><span id="dk_p_min">Min. price: ${min_val}</span><span id="dk_p_max">Max. price: ${max_val}</span></div>`);console.log(`<div class="price_inserter"><span id="dk_p_min">Min. price: ${min_val}</span><span id="dk_p_max">Max. price: ${max_val}</span></div>`)},2000);$(document).on('mousemove click change','.wpgb-range-thumbs .wpgb-range-thumb',function(){let slide_item=$('.wpgb-facet-10').find('.wpgb-range-thumbs');console.log(slide_item);let min_val=slide_item.children('.wpgb-range-thumb:nth-child(1)').attr('aria-valuenow');let max_val=slide_item.children('.wpgb-range-thumb:nth-child(2)').attr('aria-valuenow');$('#dk_p_min').html('Min. price: '+min_val);$('#dk_p_max').html('Max. price: '+max_val)});setInterval(function(){$(document).trigger('yith_wcwl_reload_fragments');let slide_item=$('.wpgb-facet-10').find('.wpgb-range-thumbs');let min_val=slide_item.children('.wpgb-range-thumb:nth-child(1)').attr('aria-valuenow');let max_val=slide_item.children('.wpgb-range-thumb:nth-child(2)').attr('aria-valuenow');$('#dk_p_min').html('Min. price: '+min_val);$('#dk_p_max').html('Max. price: '+max_val)},3000)}
if($('body').hasClass('woocommerce-checkout')){$('tr.cart_item.cart-item.wcpa_cart_has_fields').each(function(params){let add_on_price=parseInt($.trim($(this).find('.wcpa_price .price_value').text()));let p_currency=$(this).find('.cart-item__element.cart-item__price span.woocommerce-Price-currencySymbol');$(this).find('.cart-item__element.cart-item__price span.woocommerce-Price-currencySymbol').remove();let price_main=parseInt($.trim($(this).find('.cart-item__element.cart-item__price bdi').text()));let final_price=price_main-add_on_price;console.log(final_price,price_main,add_on_price);if(isNaN(final_price)){final_price=price_main}
$(this).find('.cart-item__element.cart-item__price bdi').html(p_currency);$(this).find('.cart-item__element.cart-item__price bdi').append(' '+final_price)});$('.fc-number-spin-button.fc-minus').attr('title','');$('.fc-number-spin-button.fc-plus').attr('title','');$(document).on('mouseenter','.fc-number-spin-button.fc-minus,.fc-number-spin-button.fc-plus',function(e){$(this).attr('title','')});$(document).on('select2:select','#billing_country',function(e){var country=$(this).val();console.log(country);if(country==='LB'){$('#billing_postcode_field').hide();$('#billing_postcode').val('1401')}else{$('#billing_postcode_field').show()}});setInterval(function(){var initialCountry=$('#billing_country').val();if(initialCountry==='LB'){$('#billing_postcode').val('1401');$('#billing_postcode_field').hide()}else{$('#billing_postcode_field').show()}},500)}})});jQuery(document).ready(function($){if($('body.page-id-626').length){let items=$('tbody.wishlist-items-wrapper tr');items.each(function(params){let thisitem=$(this).find('a.button');if(thisitem.length){let href=thisitem.attr('href');if(href&&href.indexOf('add-to-cart=')!==-1){thisitem.text('Add to Cart')}else{thisitem.text('Customize')}
console.log('Item Found: ',thisitem)}else{console.log('Item not Found: ',thisitem)}});let items2=$('.wishlist_table.mobile li');items2.each(function(params){let thisitem=$(this).find('a.button');if(thisitem.length){let href=thisitem.attr('href');if(href&&href.indexOf('add-to-cart=')!==-1){thisitem.text('Add to Cart')}else{thisitem.text('Customize')}
console.log('Item Found: ',thisitem)}else{console.log('Item not Found: ',thisitem)}})}})