Benutzer:Curilias/monobook.js: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
K |
K |
||
Zeile 1: | Zeile 1: | ||
var HideInfobox = '[ | var HideInfobox = '[–]'; | ||
var ShowInfobox = '[+]'; | var ShowInfobox = '[+]'; | ||
Version vom 23. Juli 2008, 00:34 Uhr
var HideInfobox = '[–]'; var ShowInfobox = '[+]'; function toggleInfobox(indexInfobox) { var InfoboxContent = document.getElementById("Infobox" + indexInfobox); var ToggleInfobox = document.getElementById("ToggleInfobox" + 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 addToggleInfoboxButton() { var indexInfobox = 0; for (var i = 0; InfoboxContainer = document.getElementsByTagName("div")[i]; i++) { if (InfoboxContainer.className == "ib_container") { indexInfobox++; // create linkt to toggle visibility var ToggleInfobox = document.createElement("a"); ToggleInfobox.className = 'ib_toggle'; ToggleInfobox.setAttribute('id', 'ToggleInfobox' + 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_content") { InfoboxContent.setAttribute('id', 'Infobox' + indexInfobox); } } } } } addOnloadHook(addToggleInfoboxButton);