Merry Christmas from the IIWiki Team! Have a happy new year!
MediaWiki:Gadget-SidebarTOC.js
Jump to navigation
Jump to search
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
mw.loader.using( 'mediawiki.toc', function () {
$( function () {
var $window, $sidebar, $article, $tocContainer, $toc, tocLimit;
$window = $( window );
$sidebar = $( '#mw-panel' );
$article = $( '#content' );
$tocContainer = $( '<div class="mw-table-of-contents-container"></div>' ).insertAfter( $sidebar ).append($article);
$toc = $( '.toc' ).addClass( 'vector-sticky-toc-container' ).appendTo( $tocContainer );
if ( !$toc.length ) {
return;
}
tocLimit = $article.offset().top + $article.height();
$window.on('scroll', function () {
var scrollTop = $window.scrollTop();
if (scrollTop > tocLimit) {
$toc.addClass('sticky');
} else {
$toc.removeClass('sticky');
}
});
});
});