MediaWiki:NavigationTabs.js
Shënim: Pas botimit, mund t’ju duhet të anashkaloni fshehtinën e shfletuesit tuaj, që të shihni ndryshimet.
- Firefox / Safari: Mbani të shtypur tastin Shift teksa klikoni mbi Ringarkoje, ose shtypni një nga kombinimet Ctrl-F5 ose Ctrl-R (⌘-R në Mac)
- Google Chrome: Shtypni Ctrl-Shift-R (⌘-Shift-R në Mac)
- Internet Explorer / Edge: Mbani të shtypur Ctrl teksa klikoni mbi Refresh, ose shtypni Ctrl-F5
- Opera: Shtypni Ctrl-F5.
// Navigate Tabs (copied from wikibooks). Allows for lots of information to be displayed on a page in a more compact form.
// Originally Created by [[User:Darklama]]. If there is a problem with this on wikinews, feel free to yell at [[user:Bawolff]]
//Warning: This takes a very long time on long pages (specifically the find funtion). If we decide this would be useful to be enabled
// globally, this would have to be fixed first
function Navigate_Tabs()
{
function select_tab(id) {
if (!id) return false;
var contents = document.getElementById(id.substring(1));
if (contents && $(contents).hasClass( 'contents') && $(contents.parentNode).hasClass( "navtabs")) {
for (var tabs = contents.parentNode.firstChild; tabs != null; tabs = tabs.nextSibling) {
if ($(tabs).hasClass( "tabs") || (tabs.nodeName.toLowerCase() == 'p' && $(tabs.firstChild).hasClass( "tabs"))) {
var links = tabs.getElementsByTagName("a");
for (var i = 0; link = links[i]; i++) {
if (link.hash) {
if ($(link.parentNode).hasClass( "selected"))
link.parentNode.className = link.parentNode.className.replace(/(^|\s)selected(\s|$)/g, "$1inactive$2");
else if (!$(link.parentNode).hasClass( "inactive"))
link.parentNode.className += (link.parentNode.className ? " " : "") + "inactive";
if (link.hash == id)
link.parentNode.className = link.parentNode.className.replace(/(^|\s)inactive(\s|$)/g, "$1selected$2");
}
}
} else if ($(tabs).hasClass( "contents")) {
tabs.style.display = "none";
}
}
contents.style.display = "block";
}
return false;
}
function clicked_tab(e)
{
var target;
if (!e) e = window.event;
if (e.target) target = e.target;
else if (e.srcElement) target = e.srcElement;
else return;
if (target.nodeType && target.nodeType == 3)
target = target.parentNode;
if (target.nodeType && (target.tagName.toLowerCase() != 'a' || !target.hash))
return;
if (e.preventDefault) e.preventDefault(); else e.returnValue = false;
return select_tab(target.hash ? target.hash : target);
}
function find(tree) {
var nav, tabs, tab;
if (!tree)
return;
for (var i=0; i < tree.length; i++) {
var node = tree[i];
if (!nav && $(node).hasClass( 'navtabs')) {
node.onclick = clicked_tab;
nav = node;
} else if (nav && !tabs && $(node).hasClass( 'tabs')) {
tabs = node;
} else if (tabs && !tab && $(node).hasClass( 'selected')) {
if (node.tagName.toLowerCase() == 'a' && node.hash) {
select_tab(node.hash);
nav = tabs = null;
} else {
tab = node;
}
} else if (tab && node.tagName.toLowerCase() == 'a' && node.hash) {
select_tab(node.hash);
tab = tabs = nav = null;
} else if ($(node).hasClass( 'navtabs')) {
find(tree.slice(i));
}
}
}
var page = document.getElementById("bodyContent") || document.getElementById("article") || document.getElementById("content");
if (page)
find(page.getElementsByTagName("*"));
}
$(document).ready(Navigate_Tabs);