From 086d318c9c501b7248bbbfc31ecefff0bbff0b67 Mon Sep 17 00:00:00 2001 From: Nonimart Date: Tue, 24 Jun 2025 12:52:35 +0200 Subject: [PATCH] REFACTOR code to best handle index panel and different single. javascript features --- resources/js/singles/singles.ts | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/resources/js/singles/singles.ts b/resources/js/singles/singles.ts index a4402f1..729a286 100644 --- a/resources/js/singles/singles.ts +++ b/resources/js/singles/singles.ts @@ -1,4 +1,5 @@ -import handleIndexPanels from './index-panel'; +import handleIndexPanel from './index-panel'; +import handleFootnoteFormat from './footnote-format'; export default function singles(): void { const isSingleRevue: HTMLElement | null = document.querySelector('.page--single-revue'); @@ -7,9 +8,9 @@ export default function singles(): void { injectIdToNativeTitles(); - handleIndexPanels(); + handleIndexPanel(); + handleFootnoteFormat(); handleCiteButton(); - handleSmoothScrollToTitle(); } function handleCiteButton(): void { @@ -75,20 +76,3 @@ function injectIdToNativeTitles(): void { title.setAttribute('id', slug); }); } - -function handleSmoothScrollToTitle(): void { - const sommaireTitles: NodeListOf = document.querySelectorAll('.sommaire-index li a'); - for (const title of sommaireTitles) { - title.addEventListener('click', (e) => { - e.preventDefault(); - - const target = title.getAttribute('href'); - if (!target) return; - - const targetElement = document.querySelector(target); - if (!targetElement) return; - - targetElement.scrollIntoView({ behavior: 'smooth' }); - }); - } -}