MediaWiki:Gadget-TabSystem.js: Difference between revisions

m
no edit summary
No edit summary
mNo edit summary
 
(11 intermediate revisions by the same user not shown)
Line 62: Line 62:
sections[seci] = {};
sections[seci] = {};
legends[0].className = 'mainTab';
legends[0].className = 'mainTab';
if ( legends[0] && legends[0].firstChild.nodeValue ) {
sections[seci].html = legends[0].innerHTML;
sections[seci].text = legends[0].firstChild.nodeValue;
} else {
sections[seci].text = '# ' + seci;
}
sections[seci].secid = children[i].id;
sections[seci].secid = children[i].id;
seci++;
seci++;
Line 88: Line 84:
a.href = '#' + sections[i].secid;
a.href = '#' + sections[i].secid;
a.onmousedown = a.onclick = uncoverTabSection;
a.onmousedown = a.onclick = uncoverTabSection;
a.appendChild( document.createTextNode( sections[i].text ) );
a.innerHTML = sections[i].html;
a.tc = tc;
a.tc = tc;
a.secid = sections[i].secid;
a.secid = sections[i].secid;
Line 107: Line 103:
$(window).scroll();
$(window).scroll();
$(window).resize();
$(window).resize();
$('.slideshow-current').trigger('click');
ul.selectedid = this.secid;
ul.selectedid = this.secid;
var lis = ul.getElementsByTagName( 'li' );
var lis = ul.getElementsByTagName( 'li' );
Line 114: Line 109:
}
}
this.parentNode.className = 'selected';
this.parentNode.className = 'selected';
setTimeout(function() { $('.slideshow-current').click(); }, 100);
}
}
return false;
return false;
}
}
/* Fix hidden section links */
window.onhashchange = function() {
escapedHash = $.escapeSelector(decodeURI(location.hash.split('#').pop()));
tabId = $('#' + escapedHash).closest('.tabsection').attr('id');
if (tabId) {
$('a[href="#' + tabId + '"]').click();
}
hiddenParents = $('#' + escapedHash).parents('.mw-collapsed');
if (hiddenParents.length) {
hiddenParents.each(function() {
$(this).find('.mw-collapsible-toggle-collapsed').first().click();
});
}
if (tabId || hiddenParents.length) {
location.href = location.hash;
}
}
setTimeout(function() {
if (location.hash) {
window.dispatchEvent(new HashChangeEvent('hashchange'));
}
}, 100);


$( tabSystem );
$( tabSystem );