m (Removing redlinks.) Tag: apiedit |
m (Removing redlinks.) Tag: apiedit |
||
Line 12: | Line 12: | ||
! style="background-color:#FF0000; color:#000000; padding:0.2em 0.5em;" nowrap="nowrap"|<div style="text-indent: 10%;">Units</div> |
! style="background-color:#FF0000; color:#000000; padding:0.2em 0.5em;" nowrap="nowrap"|<div style="text-indent: 10%;">Units</div> |
||
|- |
|- |
||
− | | style="padding:0.2em 0.5em;"| '''[[:Category:Passive units|Passive]]''': Gremlin miner<br />'''[[:Category:Melee units|Melee]]''': Skully · Dead Knight · [[Zombie]] · [[Wolf]] · Imp · Gargoyle · |
+ | | style="padding:0.2em 0.5em;"| '''[[:Category:Passive units|Passive]]''': Gremlin miner<br />'''[[:Category:Melee units|Melee]]''': Skully · Dead Knight · [[Zombie]] · [[Wolf]] · Imp · Gargoyle · Spidey · Medusa · Troll · [[Dragon]]<br />'''[[:Category:Mid range units|Mid range]]''': [[Vamp]] · Necromancer · Reap<br />'''[[:Category:Long range units|Long range]]''': Skully Archer · Lich<br />'''[[:Category:Summoned units|Summoned]]''': Little spidey · Mummy · Necromancer zombie · Goblin · Ghost · (Nether Ghost)<br /><br />'''Unknown''': (Cerberus) |
|}</nowiki></pre> |
|}</nowiki></pre> |
||
Line 817: | Line 817: | ||
! style="background-color:#FF0000; color:#000000; padding:0.2em 0.5em;" nowrap="nowrap"|<div style="text-indent: 10%;">Units</div> |
! style="background-color:#FF0000; color:#000000; padding:0.2em 0.5em;" nowrap="nowrap"|<div style="text-indent: 10%;">Units</div> |
||
|- |
|- |
||
− | | style="padding:0.2em 0.5em;"| '''[[:Category:Passive units|Passive]]''': Gremlin miner<br />'''[[:Category:Melee units|Melee]]''': Skully · Dead Knight · [[Zombie]] · [[Wolf]] · Imp · Gargoyle · |
+ | | style="padding:0.2em 0.5em;"| '''[[:Category:Passive units|Passive]]''': Gremlin miner<br />'''[[:Category:Melee units|Melee]]''': Skully · Dead Knight · [[Zombie]] · [[Wolf]] · Imp · Gargoyle · Spidey · Medusa · Troll · [[Dragon]]<br />'''[[:Category:Mid range units|Mid range]]''': [[Vamp]] · Necromancer · Reap<br />'''[[:Category:Long range units|Long range]]''': Skully Archer · Lich<br />'''[[:Category:Summoned units|Summoned]]''': Little spidey · Mummy · Necromancer zombie · Goblin · Ghost · (Nether Ghost)<br /><br />'''Unknown''': (Cerberus) |
|} |
|} |
||
My code: |
My code: |
||
Line 824: | Line 824: | ||
! style="background-color:#FF0000; color:#000000; padding:0.2em 0.5em;" nowrap="nowrap"|<div style="text-indent: 10%;">Units</div> |
! style="background-color:#FF0000; color:#000000; padding:0.2em 0.5em;" nowrap="nowrap"|<div style="text-indent: 10%;">Units</div> |
||
|- |
|- |
||
− | | style="padding:0.2em 0.5em;"| '''[[:Category:Passive units|Passive]]''': Gremlin miner<br />'''[[:Category:Melee units|Melee]]''': Skully · Dead Knight · [[Zombie]] · [[Wolf]] · Imp · Gargoyle · |
+ | | style="padding:0.2em 0.5em;"| '''[[:Category:Passive units|Passive]]''': Gremlin miner<br />'''[[:Category:Melee units|Melee]]''': Skully · Dead Knight · [[Zombie]] · [[Wolf]] · Imp · Gargoyle · Spidey · Medusa · Troll · [[Dragon]]<br />'''[[:Category:Mid range units|Mid range]]''': [[Vamp]] · Necromancer · Reap<br />'''[[:Category:Long range units|Long range]]''': Skully Archer · Lich<br />'''[[:Category:Summoned units|Summoned]]''': Little spidey · Mummy · Necromancer zombie · Goblin · Ghost · (Nether Ghost)<br /><br />'''Unknown''': (Cerberus) |
|} |
|} |
||
[[User:Lunarity|Lunarity]] 04:53, July 28, 2012 (UTC) |
[[User:Lunarity|Lunarity]] 04:53, July 28, 2012 (UTC) |
Revision as of 18:36, 1 April 2016
To contact staff directly or to report bugs, please use Special:Contact.
- NOTE: ALL PROBLEMS ARE FIXED
I currently have some problems with an support of parserfunctions inside an collapse class. Here an example:
- The page it showed: {{Navbox troops}}
- Navbox troops template: {{Navbox units}}{{Navbox neutral}}{{Navbox heroes}}
- Navbox units:
{| class="navbox collapsible{{#switch:{{PAGENAME}}|Gremlin miner|Skully|Dead Knight|Zombie|Wolf|Imp|Gargoyle|Spidey|Medusa|Troll|Dragon|Vamp|Necromancer|Reap|Skully Archer|Lich|Little spidey|Mummy|Necromancer zombie|Goblin|Ghost|Nether Ghost|Cerberus=|#default= collapsed}}" style="width:100%; margin-top:1em; border:1px solid #999; font-size:90%; text-align:center;" |- ! style="background-color:#FF0000; color:#000000; padding:0.2em 0.5em;" nowrap="nowrap"|<div style="text-indent: 10%;">Units</div> |- | style="padding:0.2em 0.5em;"| '''[[:Category:Passive units|Passive]]''': Gremlin miner<br />'''[[:Category:Melee units|Melee]]''': Skully · Dead Knight · [[Zombie]] · [[Wolf]] · Imp · Gargoyle · Spidey · Medusa · Troll · [[Dragon]]<br />'''[[:Category:Mid range units|Mid range]]''': [[Vamp]] · Necromancer · Reap<br />'''[[:Category:Long range units|Long range]]''': Skully Archer · Lich<br />'''[[:Category:Summoned units|Summoned]]''': Little spidey · Mummy · Necromancer zombie · Goblin · Ghost · (Nether Ghost)<br /><br />'''Unknown''': (Cerberus) |}
The other 2 are similar. Now is the question why it doesn't work. I currently removed the full common.js and testing on the userstyle. My user style:
/********************************************************************************/ /********************************************************************************/ /************************************ PERSONAL **********************************/ /********************************************************************************/ /********************************************************************************/ /*******************************************************************************/ /* Script Import */ /********************************************************************************/ importScriptPage('User:Jens Ingels/ChatHacks.js', 'c'); /*******************************************************************************/ /* Image Popup */ /********************************************************************************/ /* kill image popups */ window.wgEnableImageLightboxExt = false;C:\Users\user> function changeimagelinks() { $('#WikiaArticle, .LatestPhotosModule, #article-comments').unbind('click.lightbox'); var a = document.getElementsByTagName('a'); for(var t = 0; t < a.length; ++t) { var a2 = a[t]; var img = a2.getElementsByTagName('img'); if(img[0] != null) { if (a2.href.indexOf('images.wikia.com') != -1) { var link = wgServer + '/wiki/File:' + a2.href.substring(a2.href.lastIndexOf('/') + 1); a2.setAttribute('href',link); } } } } addOnloadHook(changeimagelinks); /********************************************************************************/ /********************************************************************************/ /****************************** COMMON PROJECT **********************************/ /********************************************************************************/ /********************************************************************************/ /*******************************************************************************/ /* Script Import */ /********************************************************************************/ importScriptPage('MediaWiki:ShowHide.js'); importScriptPage('Countdown/code.js', 'dev'); importScriptPage('InactiveUsers/code.js', 'dev'); importScriptPage('MediaWiki:Clock'); importScriptPage('User:Jgjake2/js/DISPLAYTITLE.js', 'deadisland'); importScriptPage('EditIntroButton/code.js', 'dev'); importScriptPage('MediaWiki:BackToTopButton'); /*******************************************************************************/ /* TOGGLER EXTENSION */ /********************************************************************************/ importScriptPage('MediaWiki:Toggler_extension.js') /*******************************************************************************/ /* DYNAMICFUCTIONS EXTENSION */ /********************************************************************************/ /* http://www.mediawiki.org/wiki/Extension:DynamicFunctions */ <?php /* Defines a subset of parser functions that must clear the cache to be useful. {{#arg:name}} Returns the value of the given URL argument. Can also be called with a default value, which is returned if the given argument is undefined or blank: {{#arg:name|default}} {{#ip:}} Returns the current user IP. {{#rand:a|b}} Returns a random value between a and b, inclusive. Can also be called with a single value; {{#rand:6}} returns a random value between 1 and 6 (equivalent to a dice roll). {{#skin:}} Returns the name of the current skin. Author: Algorithm [http://meta.wikimedia.org/wiki/User:Algorithm] Version 1.0 (5/21/06) */ $wgExtensionFunctions[] = 'wfDynamicFunctions'; $wgExtensionCredits['parserhook'][] = array( 'name' => 'DynamicFunctions', 'version' => '1.0', 'url' => 'http://www.mediawiki.org/wiki/Extension:DynamicFunctions', 'author' => 'Ross McClure', 'description' => 'Defines an additional set of parser functions.' ); $wgHooks['LanguageGetMagic'][] = 'wfDynamicFunctionsLanguageGetMagic'; function wfDynamicFunctions() { global $wgParser, $wgExtDynamicFunctions; $wgExtDynamicFunctions = new ExtDynamicFunctions(); $wgParser->setFunctionHook( 'arg', array( &$wgExtDynamicFunctions, 'arg' ) ); $wgParser->setFunctionHook( 'ip', array( &$wgExtDynamicFunctions, 'ip' ) ); $wgParser->setFunctionHook( 'rand', array( &$wgExtDynamicFunctions, 'rand' ) ); $wgParser->setFunctionHook( 'skin', array( &$wgExtDynamicFunctions, 'skin' ) ); } function wfDynamicFunctionsLanguageGetMagic( &$magicWords, $langCode ) { switch ( $langCode ) { default: $magicWords['arg'] = array( 0, 'arg' ); $magicWords['ip'] = array( 0, 'ip' ); $magicWords['rand'] = array( 0, 'rand' ); $magicWords['skin'] = array( 0, 'skin' ); } return true; } class ExtDynamicFunctions { function arg( &$parser, $name = '', $default = '' ) { global $wgRequest; $parser->disableCache(); return $wgRequest->getVal($name, $default); } function ip( &$parser ) { $parser->disableCache(); return wfGetIP(); } function rand( &$parser, $a = 0, $b = 1 ) { $parser->disableCache(); return mt_rand( intval($a), intval($b) ); } function skin( &$parser ) { global $wgUser, $wgRequest; $parser->disableCache(); return $wgRequest->getVal('useskin', $wgUser->getOption('skin')); } } |
And here's the css:
/* Hide text only for you */ .myhide {display: none} #id {display: none} /* Tests */ /* HIGHLIGHTED USERNAMES LIST Admins: green, Chat mods: 009999 */ a[href="/wiki/User:Agantacroxi"], a[href="/wiki/Message_Wall:Agantacroxi"], a[href="/wiki/User_talk:Agantacroxi"] { color: green !important;} a[href="/wiki/User:Jens_Ingels"], a[href="/wiki/Message_Wall:Jens_Ingels"], a[href="/wiki/User_talk:Jens_Ingels"] { color: green !important;} a[href="/wiki/User:Brandonw38"], a[href="/wiki/Message_Wall:Brandonw38"], a[href="/wiki/User_talk:Brandonw38"] { color: green !important;} a[href="/wiki/User:Royironarm"], a[href="/wiki/Message_Wall:Royironarm"], a[href="/wiki/User_talk:Royironarm"] { color: #009999 !important;} a[href="http://www.livgames.com"] { color: darkgreen} |
And here is the wikia.css:
/*NO IMAGE ATTRIBUTION*/ .WikiaArticle .picture-attribution { display:none; } /* HIGHLIGHTED USERNAMES LIST Admins: green, Chat mods: orange */ a[href="/wiki/User:Agantacroxi"], a[href="/wiki/Message_Wall:Agantacroxi"], a[href="/wiki/User_talk:Agantacroxi"] { color: green !important;} a[href="/wiki/User:Jens_Ingels"], a[href="/wiki/Message_Wall:Jens_Ingels"], a[href="/wiki/User_talk:Jens_Ingels"] { color: green !important;} a[href="/wiki/User:Brandonw38"], a[href="/wiki/Message_Wall:Brandonw38"], a[href="/wiki/User_talk:Brandonw38"] { color: green !important;} a[href="/wiki/User:Royironarm"], a[href="/wiki/Message_Wall:Royironarm"], a[href="/wiki/User_talk:Royironarm"] { color: orange !important;} /*STYLE*/ /*LIVINGSTONE FONT FOR H1*/ @font-face{font-family: 'Livingstone'; src: url('http://www.ttfonts.net/sfonts/2/23643_livingst.ttf'); font-size:120%;} h1 { font-family: Livingstone, 'Lucida Sans Unicode', sans-serif; font-size:500%; font-weight:200; } body { font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif; } /*CLASSES (.)*/ div.announcement { background-color:orange; border:1px solid black; text-align:center; padding:1em; } .announcement hr { background:red; } .diff-addedline { background-color:green; color:white } figcaption.thumbcaption, img.thumbimage { background-color:honeydew; } /*IDS (#)*/ #toc { border:1px solid green; background-color:honeydew; } |
Other notes are the the toggler extension also is installed like you can see with the user style js here is the code:
/************* Funzioni di utilità generale *************/ /* Test if an element has a certain class ************************************** * * Description: Uses regular expressions and caching for better performance. * Maintainers: User:Mike Dillon, User:R. Koot, User:SG */ var hasClass = (function () { var reCache = {}; return function (element, className) { return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className); }; })(); function getElementsByClass (node, className, tagName) { if (node.getElementsByClassName && (tagName == undefined || tagName == null || tagName == '*')) return node.getElementsByClassName(className); var list = node.getElementsByTagName(tagName?tagName:'*'); var array = new Array(); var i = 0; for (i in list) { if (hasClass(list[i], className)) array.push(list[i]); } return array; } /* Creates the method getElementsByClass, if unsupported from the browser */ if(!document.getElementsByClass) document.getElementsByClass = function(className) { return getElementsByClass(document, className, '*'); }; function getElementsByName (name, root) { if (root == undefined) root = document; var e = root.getElementsByTagName('*'); var r = new Array(); for (var i = 0; i < e.length; i++) { if (e[i].getAttribute('name') == name) r[r.length] = e[i]; } return r; } /* Any JavaScript here will be loaded for all users on every page load. */ /** Toggles the display of elements on a page Author/contact: Austin Che http://openwetware.org/wiki/User:Austin_J._Che See http://openwetware.org/wiki/OpenWetWare:Toggle for examples and documentation */ // indexed array of toggler ids to array of associated toggle operations // each operation is a two element array, the first being the type, the second a class name or array of elements // operation types are strings like "_reset" or "" for the default toggle operation var togglers = new Array(); var allClasses = new Object(); // associative map of class names to page elements function toggler(id) { var toBeToggled = togglers[id]; if (!toBeToggled) return; // if some element is in list more than once, it will be toggled multiple times for (var i = 0; i < toBeToggled.length; i++) { // get array of elements to operate on var toggles = toBeToggled[i][1]; if (typeof(toggles) == "string") { if (toggles.charAt(0) == '-') { // treat as an element ID, not as class toggles = document.getElementById(toggles.substring(1)); if (toggles) toggles = new Array(toggles); } else toggles = allClasses[toggles]; } if (!toggles || !toggles.length) continue; var op = toBeToggled[i][0]; // what the operation will be switch (op) { case "_reset": for (var j in toggles) toggles[j].style.display = toggles[j]._toggle_original_display; break; case "_show": for (var j in toggles) toggles[j].style.display = ''; break; case "_hide": for (var j in toggles) toggles[j].style.display = 'none'; break; case "": default: // Toggle for (var j in toggles) toggles[j].style.display = ((toggles[j].style.display == 'none') ? '' : 'none'); break; } } } function createTogglerLink(toggler, id) { var toggle = document.createElement("a"); toggle.className = 'toggler-link'; toggle.setAttribute('id', 'toggler' + id); toggle.setAttribute('href', 'javascript:toggler("' + id + '");'); var child = toggler.firstChild; toggler.removeChild(child); toggle.appendChild(child); toggler.insertBefore(toggle, toggler.firstChild); } function toggleInit() { var togglerElems = new Array(); var toggleGroup = new Array(); // initialize/clear any old information togglers = new Array(); allClasses = new Object(); allClasses.watch = undefined; allClasses.unwatch = undefined; // make list of all document classes var elems = document.getElementsByTagName("*"); var numelems = elems.length; for (var i = 0; i < elems.length; i++) { var elem = elems[i]; if (!elem.className) continue; elem._toggle_original_display = elem.style.display; var togglerID = -1; var elemClasses = elem.className.split(' '); // get list of classes for (var j = 0; j < elemClasses.length; j++) { var elemClass = elemClasses[j]; if (! allClasses[elemClass]) allClasses[elemClass] = new Array(); allClasses[elemClass].push(elem); // all the special classes begin with _toggle if (elemClass.substring(0, 7) != "_toggle") continue; if (elemClass == "_togglegroup") toggleGroup = new Array(); else if (elemClass == "_toggle") toggleGroup.push(elem); else if (elemClass.substring(0, 12) == "_toggle_init") { // set initial value for display (ignore the original CSS set value) // understands _toggle_initshow and _toggle_inithide var disp = elemClass.substring(12); if (disp == "show") elem.style.display = ''; else if (disp == "hide") elem.style.display = 'none'; elem._toggle_original_display = disp; } else if (elemClass.substring(0, 8) == "_toggler") { if (togglerID == -1) { togglerID = togglers.length; togglers[togglerID] = new Array(); togglerElems[togglerID] = elem; } // all classes are of form _toggler_op-CLASS // figure out what class we're toggling // if none is specified, then we use the current toggle group var toBeToggled; var hyphen = elemClass.indexOf('-'); if (hyphen != -1) toBeToggled = elemClass.substring(hyphen+1); else { toBeToggled = toggleGroup; hyphen = elemClass.length; } var op = elemClass.substring(8, hyphen); togglers[togglerID].push(new Array(op, toBeToggled)); } } } // add javascript links to all toggler elements for (var i = 0; i < togglerElems.length; i++) createTogglerLink(togglerElems[i], i); } function owwsitesearch(f){ f.q.value='site:http://openwetware.org/wiki/'+ f.base.value+'++'+f.qfront.value } addOnloadHook(toggleInit); |
And last not least the showhide code. I only replace all names to + and - and removed the []
/*<syntaxhighlight lang="javascript">*/ /* * Copyright © 2009, Daniel Friesen * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the script nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY DANIEL FRIESEN ''AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL DANIEL FRIESEN BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ ( function( $ ) { // CONFIG var config = window.ShowHideConfig = $.extend( true, { autoCollapse: 2, userLang: true, brackets: '', linkBefore: false, // Bulgarian bg: { show: "+", hide: "-", showAll: "Покажи всички", hideAll: "Скрий всички" }, // German de: { show: "+", hide: "-", showAll: "alle anzeigen", hideAll: "alle verbergen" }, // English en: { show: "+", hide: "-", showAll: "show all", hideAll: "hide all" }, // Spanish es: { show: "+", hide: "-", showAll: "Mostrar todo", hideAll: "Ocultar todo" }, // French fr: { show: "+", hide: "-", showAll: "tout afficher", hideAll: "tout masquer" }, // Hungarian hu: { show: "+", hide: "-", showAll: "összes kibontása", hideAll: "összes elrejtése" }, // Italian it: { show: "+", hide: "-", showAll: "Mostra tutti", hideAll: "Nascondi tutti" }, // Japanese ja: { show: "+", hide: "-", showAll: "すべて表示", hideAll: "すべて非表示" }, // Korean ko: { show: "+", hide: "-", showAll: "모두 보이기", hideAll: "모두 숨기기" }, // Dutch nl: { show: "+", hide: "-", showAll: "alles tonen", hideAll: "alles verbergen" }, // Polish pl: { show: "+", hide: "-", showAll: "Pokaż wszystko", hideAll: "Ukryj wszystko" }, // Portuguese pt: { show: "+", hide: "-", showAll: "Expandir Todos", hideAll: "Esconder Todos" }, // Brazilian Portuguese 'pt-br': { show: "+", hide: "-", showAll: "Expandir Todos", hideAll: "Esconder Todos" }, // Russian ru: { show: "+", hide: "-", showAll: "Открыть все", hideAll: "Скрыть все" }, // Chinese zh: { show: "+", hide: "-", showAll: "全部显示", hideAll: "全部隐藏" } // Make a post on the talkpage if you have i18n updates }, window.ShowHideConfig || {} ); // i18n function function msg( name ) { if ( config.userLang && wgUserLanguage in config && name in config[wgUserLanguage] ) { return config[wgUserLanguage][name]; } if ( wgContentLanguage in config && name in config[wgContentLanguage] ) { return config[wgContentLanguage][name]; } return config.en[name]; } // common $.fn.onLink = function( fn ) { return this.bind( 'click keypress', function(e) { if ( e.type === 'click' || ( e.type === 'keypress' && ( e.keyCode === 13 || e.charCode === 32 ) ) ) { fn.call(this, e); } } ); }; /** Collapsible tables using jQuery * * Description: Allows tables to be collapsed, showing only the header. */ function collapseTable( node, state ) { var $table = $( node ), $button = $table.find( 'tr:first > th:last .collapseLink' ); if ( !$table.length || !$button.length ) { return false; } if ( typeof state === 'boolean' ) { $table.toggleClass( 'collapsed', !state ); } else { $table.toggleClass( 'collapsed' ); } var hidden = $table.hasClass( 'collapsed' ); $table.find( '> * > tr:not(:first):not(.nocollapse)' )[hidden?"hide":"show"](); $button.text( msg( hidden ? "show" : "hide" ) ); return true; } function createCollapseButtons() { var NavigationBoxes = []; $( 'table.collapsible' ).each( function () { NavigationBoxes.push(this); var $buttonLink = $( '<span tabIndex=0 class=collapseLink />' ).text( msg( "hide" ) ).css({ cursor: "pointer" }).onLink( function( e ) { collapseTable( $(this).closest('table') ); } ), $button = $( "<span class=collapseButton />" ).css( { "float": "right", textAlign: "right", fontWeight: "normal", width: "6em", marginLeft: "-100%" } ); $button.append( document.createTextNode(config.brackets.substr(0, config.brackets.length/2)), $buttonLink, config.brackets.substr(config.brackets.length/2) ); var $header = $( this ).find( 'tr:first > th:last' ).prepend($button); } ); // if more Navigation Bars found than Default: hide all if ( $( NavigationBoxes ).filter( '.autocollapse' ).length >= config.autoCollapse ) { $( NavigationBoxes ).filter( '.autocollapse' ).each( function () { collapseTable( this, false ); } ); } $( NavigationBoxes ).filter( '.collapsed' ).each( function () { collapseTable( this, false ); } ); } $( createCollapseButtons ); /** Dynamic Navigation Bars with jQuery * * Base Description: See Wikipedia:Wikipedia:NavFrame. */ // shows and hides content and picture (if available) of navigation bars function toggleNavigationBar( node ) { var $navFrame = $( node ), $navToggle = $navFrame.find( '.NavHead:first .collapseLink' ); if ( !$navFrame.length || !$navToggle.length ) { return false; } $navFrame.toggleClass( 'NavVisible' ); $navFrame.find( '.NavPic, .NavContent' ).not( $navFrame.find( '.NavFrame .NavPic' ) ).not( $navFrame.find( '.NavFrame .NavContent' ) ).slideToggle(); $navToggle.text( msg( $navFrame.hasClass( 'NavVisible' ) ? "hide" : "show" ) ); return true; } // adds show/hide-button to navigation bars function createNavigationBarToggleButton() { var NavFrames = $( '.NavFrame' ).addClass( 'NavVisible' ).each( function () { var $navHead = $( this ).find( '.NavHead:first' ), $buttonLink = $( '<span tabIndex=0 class=collapseLink />' ).text( msg( "hide" ) ).onLink( function ( e ) { toggleNavigationBar( $( this ).closest( '.NavFrame' ) ); } ), $button = $( '<span class="NavToggle collapseButton" />' ); $navHead.filter( 'legend' ).append( ' - ' ); if ( config.brackets ) { $button.append( document.createTextNode(config.brackets.substr(0, config.brackets.length/2)), $buttonLink, config.brackets.substr(config.brackets.length/2) ); } else { $button.append( $buttonLink ); } $navHead[config.linkBefore?"prepend":"append"]($button); } ); // if more Navigation Bars found than Default: hide all if ( NavFrames.length >= config.autoCollapse ) { NavFrames.not( '.noautocollapse' ).each( function () { toggleNavigationBar(this); } ); } else { NavFrames.filter( '.collapsed' ).each( function () { toggleNavigationBar(this); } ); } return true; } $( createNavigationBarToggleButton ); $( function () { $( '.NavGlobal' ).each( function () { $( '<span class=NavGlobalShow />' ).append( document.createTextNode( '[' ), $( '<span tabIndex=0 class=collapseLink />' ).text( msg( "showAll" ) ).onLink( function ( e ) { $( '.NavFrame' ).each( function () { if ( !$( this ).hasClass( 'NavVisible' ) ) toggleNavigationBar(this); } ); } ), ']' ).appendTo( this ); $( this ).append( ' ' ); $('<span class=NavGlobalHide />').append( document.createTextNode( '[' ), $( '<span tabIndex=0 class=collapseLink />' ).text( msg( "hideAll" ) ).onLink( function ( e ) { $( '.NavFrame' ).each( function () { if ( $( this ).hasClass( 'NavVisible' ) ) toggleNavigationBar(this); } ); } ), ']' ).appendTo( this ); } ); } ); } )( jQuery ); /*</syntaxhighlight>*/ |
Finaly the old commons you can find here and here. If you known an fix please tell me.--Jens Ingels (talk) 13:11, July 27, 2012 (UTC)
- I'm a little confused. What exactly isn't working? -- RandomTime 13:21, July 27, 2012 (UTC)
- Wel I don't really understand myself what happend. But if I use an #switch code like in the example the collapse function will not work anymore. So there is something wrong the the ParserFuction. The code doesn't understand what to do if there is an #switch inside the class:
class="navbox collapsible{{#switch:{{PAGENAME}}|Gremlin miner|Skully|Dead Knight|Zombie|Wolf|Imp|Gargoyle|Spidey|Medusa|Troll|Dragon|Vamp|Necromancer|Reap|Skully Archer|Lich|Little spidey|Mummy|Necromancer zombie|Goblin|Ghost|Nether Ghost|Cerberus=|#default= collapsed}}"
--Jens Ingels (talk) 14:36, July 27, 2012 (UTC)
Put a space before the #switch
. You are colliding the two classes together.
{| class="navbox collapsible<PUT A SPACE HERE>{{#switch:{{PAGENAME}}|Gremlin miner|Skully|Dead Knight|Zombie|Wolf|Imp|Gargoyle|Spidey|Medusa|Troll|Dragon|Vamp|Necromancer|Reap|Skully Archer|Lich|Little spidey|Mummy|Necromancer zombie|Goblin|Ghost|Nether Ghost|Cerberus=|#default= collapsed}}
The problem is that if your switch doesn't match anything then the #default
will be used resulting in: class="navbox collapsiblecollapsed"
(Notice how collapsible
and collapsed
are slammed together). The important thing to remember is that leading and trailing white-space is ignored by MediaWiki. The following 2 statements are identical:
{{ SomeTemplate | Param1 | someparameter = Param 2 }}
{{SomeTemplate|Param1|someparameter=Param 2}}
Only whitespace after the first non-white-space character is included in the result. Trailing white-space (after the last non-white-space character) is also thrown away. This feature is actually very useful since it lets you break your template and parser functions across multiple lines so you don't have to cram everything on one really really long line. This is very important for readability when you start doing complicated things like putting an #if
inside a parameter to a template inside a #switch
inside another #switch
.
BTW, you can see the problem using Web Inspector in either Firefox or Chrome (or Developer Tools in Internet Explorer, maybe). If you inspect the table generated by your navbox template, you can see the contents of the class
attribute on the table
tag which helps make these sorts of problems reasonably obvious. Lunarity 16:04, July 27, 2012 (UTC)
- This will not fix the problem sorry. The code has worked with the old navframe extension. So I think the problem is in the js or will require an css code to let it work. --Jens Ingels (talk) 18:27, July 27, 2012 (UTC)
If you say so, but did you try it? Your code:
Units
|
---|
Passive: Gremlin miner Melee: Skully · Dead Knight · Zombie · Wolf · Imp · Gargoyle · Spidey · Medusa · Troll · Dragon Mid range: Vamp · Necromancer · Reap Long range: Skully Archer · Lich Summoned: Little spidey · Mummy · Necromancer zombie · Goblin · Ghost · (Nether Ghost) Unknown: (Cerberus) |
My code:
Units
|
---|
Passive: Gremlin miner Melee: Skully · Dead Knight · Zombie · Wolf · Imp · Gargoyle · Spidey · Medusa · Troll · Dragon Mid range: Vamp · Necromancer · Reap Long range: Skully Archer · Lich Summoned: Little spidey · Mummy · Necromancer zombie · Goblin · Ghost · (Nether Ghost) Unknown: (Cerberus) |
Lunarity 04:53, July 28, 2012 (UTC)
- BTW, you said you removed the ShowHide code from the site's Common.js? I notice that you don't have an
importScriptPage('MediaWiki:ShowHide.js');
in your user js. If the code isn't included then it won't run and it won't work. Lunarity 12:56, July 28, 2012 (UTC)
Found the problem. It seems the DynamicFunction extension crash when the toggler extension is installed. The problem is not the showhide but the ParserFunctions (build-in wiki) that crash or give an error with tables, not sure. So what I think for now the problem is the dynamicfunction. I currently removed it from the wiki. --Jens Ingels (talk) 00:20, July 29, 2012 (UTC)