Forum:Show and hide thingy

This in a old conversation of a manual installation feature please referrer to Help:Dynamic navigation for an updated and clean version.

Well, I've seen those at some wikis. You know, you click where it says "show" (or similarly), and something shows up. I tried copying template:hidden from Wikipedia. It didn't work. I tried copying template:H from Uncyc, and it didn't work. I use IE7, which normally could display such things. Can you help me? Thanks. – Smiddle 16:53, 15 April 2007 (UTC)


 * if you copy it from Wikipedia this is the code you have to paste in your commons or your monobook (better in commons) so the template can work properly

 /* Standard Navigationsleisten, aka box hiding thingy from .de.*/ div.Boxmerge, div.NavFrame { margin: 0px; padding: 2px; border: 1px solid #aaaaaa; text-align: center; border-collapse: collapse; font-size: 95%; } div.Boxmerge div.NavFrame { border-style: none; border-style: hidden; } div.NavFrame + div.NavFrame { border-top-style: none; border-top-style: hidden; } div.NavPic { background-color: #ffffff; margin: 0px; padding: 2px; float: left; } div.NavFrame div.NavHead { height: 1.6em; font-weight: bold; font-size: 100%; background-color: #efefef; position:relative; } div.NavFrame p { font-size: 100%; } div.NavFrame div.NavContent { font-size: 100%; } div.NavFrame div.NavContent p { font-size: 100%; } div.NavEnd { margin: 0px; padding: 0px; line-height: 1px; clear: both; } a.NavToggle { position:absolute; top:0px; right:3px; font-weight:normal; font-size:smaller; }

--Cizagna (Talk) 23:58, 15 April 2007 (UTC)


 * You also need some sections of javascript from Wikipedia:MediaWiki:Common.js. The sections Collapsible tables and Dynamic Navigation Bars (experimental). --Splarka (talk) 04:56, 16 April 2007 (UTC)
 * Thanks a lot, but just a question, if I put something in the wrong place (like js in the css file), does the whole thing crap up and stops working? – Smiddle 17:29, 16 April 2007 (UTC)
 * I guess that yes because if you see the HTML of any page, you will see that Monobook.css is treated as css scrip and js is treated as javascrip code --Cizagna (Talk) 17:49, 16 April 2007 (UTC)


 * This does not work as it should. I copy the information from Wikipedia:MediaWiki:Common.js the Collapsible tables and the Dynamic Navigation Bars (experimental) to the w:c:Dofus:MediaWiki:Common.js and it was unable to work properly and that was strange as i had it working perfectly on my personal monobook.js with the old code i had, and as i was implementing it now to the whole wikia and wanted to upgrade the code version but it did not work, so to make it work in the dofus wikia i had to use the old JS code (i even copy my personal user page and paste on a random wikipedia page to see if it was some class that change), but when I used the show preview it worked with out a problem. The old code that for me works properly is the followng:

 function addLoadEvent(func) {  if (window.addEventListener) window.addEventListener("load", func, false); else if (window.attachEvent) window.attachEvent("onload", func); }

// ============================================================ // BEGIN Dynamic Navigation Bars (experimantal) // set up the words in your language var NavigationBarHide = '[ Hide ]'; var NavigationBarShow = '[ Show ]'; // set up max count of Navigation Bars on page, // if there are more, all will be hidden // NavigationBarShowDefault = 0; // all bars will be hidden // NavigationBarShowDefault = 1; // on pages with more than 1 bar all bars will be hidden var NavigationBarShowDefault = 1; // shows and hides content and picture (if available) of navigation bars // Parameters: //    indexNavigationBar: the index of navigation bar to be toggled function toggleNavigationBar(indexNavigationBar) {   var NavToggle = document.getElementById("NavToggle" + indexNavigationBar); var NavFrame = document.getElementById("NavFrame" + indexNavigationBar); if (!NavFrame || !NavToggle) { return false; }   // if shown now 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'; }       }    NavToggle.firstChild.data = NavigationBarShow; // if hidden now } else if (NavToggle.firstChild.data == NavigationBarShow) { 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'; }       }    NavToggle.firstChild.data = NavigationBarHide; } } // adds show/hide-button to navigation bars function createNavigationBarToggleButton {   var indexNavigationBar = 0; // iterate over all -elements for(           var i=0;             NavFrame = document.getElementsByTagName("div")[i];             i++        ) { // if found a navigation bar 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); // 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 (NavFrame.childNodes[j].className == "NavHead") { NavFrame.childNodes[j].appendChild(NavToggle); }           }            NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar); }   }    // if more Navigation Bars found than Default: hide all if (NavigationBarShowDefault < indexNavigationBar) { for(               var i=1;                 i<=indexNavigationBar;                 i++        ) { toggleNavigationBar(i); }   } } addLoadEvent(createNavigationBarToggleButton); // END Dynamic Navigation Bars // ============================================================

Has something to do with my first 7 lines of the old code and the last one with addloadevent, Though the new code looks like you can customize it more when you are defining the class in the table not sure, now why the new code does not work? i tested with IE6 and FF2--Cizagna (Talk) 20:16, 16 April 2007 (UTC)


 * It appears to be working fine to me. Though if I might say, don't bother with the addLoadEvent, when I copied the code over I replaced that with the standard addOnloadHook which is part of the MediaWiki code itself. ~Dantman(talk) tricks Apr 17, 2007 @ 00:01 (UTC)

I think I did something wrong, because there is no show button. I tried it at UnMario. Please fix anything wrong, or leave it on the talk pages of the pages. – Smiddle 17:02, 17 April 2007 (UTC)


 * I think I fixified it? w:c:unmario:UnMarioWiki:Comic_Convention/C0m1xx0rz --Splarka (talk) 07:09, 18 April 2007 (UTC)
 * Thanks a lot. – Smiddle 18:22, 19 April 2007 (UTC)
 * Is it possible to set it as hidden by default? – Smiddle 18:25, 19 April 2007 (UTC)


 * --Splarka (talk) 05:41, 20 April 2007 (UTC)
 * It showed up when I viewed the page, it wasn't hidden. I use IE7 (not IE6, which is crap), is anything wrong? – Smiddle 12:44, 21 April 2007 (UTC)
 * Yup onload IE6 and IE7 shows it unhidding, FF shows it hidden (though as some times it loads slow it will hide once its fully loaded--Cizagna (Talk) 17:16, 21 April 2007 (UTC)