MediaWiki:Gadget-FontSwitcher.js: различия между версиями

Нет описания правки
Метка: отменено
Нет описания правки
Метка: отменено
Строка 114: Строка 114:
      
      
     // 4. Фикс «Свежих правок»: дата и время не раздуваются
     // 4. Фикс «Свежих правок»: дата и время не раздуваются
    if ( body.classList.contains( 'font-large' ) ) {
function shrinkDates( root ) {
        var dates = document.querySelectorAll( '.mw-changeslist-date, .mw-changeslist-time' );
    var dates = ( root || document ).querySelectorAll(
        dates.forEach( function ( el ) {
        '.mw-changeslist-date, .mw-changeslist-time'
            el.style.setProperty( 'font-size', '0.8em', 'important' );
    );
            el.style.setProperty( 'white-space', 'nowrap', 'important' );
    dates.forEach( function ( el ) {
            el.style.setProperty( 'display', 'inline-block', 'important' );
        el.style.setProperty( 'font-size', '0.8em', 'important' );
        el.style.setProperty( 'white-space', 'nowrap', 'important' );
        el.style.setProperty( 'display', 'inline-block', 'important' );
    } );
}
 
if ( body.classList.contains( 'font-large' ) ) {
    // Применяем сразу к тому, что уже есть
    shrinkDates();
 
    // Следим за появлением новых элементов (AJAX-подгрузка)
    var observer = new MutationObserver( function ( mutations ) {
        mutations.forEach( function ( mutation ) {
            mutation.addedNodes.forEach( function ( node ) {
                if ( node.nodeType === 1 ) { // ELEMENT_NODE
                    shrinkDates( node );
                }
            } );
         } );
         } );
     }
     } );
 
    observer.observe( document.body, {
        childList: true,
        subtree: true
    } );
}
}() );
}() );