|
|
Line 90: |
Line 90: |
| | | |
| addOnloadHook( createCollapseButtons ); | | addOnloadHook( createCollapseButtons ); |
|
| |
| var NavigationBarHide = 'hide ▲';var NavigationBarShow = 'show ▼'; function NavToggleCategory(navFrame){ var table = navFrame.getElementsByTagName('table')[0]; if (table && table.className == "translations") return "translations"; var heading = navFrame.previousSibling; while (heading) { if (/[hH][4-6]/.test(heading.nodeName)) { if (heading.getElementsByTagName('span')[1]) heading = heading.getElementsByTagName('span')[1]; else heading = heading.getElementsByTagName('span')[0]; return $(heading).text().toLowerCase() // jQuery's .text() is inconsistent about whitespace: .replace(/^\s+|\s+$/g, '').replace(/\s+/g, ' ') // remove numbers added by the "Auto-number headings" pref: .replace(/^[1-9][0-9.]+ ?/, ''); } else if (/[hH][1-3]/.test(heading.nodeName)) break; heading = heading.previousSibling; } return "other boxes";};function createNavToggle(navFrame){ var navHead, navToggle, navContent; for (var j=0; j < navFrame.childNodes.length; j++) { var div = navFrame.childNodes[j]; switch (div.className) { case 'NavHead': navHead = div; break; case 'NavContent': navContent = div; break; } } if (!navHead || !navContent) return; // Step 1, don't react when a subitem is clicked. for (var i=0; i<navHead.childNodes.length; i++) { var child = navHead.childNodes[i]; if (child.nodeName == "A") { child.onclick = function (e) { if (e && e.stopPropagation) e.stopPropagation(); else window.event.cancelBubble = true; } } } // Step 2, toggle visibility when bar is clicked. // NOTE This function was chosen due to some funny behaviour in Safari. navToggle = newNode('a', {href: 'javascript:(function(){})()'}, ''); navHead.insertBefore(newNode('span', {'class': 'NavToggle'}, '[', navToggle, ']'), navHead.firstChild); navHead.style.cursor = "pointer"; navHead.onclick = VisibilityToggles.register(NavToggleCategory(navFrame), function show() { navToggle.innerHTML = NavigationBarHide; if (navContent) navContent.style.display = "block"; }, function hide() { navToggle.innerHTML = NavigationBarShow; if (navContent) navContent.style.display = "none"; });}; addOnloadHook( function (){ var divs = $(".NavFrame"); for (var i=0; i<divs.length; i++) { // NOTE: some templates use a class of NavFrame for the style, but for legacy reasons, are not NavFrames if (divs[i].className == "NavFrame") { createNavToggle(divs[i]); } } });
| |
| | | |
| /** Test if an element has a certain class ************************************** | | /** Test if an element has a certain class ************************************** |