Aller au contenu

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

De AECFC
Aucun résumé des modifications
Balise : Révoqué
Aucun résumé des modifications
 
(13 versions intermédiaires par le même utilisateur non affichées)
Ligne 3 : Ligne 3 :
$(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');
});
});
*/
*/


/* Ensemble : logo + liens Accueil et Devoirs */
(function () {
.aecfc-brand {
    'use strict';
     display: flex;
 
     align-items: center;
    function restoreAecfcLink() {
     flex: 0 0 auto;
        document.querySelectorAll('a.mw-logo').forEach(function (link) {
     min-width: max-content;
            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();
    }
}
}


/* Logo graphique uniquement */
$.when(
.aecfc-brand .aecfc-logo-link {
    mw.loader.using( 'mediawiki.util' ),
     display: flex !important;
     $.ready
    align-items: center;
).then( function () {
    flex: 0 0 auto !important;


     width: auto !important;
     // Ce code concerne l'habillage Vector 2022
     height: auto !important;
     if ( mw.config.get( 'skin' ) !== 'vector-2022' ) {
     margin: 0 !important;
        return;
     }


     position: static !important;
     var leftNavigation = document.getElementById( 'left-navigation' );
    inset: auto !important;
     var rightNavigation = document.getElementById( 'right-navigation' );
     z-index: auto !important;


     pointer-events: auto !important;
     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'
    );


/* Les deux liens à droite du logo */
/*
.aecfc-text-links {
* Déplacer « Voir l'historique » dans le menu Outils
    display: flex;
*/
    flex-direction: column;
var historyTab = document.getElementById( 'ca-history' );
     align-items: flex-start;
var historyLink = historyTab
     justify-content: center;
     ? historyTab.querySelector( 'a' )
     : null;


     margin-left: 14px;
if (
     white-space: nowrap;
    historyLink &&
     !document.getElementById( 't-page-history' )
) {
     var toolsList = document.querySelector(
        '#p-tb .vector-menu-content-list'
    );


     position: relative;
     var firstTool = toolsList
    z-index: 10;
        ? toolsList.firstElementChild
}
        : null;


/* Accueil : texte principal */
    var historyMenuItem = mw.util.addPortletLink(
.aecfc-accueil-link,
        'p-tb',
.aecfc-accueil-link:visited {
        historyLink.href,
    color: #287676;
        historyLink.textContent.trim() || "Voir l'historique",
    font-size: 25px;
        't-page-history',
    font-weight: 700;
        "Voir l'historique de cette page",
    line-height: 1.15;
        null,
    text-decoration: none;
        firstTool
     pointer-events: auto;
     );
}


/* Devoirs : texte secondaire */
    if ( historyMenuItem ) {
.aecfc-devoirs-link,
        historyTab.remove();
.aecfc-devoirs-link:visited {
     }
    color: #3366cc;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.25;
     text-decoration: none;
    margin-top: 3px;
    pointer-events: auto;
}
}


.aecfc-accueil-link:hover,
} );
.aecfc-devoirs-link:hover {
    text-decoration: underline;
}

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();
    }
}

} );