Benutzer:Curilias/monobook.js: Unterschied zwischen den Versionen

Aus MIDGARD-Wiki
Zur Navigation springen Zur Suche springen
K
K
Zeile 41: Zeile 41:
if (InfoboxContent.className == "ib_content2") {
if (InfoboxContent.className == "ib_content2") {
InfoboxContent.setAttribute('id', 'Infobox2' + indexInfobox);
InfoboxContent.setAttribute('id', 'Infobox2' + indexInfobox);
}
if (InfoboxContent.className == "ib_content_default_hidden2") {
InfoboxContent.setAttribute('id', 'Infobox2' + indexInfobox);
InfoboxContent.style.display = 'none';
ToggleInfobox.firstChild.data = ShowInfobox;
}
}
}
}

Version vom 23. Juli 2008, 18:11 Uhr

var HideInfobox = '[–]';
var ShowInfobox = '[+]';

function toggleInfobox2(indexInfobox) {
	var InfoboxContent = document.getElementById("Infobox2" + indexInfobox);
	var ToggleInfobox = document.getElementById("ToggleInfobox2" + indexInfobox);

	if (!InfoboxContent || !ToggleInfobox) { return false; }

	if (ToggleInfobox.firstChild.data == HideInfobox) {
		InfoboxContent.style.display = 'none';
	} else if (ToggleInfobox.firstChild.data == ShowInfobox) {
		InfoboxContent.style.display = 'block';
	}

	if (ToggleInfobox.firstChild.data == HideInfobox) {
		ToggleInfobox.firstChild.data = ShowInfobox;
	} else {
		ToggleInfobox.firstChild.data = HideInfobox;
	}
}
 
function addToggleInfoboxButton2() {
	var indexInfobox = 0;
	for (var i = 0; InfoboxContainer = document.getElementsByTagName("div")[i]; i++) {
		if (InfoboxContainer.className == "ib_container2") {
			indexInfobox++;

			// create linkt to toggle visibility
			var ToggleInfobox = document.createElement("a");
			ToggleInfobox.className = 'ib_toggle2';
			ToggleInfobox.setAttribute('title', 'Ein-/Ausklappen');
			ToggleInfobox.setAttribute('id', 'ToggleInfobox2' + indexInfobox );
			ToggleInfobox.setAttribute('href', 'javascript:toggleInfobox2(' + indexInfobox + ');');
			var ToggleCaption = document.createTextNode(HideInfobox);
			ToggleInfobox.appendChild(ToggleCaption);

			InfoboxContainer.insertBefore(ToggleInfobox, InfoboxContainer.firstChild);

			for (var j=0; InfoboxContent = InfoboxContainer.getElementsByTagName("div")[j]; j++) {
				if (InfoboxContent.className == "ib_content2") {
					InfoboxContent.setAttribute('id', 'Infobox2' + indexInfobox);
				}
				if (InfoboxContent.className == "ib_content_default_hidden2") {
					InfoboxContent.setAttribute('id', 'Infobox2' + indexInfobox);
					InfoboxContent.style.display = 'none';
					ToggleInfobox.firstChild.data = ShowInfobox;
				}
			}
		}
	}
}
 
addOnloadHook(addToggleInfoboxButton2);