« 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 :
/*( function () {
$( function () {
     'use strict';
     var panel = document.getElementById( 'mw-panel' );
    var content = document.getElementById( 'content' );
    if ( !panel || !content ) { return; }


    var THEMES = [ 'space', 'terminal' ];
     // Match the panel height to the content box
    var KEY = 'emush-theme';
     function sync() {
 
         panel.style.minHeight = content.offsetHeight + 'px';
     // Read the stored theme, falling back to the first one
     function current() {
         try {
            var s = localStorage.getItem( KEY );
            if ( s && THEMES.indexOf( s ) !== -1 ) { return s; }
        } catch ( e ) {}
        return THEMES[ 0 ];
     }
     }
    sync();


     // Swap the view-* class on <html> and persist the choice
     // Recompute when the content box changes size
     function apply( theme ) {
     if ( window.ResizeObserver ) {
         var root = document.documentElement;
         new ResizeObserver( sync ).observe( content );
        THEMES.forEach( function ( t ) { root.classList.remove( 'view-' + t ); } );
    } else {
         root.classList.add( 'view-' + theme );
         window.addEventListener( 'resize', sync );
        try { localStorage.setItem( KEY, theme ); } catch ( e ) {}
     }
     }
 
} );
    // The link already exists in the HTML — only bind the click
    $( function () {
        var li = document.getElementById( 'pt-themetoggle' );
        if ( !li ) { return; }
        li.addEventListener( 'click', function ( e ) {
            e.preventDefault();
            apply( current() === 'space' ? 'terminal' : 'space' );
        } );
    } );
}() );*/

Version du 30 juillet 2026 à 02:53

$( function () {
    var panel = document.getElementById( 'mw-panel' );
    var content = document.getElementById( 'content' );
    if ( !panel || !content ) { return; }

    // Match the panel height to the content box
    function sync() {
        panel.style.minHeight = content.offsetHeight + 'px';
    }
    sync();

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