MediaWiki:SupportPage.js: Difference between revisions
Content deleted Content added
Tag: Undo |
minor cleanup |
||
Line 18:
// Cache selectors
var lastId,
topMenu = $(
menuItems = topMenu.find('a'), // All
scrollItems = $('.sp-content .mw-headline'); // Anchors corresponding to TOC links▼
▲ scrollItems = $('.sp-content .mw-headline');
/
menuItems.click(function(e){
var id = $(this).attr(
offsetTop = $( document.getElementById(id) ).offset().top;
$('html, body').stop().animate({
Line 35 ⟶ 32:
});
/* Highlighting current section in TOC */
$(window).scroll(function(){
// Get container scroll position
Line 42 ⟶ 39:
// 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) {
Line 53 ⟶ 50:
// Set/remove active class
menuItems
.removeClass(
.end().filter(
}
});
/* END of
/*!
|