|
|
Linje 171: |
Linje 171: |
| } | | } |
| | | |
| // adds show/hide-button to navigation bars
| | // Changed function from da.wikipedia 2008-07-02 ------------------ |
| function createNavigationBarToggleButton()
| |
| {
| |
| var indexNavigationBar = 0;
| |
| // iterate over all < div >-elements
| |
| var divs = document.getElementsByTagName("div");
| |
| for(
| |
| var i=0;
| |
| NavFrame = divs[i];
| |
| i++
| |
| ) {
| |
| // if found a navigation bar
| |
| if (hasClass(NavFrame, "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);
| |
| for (
| |
| var NavChild = NavFrame.firstChild;
| |
| NavChild != null;
| |
| NavChild = NavChild.nextSibling
| |
| ) {
| |
| if ( hasClass( NavChild, 'NavPic' ) || hasClass( NavChild, 'NavContent' ) ) {
| |
| if (NavChild.style.display == 'none') {
| |
| NavToggleText = document.createTextNode(NavigationBarShow);
| |
| break;
| |
| }
| |
| }
| |
| }
| |
|
| |
| NavToggle.appendChild(NavToggleText);
| |
| // Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
| |
| for(
| |
| var j=0;
| |
| j < NavFrame.childNodes.length;
| |
| j++
| |
| ) {
| |
| if (hasClass(NavFrame.childNodes[j], "NavHead")) {
| |
| NavFrame.childNodes[j].appendChild(NavToggle);
| |
| }
| |
| }
| |
| NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
| |
| }
| |
| }
| |
| }
| |
|
| |
| addOnloadHook( createNavigationBarToggleButton );
| |
| // adds show/hide-button to navigation bars | | // adds show/hide-button to navigation bars |
| function createNavigationBarToggleButton() | | function createNavigationBarToggleButton() |
| { | | { |
| var indexNavigationBar = 0; | | var indexNavigationBar = 0; |
| // iterate over all < div >-elements | | // iterate over all < div >-elements |
| var divs = document.getElementsByTagName("div");
| |
| for( | | for( |
| var i=0; | | var i=0; |
| NavFrame = divs[i]; | | NavFrame = document.getElementsByTagName("div")[i]; |
| i++ | | i++ |
| ) { | | ) { |
| // if found a navigation bar | | // if found a navigation bar |
| if (hasClass(NavFrame, "NavFrame")) { | | if (NavFrame.className == "NavFrame") { |
| | | |
| indexNavigationBar++; | | indexNavigationBar++; |
| var NavToggle = document.createElement("a"); | | var NavToggle = document.createElement("a"); |
Linje 241: |
Linje 190: |
| NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar); | | NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar); |
| NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');'); | | NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');'); |
| | | |
| var NavToggleText = document.createTextNode(NavigationBarHide); | | var NavToggleText = document.createTextNode(NavigationBarHide); |
| for (
| |
| var NavChild = NavFrame.firstChild;
| |
| NavChild != null;
| |
| NavChild = NavChild.nextSibling
| |
| ) {
| |
| if ( hasClass( NavChild, 'NavPic' ) || hasClass( NavChild, 'NavContent' ) ) {
| |
| if (NavChild.style.display == 'none') {
| |
| NavToggleText = document.createTextNode(NavigationBarShow);
| |
| break;
| |
| }
| |
| }
| |
| }
| |
|
| |
| NavToggle.appendChild(NavToggleText); | | NavToggle.appendChild(NavToggleText); |
| // Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked) | | |
| for( | | // add NavToggle-Button as first div-element |
| var j=0;
| | // in < div class="NavFrame" > |
| j < NavFrame.childNodes.length;
| | NavFrame.insertBefore( |
| j++
| | NavToggle, |
| ) { | | NavFrame.firstChild |
| if (hasClass(NavFrame.childNodes[j], "NavHead")) {
| | ); |
| NavFrame.childNodes[j].appendChild(NavToggle); | |
| }
| |
| }
| |
| NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar); | | NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar); |
| } | | } |
| } | | } |
| | // if more Navigation Bars found than Default: hide all |
| | if (NavigationBarShowDefault < indexNavigationBar && !document.getElementById("NavFrameOpenAll")) { |
| | for( |
| | var i=1; |
| | i<=indexNavigationBar; |
| | i++ |
| | ) { |
| | toggleNavigationBar(i); |
| | } |
| | } |
| | |
| } | | } |
| | | |
| addOnloadHook( createNavigationBarToggleButton ); | | aOnloadFunctions[aOnloadFunctions.length] = createNavigationBarToggleButton; |