User:Vatsa1708/wikia.js

function showHide { // Configuration var config = window.ShowHideConfig = $.extend(true, {     autoCollapse: 1,      userLang: false,      brackets: '[]',      linkBefore: false,      // English      en: {         show: 'show',         hide: 'hide',         showAll: 'show all',         hideAll: 'hide all'      }   }, window.ShowHideConfig || {}); // Function for multi-language support 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);         }      }); };  function collapseTable(node, state) { var  $table = $(node), $button = $table.find('tr:first > th:first .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 = $(' ').text(msg('hide')).css({ 'cursor': 'pointer' }).onLink(function(e) { collapseTable($(this).closest('table')); }),            $button = $(' ').css({ 'float': 'right', 'text-align': 'right', 'font-weight': 'normal', 'width': '40px' });        $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:first').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); }); } else { $(NavigationBoxes).filter('.collapsed').each(function { collapseTable(this, false); }); }  }   $(createCollapseButtons); }