Benutzer:Curilias/monobook.js: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
K |
K |
||
Zeile 2: | Zeile 2: | ||
var ShowInfobox = '[+]'; | var ShowInfobox = '[+]'; | ||
function | function toggleInfobox2(indexInfobox) { | ||
var InfoboxContent = document.getElementById(" | var InfoboxContent = document.getElementById("Infobox2" + indexInfobox); | ||
var ToggleInfobox = document.getElementById(" | var ToggleInfobox = document.getElementById("ToggleInfobox2" + indexInfobox); | ||
if (!InfoboxContent || !ToggleInfobox) { return false; } | if (!InfoboxContent || !ToggleInfobox) { return false; } | ||
Zeile 21: | Zeile 21: | ||
} | } | ||
function | function addToggleInfoboxButton2() { | ||
var indexInfobox = 0; | var indexInfobox = 0; | ||
for (var i = 0; InfoboxContainer = document.getElementsByTagName("div")[i]; i++) { | for (var i = 0; InfoboxContainer = document.getElementsByTagName("div")[i]; i++) { | ||
if (InfoboxContainer.className == " | if (InfoboxContainer.className == "ib_container2") { | ||
indexInfobox++; | indexInfobox++; | ||
// create linkt to toggle visibility | // create linkt to toggle visibility | ||
var ToggleInfobox = document.createElement("a"); | var ToggleInfobox = document.createElement("a"); | ||
ToggleInfobox.className = ' | ToggleInfobox.className = 'ib_toggle2'; | ||
ToggleInfobox.setAttribute('title', 'Ein-/Ausklappen'); | ToggleInfobox.setAttribute('title', 'Ein-/Ausklappen'); | ||
ToggleInfobox.setAttribute('id', ' | ToggleInfobox.setAttribute('id', 'ToggleInfobox2' + indexInfobox ); | ||
ToggleInfobox.setAttribute('href', 'javascript:toggleInfobox(' + indexInfobox + ');'); | ToggleInfobox.setAttribute('href', 'javascript:toggleInfobox(' + indexInfobox + ');'); | ||
var ToggleCaption = document.createTextNode(HideInfobox); | var ToggleCaption = document.createTextNode(HideInfobox); | ||
Zeile 39: | Zeile 39: | ||
for (var j=0; InfoboxContent = InfoboxContainer.getElementsByTagName("div")[j]; j++) { | for (var j=0; InfoboxContent = InfoboxContainer.getElementsByTagName("div")[j]; j++) { | ||
if (InfoboxContent.className == " | if (InfoboxContent.className == "ib_content2") { | ||
InfoboxContent.setAttribute('id', ' | InfoboxContent.setAttribute('id', 'Infobox2' + indexInfobox); | ||
} | } | ||
} | } | ||
Zeile 47: | Zeile 47: | ||
} | } | ||
addOnloadHook( | addOnloadHook(addToggleInfoboxButton2); |
Version vom 23. Juli 2008, 14:26 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:toggleInfobox(' + 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); } } } } } addOnloadHook(addToggleInfoboxButton2);