|
|
| Ligne 1 : |
Ligne 1 : |
| /* Tout JavaScript présent ici sera exécuté par tous les utilisateurs à chaque chargement de page. | | /* Tout JavaScript présent ici sera exécuté par tous les utilisateurs à chaque chargement de page. */ |
|
| |
|
| $(function () { | | $(function () { |
| $('a.mw-wiki-logo, a.mw-logo') | | $('a.mw-wiki-logo, a.mw-logo') |
| .attr('href', 'Accueil') | | .attr('href', 'https://aecfc.org') |
| .attr('title', 'Retour a l'accueil'); | | .attr('title', 'Retour au site d'AECFC'); |
| }); | | }); |
| */
| |
|
| |
| (function () {
| |
| 'use strict';
| |
|
| |
| function configureAecfcLogo() {
| |
| const mainLink = document.querySelector('a.mw-logo');
| |
|
| |
| if (!mainLink) {
| |
| return;
| |
| }
| |
|
| |
| // Évite une seconde initialisation.
| |
| if (mainLink.dataset.aecfcRouting === '1') {
| |
| return;
| |
| }
| |
|
| |
| mainLink.dataset.aecfcRouting = '1';
| |
|
| |
| /*
| |
| * Supprime le titre et le sous-titre natifs,
| |
| * mais conserve l'image du logo.
| |
| */
| |
| const nativeText = mainLink.querySelector('.mw-logo-container');
| |
|
| |
| if (nativeText) {
| |
| nativeText.remove();
| |
| }
| |
|
| |
| /*
| |
| * Création des deux textes affichés à droite du logo.
| |
| * Ce sont volontairement des <span>, pas des liens imbriqués.
| |
| */
| |
| const textBlock = document.createElement('span');
| |
| textBlock.className = 'aecfc-logo-texts';
| |
|
| |
| const accueilText = document.createElement('span');
| |
| accueilText.className = 'aecfc-accueil-text';
| |
| accueilText.textContent = 'Accueil';
| |
| accueilText.title = 'Accueil du wiki';
| |
|
| |
| const devoirsText = document.createElement('span');
| |
| devoirsText.className = 'aecfc-devoirs-text';
| |
| devoirsText.textContent = 'Devoirs';
| |
| devoirsText.title = 'Consulter les devoirs';
| |
|
| |
| textBlock.appendChild(accueilText);
| |
| textBlock.appendChild(devoirsText);
| |
| mainLink.appendChild(textBlock);
| |
|
| |
| /*
| |
| * Le lien par défaut du bloc reste l'accueil du wiki.
| |
| */
| |
| mainLink.href = 'https://wiki.aecfc.org/wiki/Accueil';
| |
| mainLink.title = '';
| |
|
| |
| const logoIcon = mainLink.querySelector('.mw-logo-icon');
| |
|
| |
| if (logoIcon) {
| |
| logoIcon.title = 'Site officiel de l’AECFC';
| |
| }
| |
|
| |
| /*
| |
| * Comme Vector utilise un seul lien parent,
| |
| * on choisit la destination selon la zone cliquée.
| |
| */
| |
| mainLink.addEventListener(
| |
| 'click',
| |
| function (event) {
| |
| const target =
| |
| event.target instanceof Element
| |
| ? event.target
| |
| : event.target.parentElement;
| |
|
| |
| if (!target) {
| |
| return;
| |
| }
| |
|
| |
| // Clic sur le logo graphique → site aecfc.org
| |
| if (target.closest('.mw-logo-icon')) {
| |
| event.preventDefault();
| |
| event.stopImmediatePropagation();
| |
| window.location.assign('https://aecfc.org/');
| |
| return;
| |
| }
| |
|
| |
| // Clic sur Devoirs → page Devoirs
| |
| if (target.closest('.aecfc-devoirs-text')) {
| |
| event.preventDefault();
| |
| event.stopImmediatePropagation();
| |
| window.location.assign(
| |
| 'https://wiki.aecfc.org/wiki/Devoirs_2026-2027'
| |
| );
| |
| return;
| |
| }
| |
|
| |
| /*
| |
| * Clic sur Accueil, ou sur le reste du bloc :
| |
| * le comportement normal du lien parent est conservé.
| |
| */
| |
| },
| |
| true
| |
| );
| |
| }
| |
|
| |
| if (document.readyState === 'loading') {
| |
| document.addEventListener(
| |
| 'DOMContentLoaded',
| |
| configureAecfcLogo,
| |
| { once: true }
| |
| );
| |
| } else {
| |
| configureAecfcLogo();
| |
| }
| |
| })();
| |