MediaWiki:Gadget-SidebarTOC.js: Difference between revisions

Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 1: Line 1:
mw.loader.using( 'mediawiki.toc', function () {
mw.loader.using( 'mediawiki.toc', function () {
$( function () {
$( function () {
var $window, $sidebar, $article, $tocContainer, $toc;
var $window, $article, $tocContainer, $toc;


$window = $( window );
$window = $( window );
$sidebar = $( '#mw-panel' );
$article = $( '.vector-body' );
$article = $( '.vector-body' );
$tocContainer = $( '<div class="mw-table-of-contents-container"></div>' ).insertAfter( $sidebar );
$tocContainer = $( '<div class="mw-table-of-contents-container"></div>' ).insertBefore( $article );
$toc = $( '.toc' ).addClass( 'vector-sticky-toc-container' ).appendTo( $tocContainer );
$toc = $( '.toc' ).addClass( 'vector-sticky-toc-container' ).appendTo( $tocContainer );


Line 18: Line 17:
bottom: 0,
bottom: 0,
width: '15%', /* Adjust as needed */
width: '15%', /* Adjust as needed */
overflow: 'auto'
overflow: 'auto',
left: 0
});
});


     });
     });
});
});

Revision as of 07:10, 22 February 2024

mw.loader.using( 'mediawiki.toc', function () {
	$( function () {
		var $window, $article, $tocContainer, $toc;

		$window = $( window );
		$article = $( '.vector-body' );
		$tocContainer = $( '<div class="mw-table-of-contents-container"></div>' ).insertBefore( $article );
		$toc = $( '.toc' ).addClass( 'vector-sticky-toc-container' ).appendTo( $tocContainer );

		if ( !$toc.length ) {
			return;
		}

		$tocContainer.css({
			position: 'fixed',
			top: 0,
			bottom: 0,
			width: '15%', /* Adjust as needed */
			overflow: 'auto',
			left: 0
		});

    });
});