MediaWiki:SupportPage.js: Difference between revisions

Content deleted Content added
No edit summary
new toc code
Line 14:
$(function() {
 
/* Code-- fortable highlightingof currentcontents sectioncode in TOC-- */
// Build a list of corresponding toc links and anchors
//var toc = })[];
// $(window'#toc > ul a').scrolleach( function() {
// var id = $(this).attr('href').replace('#', '');
toc.push({
// link: }$(this),
anchor: $( document.getElementById(id) )
// });
// });
 
// //Add Cachesmooth selectorsscrolling effect
var scrollOffset = 24, // Offset in px
// var lastId,
// topMenuscrollDuration = $('#toc500, >// ul'),in ms
// menuItemssmoothScroll = topMenu.findfunction('a'event), // All TOC links{
var offsetTop = event.data.anchor.offset().top;
// scrollItems = $('.sp-content .mw-headline'), // Anchors corresponding to TOC links
// scrollOffset = 16 $('html, // Offset in pxbody').stop().animate({
scrollTop: offsetTop - scrollOffset
// scrollDuration = 500; // in ms
// }, return thisscrollDuration);
// e event.preventDefault();
// };
for (var i = 0; i < toc.length; i++) {
toc[i].link.on( 'click', toc[i], smoothScroll );
}
 
// /* HighlightingHighlight current section in TOC */toc
// /* Bind click handler to menu items so we can get a fancy scroll animation */
var lastSection;
// menuItems$(window).clickscroll(function(e) {
// var id = $(this).attr('href').replace('#', '');
// var offsetTopfromTop = $( document.getElementById(id) this).offsetscrollTop().top; // Get container scroll position
// var $('html,currentSection body')= toc.stopfilter(function(item).animate( {
// return scrollTop:fromTop offsetTop> item.anchor.offset().top - scrollOffset48;
// }, scrollDuration);
currentSection = currentSection[currentSection.length - 1];
// e.preventDefault();
if ( lastSection !== currentSection ) {
// });
lastSection = currentSection;
// $('#toc > ul a').removeClass('-active');
currentSection.link.addClass('-active');
}
});
/* -- end of table of contents code -- */
 
// /* 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 */
 
/*!