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

De eMushpedia
Aller à la navigation Aller à la recherche
Aucun résumé des modifications
Aucun résumé des modifications
Ligne 1 : Ligne 1 :
/* Ensure the left panel is always the same height as #content */
$( function () {
$( function () {
     var panel = document.getElementById( 'mw-panel' );
     var panel = document.getElementById( 'mw-panel' );
Ligne 20 : Ligne 21 :
         window.addEventListener( 'resize', sync );
         window.addEventListener( 'resize', sync );
     }
     }
} );
/* Make the logo at the top center redirect to the home page */
$( function () {
    var sidebarLink = document.querySelector( '#p-logo a' );
    if ( !sidebarLink || document.getElementById( 'emush-logo-hotspot' ) ) { return; }
    var hotspot = document.createElement( 'a' );
    hotspot.id = 'emush-logo-hotspot';
    hotspot.href = sidebarLink.getAttribute( 'href' );
    hotspot.title = sidebarLink.getAttribute( 'title' ) || '';
    hotspot.setAttribute( 'aria-label', 'Accueil' );
    document.body.appendChild( hotspot );
} );
} );

Version du 30 juillet 2026 à 03:37

/* Ensure the left panel is always the same height as #content */
$( function () {
    var panel = document.getElementById( 'mw-panel' );
    var content = document.getElementById( 'content' );
    if ( !panel || !content ) { return; }

    // Set an exact height; min-height would only act as a floor
    function sync() {
        panel.style.minHeight = '0';

        // Convert 1em to pixels using the panel's own font size
        var em = parseFloat( getComputedStyle( panel ).fontSize );
        panel.style.height = ( content.getBoundingClientRect().height - em ) + 'px';
    }
    sync();

    // Recompute when the content box changes size
    if ( window.ResizeObserver ) {
        new ResizeObserver( sync ).observe( content );
    } else {
        window.addEventListener( 'resize', sync );
    }
} );


/* Make the logo at the top center redirect to the home page */
$( function () {
    var sidebarLink = document.querySelector( '#p-logo a' );
    if ( !sidebarLink || document.getElementById( 'emush-logo-hotspot' ) ) { return; }

    var hotspot = document.createElement( 'a' );
    hotspot.id = 'emush-logo-hotspot';
    hotspot.href = sidebarLink.getAttribute( 'href' );
    hotspot.title = sidebarLink.getAttribute( 'title' ) || '';
    hotspot.setAttribute( 'aria-label', 'Accueil' );
    document.body.appendChild( hotspot );
} );