S’ouvre dans un nouvel onglet
Au Bosquet
document.addEventListener('click', function(e) {
// Trouver le véritable lien, même si on clique sur son contenu
const link = e.target.closest('a[href]');
if (!link) return;
// Ignorer les actions particulières
if (
link.target === '_blank' ||
link.hasAttribute('download') ||
e.ctrlKey || e.metaKey ||
e.shiftKey || e.altKey ||
e.button !== 0
) return;
const href = link.getAttribute('href');
if (!href || href.startsWith('#') ||
href.startsWith('mailto:') ||
href.startsWith('tel:') ||
href.startsWith('javascript:')) return;
const url = new URL(href, location.href);
if (url.origin !== location.origin) return;
if (url.href === location.href) return;
// Éviter les doubles clics
if (link.dataset.arcLoading === '1') {
e.preventDefault();
return;
}
// Prendre en charge uniquement la navigation classique
e.preventDefault();
link.dataset.arcLoading = '1';
// Conserver les dimensions de l'élément
const width = link.offsetWidth;
const height = link.offsetHeight;
link.style.minWidth = width + 'px';
link.style.minHeight = height + 'px';
// Créer le message
const indicator = document.createElement('span');
indicator.className = 'arc-loading-indicator';
const spinner = document.createElement('span');
spinner.className = 'arc-loading-spinner';
const message = document.createElement('span');
message.textContent = 'Chargement en cours…';
indicator.append(spinner, message);
// Remplacer le contenu du lien
link.classList.add('arc-loading');
link.setAttribute('aria-busy', 'true');
link.replaceChildren(indicator);
// Laisser le navigateur afficher l'animation
setTimeout(function() {
window.location.assign(url.href);
}, 120);
}, true);