MediaWiki:SupportPage.js: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 16:
/* Code for highlighting current section in TOC */
 
// // Cache selectors
// var lastId,
// topMenu = $('#toc > ul'),
// menuItems = topMenu.find('a'), // All TOC links
// scrollItems = $('.sp-content .mw-headline'), // Anchors corresponding to TOC links
// scrollOffset = 16, // Offset in px
// scrollDuration = 500; // in ms
 
// /* Bind click handler to menu items so we can get a fancy scroll animation */
// menuItems.click(function(e){
// var id = $(this).attr('href').replace('#', '');
// var offsetTop = $( document.getElementById(id) ).offset().top;
// $('html, body').stop().animate({
// scrollTop: offsetTop - scrollOffset
// }, scrollDuration);
// e.preventDefault();
// });
 
// /* Highlighting current section in TOC */
// $(window).scroll(function(){
// var fromTop = $(this).scrollTop(); // Get container scroll position
 
// // Get id of current scroll item
// var cur = scrollItems.map(function(){
// if ( $(this).offset().top < fromTop ) {
// return this;
// }
// });
// // Get the id of the current element
// cur = cur[cur.length-1];
// var id = cur && cur.length ? cur[0].id : '';
 
// if (lastId !== id) {
// lastId = id;
// // Set/remove active class
// menuItems
// .removeClass('-active')
// .end().filter('[href=#' + id + ']').addClass('-active');
// }
// });
// /* END of highlighting current section in TOC */
 
/*!