Aller au contenu

« MediaWiki:Common.js » : différence entre les versions

De AECFC
Aucun résumé des modifications
Aucun résumé des modifications
 
(Une version intermédiaire par le même utilisateur non affichée)
Ligne 29 : Ligne 29 :
})();
})();


/*
* Déplacer « Voir l'historique » dans le menu Outils
*/
var historyTab = document.getElementById( 'ca-history' );
var historyLink = historyTab
    ? historyTab.querySelector( 'a' )
    : null;
if (
    historyLink &&
    !document.getElementById( 't-page-history' )
) {
    var toolsList = document.querySelector(
        '#p-tb .vector-menu-content-list'
    );
    var firstTool = toolsList
        ? toolsList.firstElementChild
        : null;
    var historyMenuItem = mw.util.addPortletLink(
        'p-tb',
        historyLink.href,
        historyLink.textContent.trim() || "Voir l'historique",
        't-page-history',
        "Voir l'historique de cette page",
        null,
        firstTool
    );
    /*
    * Supprimer l'onglet uniquement si son ajout
    * dans Outils a réussi
    */
    if ( historyMenuItem ) {
        historyTab.remove();
    }
}


$.when(
$.when(
Ligne 107 : Ligne 146 :
     mw.util.addPortletLink(
     mw.util.addPortletLink(
         'p-associated-pages',
         'p-associated-pages',
         mw.util.getUrl( 'Devoirs' ),
         mw.util.getUrl( 'Devoirs_2026-2027' ),
         'Devoirs',
         'Devoirs',
         'ca-aecfc-devoirs',
         'ca-aecfc-devoirs',
         'Aller à la page des devoirs'
         'Aller à la page des devoirs'
     );
     );
/*
* Déplacer « Voir l'historique » dans le menu Outils
*/
var historyTab = document.getElementById( 'ca-history' );
var historyLink = historyTab
    ? historyTab.querySelector( 'a' )
    : null;
if (
    historyLink &&
    !document.getElementById( 't-page-history' )
) {
    var toolsList = document.querySelector(
        '#p-tb .vector-menu-content-list'
    );
    var firstTool = toolsList
        ? toolsList.firstElementChild
        : null;
    var historyMenuItem = mw.util.addPortletLink(
        'p-tb',
        historyLink.href,
        historyLink.textContent.trim() || "Voir l'historique",
        't-page-history',
        "Voir l'historique de cette page",
        null,
        firstTool
    );
    if ( historyMenuItem ) {
        historyTab.remove();
    }
}
} );
} );

Dernière version du 3 juillet 2026 à 00:26

/* Tout JavaScript présent ici sera exécuté par tous les utilisateurs à chaque chargement de page.

$(function () {
    $('a.mw-wiki-logo, a.mw-logo')
        .attr('href', 'https://aecfc.org')
        .attr('title', 'Retour au site d'AECFC');
});
*/

(function () {
    'use strict';

    function restoreAecfcLink() {
        document.querySelectorAll('a.mw-logo').forEach(function (link) {
            link.href = 'https://aecfc.org/';
            link.title = 'Site de l’AECFC';
        });
    }

    if (document.readyState === 'loading') {
        document.addEventListener(
            'DOMContentLoaded',
            restoreAecfcLink,
            { once: true }
        );
    } else {
        restoreAecfcLink();
    }
})();


/*
 * Déplacer « Voir l'historique » dans le menu Outils
 */
var historyTab = document.getElementById( 'ca-history' );
var historyLink = historyTab
    ? historyTab.querySelector( 'a' )
    : null;

if (
    historyLink &&
    !document.getElementById( 't-page-history' )
) {
    var toolsList = document.querySelector(
        '#p-tb .vector-menu-content-list'
    );

    var firstTool = toolsList
        ? toolsList.firstElementChild
        : null;

    var historyMenuItem = mw.util.addPortletLink(
        'p-tb',
        historyLink.href,
        historyLink.textContent.trim() || "Voir l'historique",
        't-page-history',
        "Voir l'historique de cette page",
        null,
        firstTool
    );

    /*
     * Supprimer l'onglet uniquement si son ajout
     * dans Outils a réussi
     */
    if ( historyMenuItem ) {
        historyTab.remove();
    }
}

$.when(
    mw.loader.using( 'mediawiki.util' ),
    $.ready
).then( function () {

    // Ce code concerne l'habillage Vector 2022
    if ( mw.config.get( 'skin' ) !== 'vector-2022' ) {
        return;
    }

    var leftNavigation = document.getElementById( 'left-navigation' );
    var rightNavigation = document.getElementById( 'right-navigation' );

    var viewsPortlet = document.getElementById( 'p-views' );
    var associatedPagesPortlet = document.getElementById( 'p-associated-pages' );
    var toolsDropdown = document.getElementById(
        'vector-page-tools-dropdown'
    );

    if (
        !leftNavigation ||
        !rightNavigation ||
        !viewsPortlet ||
        !associatedPagesPortlet
    ) {
        return;
    }

    /*
     * 1. Déplacer Lire, Modifier, Historique, etc. à gauche
     */
    var viewsBlock = viewsPortlet.closest( 'nav' ) || viewsPortlet;
    leftNavigation.appendChild( viewsBlock );

    /*
     * 2. Déplacer également le menu Outils à gauche
     */
    if ( toolsDropdown ) {
        var toolsBlock = toolsDropdown.closest( 'nav' ) || toolsDropdown;
        leftNavigation.appendChild( toolsBlock );
    }

    /*
     * 3. Vider l'ancien bloc contenant "Page"
     */
    var associatedList = associatedPagesPortlet.querySelector(
        '.vector-menu-content-list'
    );

    if ( associatedList ) {
        while ( associatedList.firstChild ) {
            associatedList.removeChild( associatedList.firstChild );
        }
    }

    /*
     * 4. Déplacer ce bloc vide à droite
     */
    var associatedPagesBlock =
        associatedPagesPortlet.closest( 'nav' ) ||
        associatedPagesPortlet;

    rightNavigation.appendChild( associatedPagesBlock );

    /*
     * 5. Ajouter Accueil et Devoirs dans la partie droite
     */
    mw.util.addPortletLink(
        'p-associated-pages',
        mw.util.getUrl( 'Accueil' ),
        'Accueil',
        'ca-aecfc-accueil',
        "Aller à la page d'accueil"
    );

    mw.util.addPortletLink(
        'p-associated-pages',
        mw.util.getUrl( 'Devoirs_2026-2027' ),
        'Devoirs',
        'ca-aecfc-devoirs',
        'Aller à la page des devoirs'
    );

/*
 * Déplacer « Voir l'historique » dans le menu Outils
 */
var historyTab = document.getElementById( 'ca-history' );
var historyLink = historyTab
    ? historyTab.querySelector( 'a' )
    : null;

if (
    historyLink &&
    !document.getElementById( 't-page-history' )
) {
    var toolsList = document.querySelector(
        '#p-tb .vector-menu-content-list'
    );

    var firstTool = toolsList
        ? toolsList.firstElementChild
        : null;

    var historyMenuItem = mw.util.addPortletLink(
        'p-tb',
        historyLink.href,
        historyLink.textContent.trim() || "Voir l'historique",
        't-page-history',
        "Voir l'historique de cette page",
        null,
        firstTool
    );

    if ( historyMenuItem ) {
        historyTab.remove();
    }
}

} );