MediaWiki:Common.js: Unterschied zwischen den Versionen

Zur Navigation springen Zur Suche springen
keine Bearbeitungszusammenfassung
KKeine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Zeile 152:
addOnloadHook(toggleInit);
 
function toggleObjectVisibility(objectId) {
var styleObject = document.getElementById(objectId);
if (styleObject) {
if (styleObject.style.display == 'block') {
styleObject.style.display = "none";
} else {
styleObject.style.display = "block";
}
}
}
 
 
var spoilersDone, navbarsDone;
//================================================================================
//*** Dynamic Navigation Bars
Zeile 166 ⟶ 180:
}
// addsshows show/hide-buttonand tohides content and picture (if available) of navigation bars
// Parameters:
addOnloadHook(function() {
// shows and hides content andindexNavigationBar: picturethe (if available)index of navigation barsbar to be toggled
function toggleNavigationBar(indexNavigationBar)
// Parameters:
{
// indexNavigationBar: the index of navigation bar to be toggled
function toggleNavigationBar(indexNavigationBar)
var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
{
var NavToggleNavFrame = document.getElementById("NavToggleNavFrame" + indexNavigationBar);
var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
if (!NavFrame || !NavToggle) {
return false;
}
// if shown now
if (NavToggle.firstChild.data == NavigationBarHide) {
for (
var NavChild = NavFrame.firstChild;
NavChild != null;
NavChild = NavChild.nextSibling
) {
if (NavChild.className == 'NavPic') {
NavChild.style.display = 'none';
}
if (NavChild.className == 'NavContent') {
NavChild.style.display = 'none';
}
if (NavChild.className == 'NavToggle') {
NavChild.firstChild.data = NavigationBarShow;
}
}
// if hidden now
} else if (NavToggle.firstChild.data == NavigationBarShow) {
for (
var NavChild = NavFrame.firstChild;
NavChild != null;
NavChild = NavChild.nextSibling
) {
if (NavChild.className == 'NavPic') {
NavChild.style.display = 'block';
}
if (NavChild.className == 'NavContent') {
NavChild.style.display = 'block';
}
if (NavChild.className == 'NavToggle') {
NavChild.firstChild.data = NavigationBarHide;
}
}
}
 
}
}
function toggleNavigationBarFunction(indexNavigationBar) {
return function() {
toggleNavigationBar(indexNavigationBar);
return false;
};
}
// adds show/hide-button to navigation bars
function createNavigationBarToggleButton()
{
if (navbarsDone) return;
var indexNavigationBar = 0;
// iterate over all < div >-elements
Zeile 231 ⟶ 242:
var NavFrame = divs[i];
// if found a navigation bar
if (NavFrame.className == "NavFrame" || NavFrame.className == "NavFrame Ausgeklappt" || NavFrame.className == "NavFrame Zugeklappt") {
indexNavigationBar++;
Zeile 237 ⟶ 248:
NavToggle.className = 'NavToggle';
NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
NavToggle.setAttribute('href', '#javascript:toggleNavigationBar(' + indexNavigationBar + ');');
NavToggle.onclick = toggleNavigationBarFunction(indexNavigationBar);
var NavToggleText = document.createTextNode(NavigationBarHide);
NavToggle.appendChild(NavToggleText);
// add NavToggle-Button as first div-element
// in < div class="NavFrame" >
NavFrame.insertBefore(
Zeile 250 ⟶ 260:
);
NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
if (NavFrame.className == "NavFrame Zugeklappt") toggleNavigationBar(indexNavigationBar);
}
}
Zeile 255 ⟶ 266:
if (NavigationBarShowDefault < indexNavigationBar) {
for(
var i=1;
i<=indexNavigationBar;
i++
) {
toggleNavigationBarvar NavFrame = document.getElementById("NavFrame" + i);
if (NavFrame.className == "NavFrame") toggleNavigationBar(i);
}
}
navbarsDone = true;
});
}
if (typeof showAllSpoiler == 'undefined' ) {
var showAllSpoiler = 0;
}
 
function createSpoiler() {
if (showAllSpoiler || spoilersDone) return;
 
var indexSpoiler = 0;
// iterate over all < div >-elements
var divs = document.getElementsByTagName("div");
for (var i=0; i<divs.length; i++) {
var Spoiler = divs[i];
if (Spoiler.className == "spoiler") {
indexSpoiler++;
Spoiler.style.display = "none";
 
var SpoilerToggle = document.createElement("a");
SpoilerToggle.className = 'spoilerButton';
SpoilerToggle.setAttribute('id', 'SpoilerToggle' +indexSpoiler);
SpoilerToggle.setAttribute('href', 'javascript:toggleObjectVisibility(\'Spoiler' + indexSpoiler + '\');');
var spLabel = Spoiler.getAttribute("title");
Spoiler.setAttribute("title", "");
if (!spLabel) spLabel = "Spoiler";
var SpoilerToggleText = document.createTextNode(spLabel);
SpoilerToggle.appendChild(SpoilerToggleText);
document.getElementById("bodyContent").insertBefore(
SpoilerToggle,
Spoiler
);
Spoiler.setAttribute('id', 'Spoiler' + indexSpoiler);
}
}
spoilersDone = true;
}
 
function createContentTabs() {
var ict = 0, divs = document.getElementsByTagName("div"), defaultTab;
for (var i = 0; i<divs.length; i++) {
var ctdiv = divs[i];
if (ctdiv.className == "Tabs") {
var firstTab, tabs;
ict++;
 
if (document.getElementById("ct_"+ict)) continue;
ctdiv.parentNode.id = "ct_"+ict;
tabs = ctdiv.childNodes;
defaultTab = ctdiv.title;
ctdiv.setAttribute("title", "");
 
for (var j=0; j<tabs.length; j++) {
var tab = tabs[j];
var toggle = document.createElement("a");
var tabName = tab.className;
if (!tabName) continue;
 
toggle.setAttribute('href', 'javascript:toggleTab(\'ct_'+ict+'\', \''+tabName+'\');');
toggle.setAttribute('id', 'ct_'+ict+'_'+tabName);
 
var spLabel = tab.innerHTML;
if (!spLabel) continue;
toggle.innerHTML = spLabel;
 
if (!firstTab) {
firstTab = tabName;
if (!defaultTab) {
defaultTab=tabName;
}
}
ctdiv.appendChild(toggle);
ctdiv.removeChild(tab);
}
toggleTab("ct_"+ict, defaultTab);
}
}
}
function toggleTab(ct_id, ct_tab) {
var a = document.getElementById(ct_id);
for (var i = 0; i<a.childNodes.length; i++) {
var b = a.childNodes[i];
for (var j = 0; j<b.childNodes.length; j++) {
var c = b.childNodes[j];
if(c.id||c.className) {
if (b.className=="Tabs") {
c.className="";
} else if (b.className=="Contents") {
c.style.display="none";
if (c.id==ct_tab) c.style.display = "block";
}
}
}
}
document.getElementById(ct_id+"_"+ct_tab).className = "active";
}
addOnloadHook(createNavigationBarToggleButton);
addOnloadHook(createSpoiler);
addOnloadHook(createContentTabs);

Navigationsmenü