
His Fiancée Forced His Daughter to Call Her “Mom”—But the Mother She Tried to Kill Came Back from the Dead
Chapter 6: You Should Have Stayed Dead
`;
modal.addEventListener('click', (event) => {
if (event.target === modal || event.target.closest('.series-chapter-modal__close')) {
closeChapterModal();
}
});
document.body.appendChild(modal);
return modal;
};
const closeChapterModal = () => {
const modal = document.querySelector('.series-chapter-modal');
document.querySelectorAll('.series-nav__toc[aria-expanded="true"]').forEach((button) => {
button.setAttribute('aria-expanded', 'false');
});
document.querySelectorAll('.series-nav__toc-wrap.is-open').forEach((wrap) => {
wrap.classList.remove('is-open');
});
if (!modal) {
return;
}
modal.classList.remove('is-open');
modal.setAttribute('aria-hidden', 'true');
document.body.classList.remove('series-chapter-modal-open');
document.body.style.overflow = '';
};
const openChapterModal = (wrap, button) => {
const source = wrap?.querySelector('.series-nav__dropdown');
const list = source?.querySelector('.series-nav__dropdown-list');
if (!source || !list) {
return;
}
const modal = ensureChapterModal();
const title = source.querySelector('.series-nav__dropdown-title')?.textContent?.trim() || 'Chapter list';
modal.querySelector('.series-chapter-modal__title').textContent = title;
modal.querySelector('.series-chapter-modal__body').innerHTML = list.outerHTML;
modal.classList.add('is-open');
modal.setAttribute('aria-hidden', 'false');
button?.setAttribute('aria-expanded', 'true');
document.body.classList.add('series-chapter-modal-open');
document.body.style.overflow = 'hidden';
setTimeout(() => modal.querySelector('.series-chapter-modal__close')?.focus(), 0);
};
const toggleChapterModal = (event) => {
const button = event.target.closest('.series-nav__toc:not(.series-nav__toc--disabled)');
if (!button) {
return;
}
const wrap = button.closest('.series-nav__toc-wrap');
if (!wrap) {
return;
}
event.preventDefault();
event.stopPropagation();
event.stopImmediatePropagation();
const isOpening = !wrap.classList.contains('is-open');
closeChapterModal();
if (isOpening) {
wrap.classList.add('is-open');
openChapterModal(wrap, button);
}
};
document.addEventListener('click', toggleChapterModal, true);
document.addEventListener('keydown', (event) => {
if (event.key === 'Escape') {
closeChapterModal();
}
});
})();