« MediaWiki:Edittools.js » : différence entre les versions
m (Page blanchie) |
mAucun résumé des modifications |
||
Ligne 1 : | Ligne 1 : | ||
var NavigationBarHide = '[ Enrouler ]'; | |||
var NavigationBarShow = '[ Dérouler ]'; | |||
var NavigationBarShowDefault = 0; | |||
function toggleNavigationBar(indexNavigationBar) | |||
{ | |||
var NavToggle = document.getElementById("NavToggle" + indexNavigationBar); | |||
var NavFrame = document.getElementById("NavFrame" + indexNavigationBar); | |||
if (!NavFrame || !NavToggle) { | |||
return false; | |||
} | |||
var ShowText; | |||
if (NavFrame.title == undefined || NavFrame.title.length == 0 ) { | |||
ShowText = NavigationBarShow; | |||
} else { | |||
ShowText = NavFrame.title; | |||
} | |||
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 = ShowText; | |||
} | |||
} | |||
} else if (NavToggle.firstChild.data == ShowText) { | |||
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; | |||
} | |||
} | |||
} | |||
} | |||
{ | |||
var indexNavigationBar = 0; | |||
// iterate over all < div >-elements | |||
for( | |||
var i=0; | |||
NavFrame = document.getElementsByTagName("div")[i]; | |||
i++ | |||
) { | |||
if (NavFrame.className == "NavFrame") { | |||
indexNavigationBar++; | |||
var NavToggle = document.createElement("a"); | |||
NavToggle.className = 'NavToggle'; | |||
NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar); | |||
NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');'); | |||
var NavToggleText = document.createTextNode(NavigationBarHide); | |||
NavToggle.appendChild(NavToggleText); | |||
NavFrame.insertBefore( | |||
NavToggle, | |||
NavFrame.firstChild | |||
); | |||
NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar); | |||
} | |||
} | |||
if (NavigationBarShowDefault < indexNavigationBar) { | |||
for( | |||
var i=1; | |||
i<=indexNavigationBar; | |||
i++ | |||
) { | |||
toggleNavigationBar(i); | |||
} | |||
} | |||
} |
Version du 12 février 2011 à 18:35
var NavigationBarHide = '[ Enrouler ]'; var NavigationBarShow = '[ Dérouler ]'; var NavigationBarShowDefault = 0; function toggleNavigationBar(indexNavigationBar) { var NavToggle = document.getElementById("NavToggle" + indexNavigationBar); var NavFrame = document.getElementById("NavFrame" + indexNavigationBar); if (!NavFrame || !NavToggle) { return false; } var ShowText; if (NavFrame.title == undefined || NavFrame.title.length == 0 ) { ShowText = NavigationBarShow; } else { ShowText = NavFrame.title; } 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 = ShowText; } } } else if (NavToggle.firstChild.data == ShowText) { 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; } } } } { var indexNavigationBar = 0; // iterate over all < div >-elements for( var i=0; NavFrame = document.getElementsByTagName("div")[i]; i++ ) { if (NavFrame.className == "NavFrame") { indexNavigationBar++; var NavToggle = document.createElement("a"); NavToggle.className = 'NavToggle'; NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar); NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');'); var NavToggleText = document.createTextNode(NavigationBarHide); NavToggle.appendChild(NavToggleText); NavFrame.insertBefore( NavToggle, NavFrame.firstChild ); NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar); } } if (NavigationBarShowDefault < indexNavigationBar) { for( var i=1; i<=indexNavigationBar; i++ ) { toggleNavigationBar(i); } } }