document.addEventListener('click', function (e){
const toggle=e.target.closest('.wp-block-navigation-submenu__toggle');
if(!toggle) return;
if(window.innerWidth >=1090) return;
if(!document.querySelector('.is-menu-open')) return;
e.stopImmediatePropagation();
e.preventDefault();
const parentLi=toggle.closest('.wp-block-navigation-item.has-child');
const ul=parentLi.querySelector(':scope > .wp-block-navigation__submenu-container');
if(!ul) return;
const isOpening = !ul.classList.contains('photom-open');
const parentUl=parentLi.parentElement;
parentUl.querySelectorAll(':scope > .wp-block-navigation-item.has-child').forEach(function (sibling){
if(sibling===parentLi) return;
const sibUl=sibling.querySelector(':scope > .wp-block-navigation__submenu-container');
const sibBtn=sibling.querySelector(':scope > .wp-block-navigation-submenu__toggle');
if(sibUl) sibUl.classList.remove('photom-open');
if(sibBtn) sibBtn.setAttribute('aria-expanded', 'false');
});
ul.classList.toggle('photom-open', isOpening);
toggle.setAttribute('aria-expanded', isOpening ? 'true':'false');
}, true);
document.addEventListener("DOMContentLoaded", function (){
if(document.querySelector('.glightbox')){
const lightbox=GLightbox({
selector: '.glightbox'
});
}
if(typeof jQuery!=="undefined"){
jQuery(function ($){
$(document).on('click', '.gotop', function (e){
e.preventDefault();
$('html, body').animate({
scrollTop: 0
}, 1000);
return false;
});
});
}});
jQuery(document).ready(function ($){
$('.wp-block-post-excerpt__more-link').each(function (){
const link=$(this);
const href=link.attr('href');
const text=link.text();
const newHTML=`
<button class="custom-btn btn-5">
<a href="${href}">
<span>${text}</span>
</a>
</button>
`;
link.replaceWith(newHTML);
});
});
document.addEventListener("DOMContentLoaded", function (){
const tocTarget=document.querySelector('.post-sidebar-left .sidebar-toc-target') ||
document.querySelector('.post-sidebar-left .toc-card') ||
document.querySelector('.post-sidebar-left .sidebar-left-box') ||
document.querySelector('.post-sidebar-left');
const toc=document.querySelector('.post-card .wp-block-rank-math-toc-block');
if(tocTarget&&toc){
tocTarget.appendChild(toc);
}});
document.addEventListener("DOMContentLoaded", function (){
const tocLinks=document.querySelectorAll('.post-sidebar-left .wp-block-rank-math-toc-block nav a'
);
if(!tocLinks.length) return;
const headings=Array.from(tocLinks).map(link=> {
const id=decodeURIComponent(link.getAttribute('href')).replace('#', '');
return document.getElementById(id);
}).filter(Boolean);
function onScroll(){
let current=null;
headings.forEach(heading=> {
if(heading.getBoundingClientRect().top <=140){
current=heading;
}});
tocLinks.forEach(link=> {
link.parentElement.classList.remove('toc-active');
});
if(current){
const activeLink=document.querySelector(`.post-sidebar-left .wp-block-rank-math-toc-block nav a[href="#${current.id}"]`
);
if(activeLink) activeLink.parentElement.classList.add('toc-active');
}}
window.addEventListener('scroll', onScroll, {
passive: true
});
onScroll();
});