MediaWiki:Common.js: Difference between revisions

trying MW's version of this func too
(trying MW's version of the function)
(trying MW's version of this func too)
Line 294: Line 294:
         // if found a navigation bar
         // if found a navigation bar
         if (hasClass(NavFrame, "NavFrame")) {
         if (hasClass(NavFrame, "NavFrame")) {
 
             indexNavigationBar++;
             indexNavigationBar++;
             var NavToggle = document.createElement("a");
             var NavToggle = document.createElement("a");
Line 300: Line 300:
             NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
             NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
             NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');
             NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');
 
             var isCollapsed = hasClass( NavFrame, "collapsed" );
             var NavToggleText = document.createTextNode(NavigationBarHide);
            /*
             for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
            * Check if any children are already hidden.  This loop is here for backwards compatibility:
            * the old way of making NavFrames start out collapsed was to manually add style="display:none"
            * to all the NavPic/NavContent elements.  Since this was bad for accessibility (no way to make
            * the content visible without JavaScript support), the new recommended way is to add the class
            * "collapsed" to the NavFrame itself, just like with collapsible tables.
            */
             for (var NavChild = NavFrame.firstChild; NavChild != null && !isCollapsed; NavChild = NavChild.nextSibling) {
                 if ( hasClass( NavChild, 'NavPic' ) || hasClass( NavChild, 'NavContent' ) ) {
                 if ( hasClass( NavChild, 'NavPic' ) || hasClass( NavChild, 'NavContent' ) ) {
                     if ( NavChild.style.display == 'none' ) {
                     if (NavChild.style.display == 'none') {
                         isCollapsed = true;
                         NavToggleText = document.createTextNode(NavigationBarShow);
                        break;
                     }
                     }
                 }
                 }
             }
             }
            if (isCollapsed) {
                for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
                    if ( hasClass( NavChild, 'NavPic' ) || hasClass( NavChild, 'NavContent' ) ) {
                        NavChild.style.display = 'none';
                    }
                }
            }
            var NavToggleText = document.createTextNode(isCollapsed ? NavigationBarShow : NavigationBarHide);
             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)
             // 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++) {
             for(var j=0; j < NavFrame.childNodes.length; j++) {