MediaWiki:Common.js: Porovnání verzí

Z AppleWikipedia
Přejít na: navigace, hledání
(Založena nová stránka s textem „/** * Keep code in MediaWiki:Common.js to a minimum as it is unconditionally * loaded for all users on every wiki page. If possible create a gadget that …“)
 
 
Řádka 1: Řádka 1:
/**
+
/*<source lang="javascript">*/
* Keep code in MediaWiki:Common.js to a minimum as it is unconditionally
+
* loaded for all users on every wiki page. If possible create a gadget that is
+
* enabled by default instead of adding it here (since gadgets are fully
+
* optimized ResourceLoader modules with possibility to add dependencies etc.)
+
*
+
* Since Common.js isn't a gadget, there is no place to declare its
+
* dependencies, so we have to lazy load them with mw.loader.using on demand and
+
* then execute the rest in the callback. In most cases these dependencies will
+
* be loaded (or loading) already and the callback will not be delayed. In case a
+
* dependency hasn't arrived yet it'll make sure those are loaded before this.
+
*/
+
 
   
 
   
/* global mw, $, importStylesheet, importScript */
+
/* hvězdičky pro featured+good articles v jiných jazycích */
/* jshint strict:false, browser:true */
+
function LinkFA()  
+
{
mw.loader.using( ['mediawiki.util', 'mediawiki.notify', 'jquery.client'], function () {
+
     var langbox = document.getElementById("p-lang");
/* Begin of mw.loader.using callback */
+
     if (!langbox) return;
+
    var interwiki = langbox.getElementsByTagName("li");
/**
+
    // iterace přes všechny mezijazykové odkazy
* Main Page layout fixes
+
    for (var i = 0; i < interwiki.length; ++i)
*
+
     {
* Description: Adds an additional link to the complete list of languages available.
+
        var link = interwiki[i];
* Maintainers: [[User:AzaToth]], [[User:R. Koot]], [[User:Alex Smotrov]]
+
        var languageMatch = /\binterwiki-([a-z-]+)\b/.exec(link.className);
*/
+
        if (!languageMatch) continue;
if ( mw.config.get( 'wgPageName' ) === 'Main_Page' || mw.config.get( 'wgPageName' ) === 'Talk:Main_Page' ) {
+
         var language = languageMatch[1];
     $( function () {
+
        // zkusit najít odpovídající FA nebo GA element
        mw.util.addPortletLink( 'p-lang', '//meta.wikimedia.org/wiki/List_of_Wikipedias',
+
        var falink = document.getElementById("fa-link-" + language) && link.className.indexOf("badge-featuredarticle") === -1;
            'Complete list', 'interwiki-completelist', 'Complete list of Wikipedias' );
+
         if (falink)
     } );
+
        {
}
+
             link.className += " featured";
+
            link.title = "Tento článek patří mezi nejlepší";
/**
+
         } else {
* Redirect User:Name/skin.js and skin.css to the current skin's pages
+
            var galink = document.getElementById("ga-link-" + language) && link.className.indexOf("badge-goodarticle") === -1;
* (unless the 'skin' page really exists)
+
            if (galink)
* @source: http://www.mediawiki.org/wiki/Snippets/Redirect_skin.js
+
             {
* @rev: 2
+
                link.className += " good";
*/
+
                link.title = "Tento článek patří mezi dobré";
if ( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgNamespaceNumber' ) === 2 ) {
+
            }
     var titleParts = mw.config.get( 'wgPageName' ).split( '/' );
+
    /* Make sure there was a part before and after the slash
+
      and that the latter is 'skin.js' or 'skin.css' */
+
    if ( titleParts.length == 2 ) {
+
         var userSkinPage = titleParts.shift() + '/' + mw.config.get( 'skin' );
+
         if ( titleParts.slice( -1 ) == 'skin.js' ) {
+
             window.location.href = mw.util.getUrl( userSkinPage + '.js' );
+
         } else if ( titleParts.slice( -1 ) == 'skin.css' ) {
+
             window.location.href = mw.util.getUrl( userSkinPage + '.css' );
+
 
         }
 
         }
 
     }
 
     }
 
}
 
}
+
 
/**
+
/*******************************\
* Map addPortletLink to mw.util
+
|*     Podpora pro navboxy     *|
* @deprecated: Use mw.util.addPortletLink instead.
+
\*******************************/
*/
+
 
mw.log.deprecate( window, 'addPortletLink', mw.util.addPortletLink, 'Use mw.util.addPortletLink instead' );
+
/* Pro další informace vizte [[:en:Help:Collapsing]]. */
+
 
/**
+
* Extract a URL parameter from the current URL
+
* @deprecated: Use mw.util.getParamValue with proper escaping
+
*/
+
mw.log.deprecate( window, 'getURLParamValue', mw.util.getParamValue, 'Use mw.util.getParamValue instead' );
+
+
/**
+
* Test if an element has a certain class
+
* @deprecated:  Use $(element).hasClass() instead.
+
*/
+
mw.log.deprecate( window, 'hasClass', function ( element, className ) {
+
    return $( element ).hasClass( className );
+
}, 'Use jQuery.hasClass() instead' );
+
+
/**
+
* @source www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL
+
* @rev 6
+
*/
+
var extraCSS = mw.util.getParamValue( 'withCSS' ),
+
    extraJS = mw.util.getParamValue( 'withJS' );
+
+
if ( extraCSS ) {
+
    if ( extraCSS.match( /^MediaWiki:[^&<>=%#]*\.css$/ ) ) {
+
        importStylesheet( extraCSS );
+
    } else {
+
        mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withCSS value' } );
+
    }
+
}
+
+
if ( extraJS ) {
+
    if ( extraJS.match( /^MediaWiki:[^&<>=%#]*\.js$/ ) ) {
+
        importScript( extraJS );
+
    } else {
+
        mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withJS value' } );
+
    }
+
}
+
+
/**
+
* Import more specific scripts if necessary
+
*/
+
if ( mw.config.get( 'wgAction' ) === 'edit' || mw.config.get( 'wgAction' ) === 'submit' || mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Upload' ) {
+
    /* scripts specific to editing pages */
+
    importScript( 'MediaWiki:Common.js/edit.js' );
+
} else if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Watchlist' ) {
+
    /* watchlist scripts */
+
     importScript( 'MediaWiki:Common.js/watchlist.js' );
+
}
+
if ( mw.config.get( 'wgNamespaceNumber' ) === 6 ) {
+
     /* file description page scripts */
+
    importScript( 'MediaWiki:Common.js/file.js' );
+
}
+
+
/**
+
* Helper script for .hlist class in Common.css
+
* Add pseudo-selector class to last-child list items in IE8
+
* @source mediawiki.org/wiki/Snippets/Horizontal_lists
+
* @revision 6 (2014-08-23)
+
* @author [[User:Edokter]]
+
*/
+
( function ( mw, $ ) {
+
    var profile = $.client.profile();
+
    if ( profile.name === 'msie' && profile.versionNumber === 8 ) {
+
        mw.hook( 'wikipage.content' ).add( function ( $content ) {
+
            $content.find( '.hlist' ).find( 'dd:last-child, dt:last-child, li:last-child' )
+
                .addClass( 'hlist-last-child' );
+
        } );
+
    }
+
}( mediaWiki, jQuery ) );
+
+
/**
+
* Fix for Windows XP Unicode font rendering
+
*/
+
if ( navigator.appVersion.search(/windows nt 5/i) !== -1 ) {
+
    mw.util.addCSS( '.IPA { font-family: "Lucida Sans Unicode", "Arial Unicode MS"; } ' +
+
                '.Unicode { font-family: "Arial Unicode MS", "Lucida Sans Unicode"; } ' );
+
}
+
+
/**
+
* WikiMiniAtlas
+
*
+
* Description: WikiMiniAtlas is a popup click and drag world map.
+
*             This script causes all of our coordinate links to display the WikiMiniAtlas popup button.
+
*             The script itself is located on meta because it is used by many projects.
+
*             See [[Meta:WikiMiniAtlas]] for more information.
+
* Maintainers: [[User:Dschwen]]
+
*/
+
( function () {
+
    var require_wikiminiatlas = false;
+
    var coord_filter = /geohack/;
+
    $( function () {
+
        $( 'a.external.text' ).each( function( key, link ) {
+
            if ( link.href && coord_filter.exec( link.href ) ) {
+
                require_wikiminiatlas = true;
+
                // break from loop
+
                return false;
+
            }
+
        } );
+
        if ( $( 'div.kmldata' ).length ) {
+
            require_wikiminiatlas = true;
+
        }
+
        if ( require_wikiminiatlas ) {
+
            mw.loader.load( '//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript' );
+
        }
+
    } );
+
} )();
+
+
/**
+
* Collapsible tables
+
*
+
* Allows tables to be collapsed, showing only the header. See [[Wikipedia:NavFrame]].
+
*
+
* @version 2.0.3 (2014-03-14)
+
* @source https://www.mediawiki.org/wiki/MediaWiki:Gadget-collapsibleTables.js
+
* @author [[User:R. Koot]]
+
* @author [[User:Krinkle]]
+
* @deprecated Since MediaWiki 1.20: Use class="mw-collapsible" instead which
+
* is supported in MediaWiki core.
+
*/
+
+
 
var autoCollapse = 2;
 
var autoCollapse = 2;
var collapseCaption = 'hide';
+
var collapseCaption = "skrýt";
var expandCaption = 'show';
+
var expandCaption = "zobrazit";
 
   
 
   
function collapseTable( tableIndex ) {
+
function collapseTable( tableIndex )
     var Button = document.getElementById( 'collapseButton' + tableIndex );
+
{
     var Table = document.getElementById( 'collapsibleTable' + tableIndex );
+
     var Button = document.getElementById( "collapseButton" + tableIndex );
 +
     var Table = document.getElementById( "collapsibleTable" + tableIndex );
 
   
 
   
 
     if ( !Table || !Button ) {
 
     if ( !Table || !Button ) {
Řádka 189: Řádka 51:
 
   
 
   
 
     var Rows = Table.rows;
 
     var Rows = Table.rows;
    var i;
 
 
   
 
   
     if ( Button.firstChild.data === collapseCaption ) {
+
     if ( Button.firstChild.data == collapseCaption ) {
         for ( i = 1; i < Rows.length; i++ ) {
+
         for ( var i = 1; i < Rows.length; i++ ) {
             Rows[i].style.display = 'none';
+
             Rows[i].style.display = "none";
 
         }
 
         }
 
         Button.firstChild.data = expandCaption;
 
         Button.firstChild.data = expandCaption;
 
     } else {
 
     } else {
         for ( i = 1; i < Rows.length; i++ ) {
+
         for ( var i = 1; i < Rows.length; i++ ) {
 
             Rows[i].style.display = Rows[0].style.display;
 
             Rows[i].style.display = Rows[0].style.display;
 
         }
 
         }
Řádka 204: Řádka 65:
 
}
 
}
 
   
 
   
function createClickHandler( tableIndex ) {
+
function createCollapseButtons()
    return function ( e ) {
+
{
        e.preventDefault();
+
        collapseTable( tableIndex );
+
    };
+
}
+
+
function createCollapseButtons() {
+
 
     var tableIndex = 0;
 
     var tableIndex = 0;
     var NavigationBoxes = {};
+
     var NavigationBoxes = new Object();
     var Tables = document.getElementsByTagName( 'table' );
+
     var Tables = document.getElementsByTagName( "table" );
    var i;
+
 
   
 
   
     for ( i = 0; i < Tables.length; i++ ) {
+
     for ( var i = 0; i < Tables.length; i++ ) {
         if ( $( Tables[i] ).hasClass( 'collapsible' ) ) {
+
         if ( hasClass( Tables[i], "collapsible" ) ) {
 
   
 
   
 
             /* only add button and increment count if there is a header row to work with */
 
             /* only add button and increment count if there is a header row to work with */
             var HeaderRow = Tables[i].getElementsByTagName( 'tr' )[0];
+
             var HeaderRow = Tables[i].getElementsByTagName( "tr" )[0];
             if ( !HeaderRow ) {
+
             if (!HeaderRow) continue;
                continue;
+
             var Header = HeaderRow.getElementsByTagName( "th" )[0];
            }
+
             if (!Header) continue;
             var Header = HeaderRow.getElementsByTagName( 'th' )[0];
+
             if ( !Header ) {
+
                continue;
+
            }
+
 
   
 
   
 
             NavigationBoxes[ tableIndex ] = Tables[i];
 
             NavigationBoxes[ tableIndex ] = Tables[i];
             Tables[i].setAttribute( 'id', 'collapsibleTable' + tableIndex );
+
             Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex );
 
   
 
   
             var Button    = document.createElement( 'span' );
+
             var Button    = document.createElement( "span" );
             var ButtonLink = document.createElement( 'a' );
+
             var ButtonLink = document.createElement( "a" );
 
             var ButtonText = document.createTextNode( collapseCaption );
 
             var ButtonText = document.createTextNode( collapseCaption );
             // Styles are declared in [[MediaWiki:Common.css]]
+
            Button.className = 'collapseButton';
+
             Button.className = "collapseButton";  //Styles are declared in Common.css
 
   
 
   
 
             ButtonLink.style.color = Header.style.color;
 
             ButtonLink.style.color = Header.style.color;
             ButtonLink.setAttribute( 'id', 'collapseButton' + tableIndex );
+
             ButtonLink.setAttribute( "id", "collapseButton" + tableIndex );
             ButtonLink.setAttribute( 'href', '#' );
+
             ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" );
            $( ButtonLink ).on( 'click', createClickHandler( tableIndex ) );
+
 
             ButtonLink.appendChild( ButtonText );
 
             ButtonLink.appendChild( ButtonText );
 
   
 
   
             Button.appendChild( document.createTextNode( '[' ) );
+
             Button.appendChild( document.createTextNode( "[" ) );
 
             Button.appendChild( ButtonLink );
 
             Button.appendChild( ButtonLink );
             Button.appendChild( document.createTextNode( ']' ) );
+
             Button.appendChild( document.createTextNode( "]" ) );
 
   
 
   
             Header.insertBefore( Button, Header.firstChild );
+
             Header.insertBefore( Button, Header.childNodes[0] );
 
             tableIndex++;
 
             tableIndex++;
 
         }
 
         }
 
     }
 
     }
 
   
 
   
     for ( i = 0;  i < tableIndex; i++ ) {
+
     for ( var i = 0;  i < tableIndex; i++ ) {
         if ( $( NavigationBoxes[i] ).hasClass( 'collapsed' ) ||
+
         if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) {
            ( tableIndex >= autoCollapse && $( NavigationBoxes[i] ).hasClass( 'autocollapse' ) )
+
        ) {
+
 
             collapseTable( i );
 
             collapseTable( i );
         }
+
         }  
         else if ( $( NavigationBoxes[i] ).hasClass ( 'innercollapse' ) ) {
+
         else if ( hasClass( NavigationBoxes[i], "innercollapse" ) ) {
 
             var element = NavigationBoxes[i];
 
             var element = NavigationBoxes[i];
             while ((element = element.parentNode)) {
+
             while (element = element.parentNode) {
                 if ( $( element ).hasClass( 'outercollapse' ) ) {
+
                 if ( hasClass( element, "outercollapse" ) ) {
 
                     collapseTable ( i );
 
                     collapseTable ( i );
 
                     break;
 
                     break;
Řádka 270: Řádka 117:
 
         }
 
         }
 
     }
 
     }
}
+
}  
 
   
 
   
mw.hook( 'wikipage.content' ).add( createCollapseButtons );
+
 
+
/* Test if an element has a certain class *
/**
+
* Dynamic Navigation Bars (experimental)
+
 
  *
 
  *
  * Description: See [[Wikipedia:NavFrame]].
+
  * Převzato z [[:en:MediaWiki:Common.js]]
* Maintainers: UNMAINTAINED
+
 
  */
 
  */
 
   
 
   
/* set up the words in your language */
+
var hasClass = (function () {
var NavigationBarHide = '[' + collapseCaption + ']';
+
    var reCache = {};
var NavigationBarShow = '[' + expandCaption + ']';
+
    return function (element, className) {
+
        return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);
/**
+
    };
* Shows and hides content and picture (if available) of navigation bars
+
})();
* Parameters:
+
 
  *     indexNavigationBar: the index of navigation bar to be toggled
+
 
**/
+
/**********************\
window.toggleNavigationBar = function ( indexNavigationBar, event ) {
+
|* Změna názvu článku *|
    var NavToggle = document.getElementById( 'NavToggle' + indexNavigationBar );
+
|* vytvořil Danny B. *|
    var NavFrame = document.getElementById( 'NavFrame' + indexNavigationBar );
+
\**********************/
    var NavChild;
+
function SpravnyNazev ()
+
  {
    if ( !NavFrame || !NavToggle ) {
+
  if (mw.config.get('wgNamespaceNumber') === 0) return;
        return false;
+
 
     }
+
  var nodSpravnyNazev = document.getElementById ("Sablona__Nazev_Spravny-nazev");
+
 
     /* if shown now */
+
  if (nodSpravnyNazev)
     if ( NavToggle.firstChild.data === NavigationBarHide ) {
+
     {
        for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
+
     var nodSablonaNazev = document.getElementById ("Sablona__Nazev");
            if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
+
     var nodNadpis = document.getElementsByTagName ("h1") [0];
                NavChild.style.display = 'none';
+
    var anodNadpisObsah = nodNadpis.getElementsByTagName("span");
            }
+
    var nodPuvodniNazev = null;
 +
    for (var i = 0; i < anodNadpisObsah.length; ++i)
 +
      {
 +
      var n = anodNadpisObsah[i];
 +
      if (n.className != "editsection")
 +
        {
 +
        nodPuvodniNazev = n;
 +
        break;
 
         }
 
         }
    NavToggle.firstChild.data = NavigationBarShow;
+
      }
+
     if (nodPuvodniNazev == null) return;
     /* if hidden now */
+
    nodNadpis.replaceChild (nodSpravnyNazev, nodPuvodniNazev);
    } else if ( NavToggle.firstChild.data === NavigationBarShow ) {
+
    nodSablonaNazev.parentNode.removeChild (nodSablonaNazev);
        for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
+
            if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
+
                NavChild.style.display = 'block';
+
            }
+
        }
+
        NavToggle.firstChild.data = NavigationBarHide;
+
 
     }
 
     }
 +
  }
 +
 +
 +
/****************************************************************************\
 +
|* Přidá položku "Vypsat pahýly" do seznamu nástrojů na stránkách kategorií *|
 +
|* vytvořil Danny B.                                                        *|
 +
\****************************************************************************/
 +
function addToolListStubs() {
 +
 
 +
  var nodDivTb = document.getElementById( "p-tb" );
 +
 
 +
  if( !nodDivTb || wgNamespaceNumber != 14 && wgNamespaceNumber != 15 ) return;
 +
 
 +
  var nodAListStubs = document.createElement( "a" );
 +
  nodAListStubs.href = "http://toolserver.org/~danny_b/powersearch/pahyly-v-kategorii.php?kategorie=" + encodeURIComponent( wgTitle );
 +
  nodAListStubs.title = "Zobrazit seznam všech pahýlů v této kategorii";
 +
  nodAListStubs.appendChild( document.createTextNode( "Vypsat pahýly" ) );
 +
 
 +
  var nodLiListStubs = document.createElement( "li" );
 +
  nodLiListStubs.id = "t-liststubs";
 +
  nodLiListStubs.appendChild( nodAListStubs );
 +
 
 +
  var nodUlTb = nodDivTb.getElementsByTagName( "ul" )[0];
 +
  nodUlTb.appendChild( nodLiListStubs );
 +
 
 +
}
 +
 +
 +
/*****************\
 +
|*  csWikipedia  *|
 +
|* customization *|
 +
\*****************/
 
   
 
   
    event.preventDefault();
+
function CustomizeCsWikipedia ()
};
+
  {
 +
  LinkFA();
 +
  SpravnyNazev();
 +
  addToolListStubs();
 +
  createCollapseButtons ();
 +
  }
 
   
 
   
/* adds show/hide-button to navigation bars */
+
if (window.addEventListener)
function createNavigationBarToggleButton() {
+
  {
    var indexNavigationBar = 0;
+
  window.addEventListener ("load", CustomizeCsWikipedia, false)
    var NavFrame;
+
  }
    var NavChild;
+
else if (window.attachEvent)
    /* iterate over all < div >-elements */
+
  {
    var divs = document.getElementsByTagName( 'div' );
+
  window.attachEvent ("onload", CustomizeCsWikipedia)
    for ( var i = 0; (NavFrame = divs[i]); i++ ) {
+
  };
        /* if found a navigation bar */
+
        if ( $( NavFrame ).hasClass( 'NavFrame' ) ) {
+
 
   
 
   
            indexNavigationBar++;
+
/*</source>*/
            var NavToggle = document.createElement( 'a' );
+
 
            NavToggle.className = 'NavToggle';
+
/*************************\
            NavToggle.setAttribute( 'id', 'NavToggle' + indexNavigationBar );
+
|* české řazení dle ÚJČ AV ČR (prirucka.ujc.cas.cz/?id=900) *|
            NavToggle.setAttribute( 'href', '#' );
+
|* vytvořil Littledogboy                                    *|
            $( NavToggle ).on( 'click', $.proxy( window.toggleNavigationBar, window, indexNavigationBar ) );
+
\*************************/
 +
mw.config.set( 'tableSorterCollation', {'á':'a','č':'cÑÑ','ď':'d','é':'e','ě':'e','í':'i','ň':'n','ó':'o','ř':'rÑÑ','š':'sÑÑ','ť':'t','ú':'u','ů':'u','ý':'y','ž':'zÑÑ','Á':'A','Č':'CÑÑ','Ď':'D','É':'E','Ě':'E','Í':'I','Ň':'N','Ó':'O','Ř':'RÑÑ','Š':'SÑÑ','Ť':'T','Ú':'U','Ů':'U','Ý':'Y','Ž':'ZÑÑ'} );
 +
 
 +
/************************************************************************************************************\
 +
|* Panel referencí - RefToolbar                                                                            *|
 +
|*  Informace na [[Wikipedie:Panel referencí]], chyby hlašte na [[Diskuse k Wikipedii:Panel referencí]]    *|
 +
|*  Nechcete-li nástroj používat, můžete jej odstranit ze svého editačního rozhraní následujícím kódem:    *|
 +
|*    refToolbarInstalled = 'bypass';                                                                      *|
 +
|*  ...který vložíte na [[Special:Mypage/vector.js]] (případně monobook.js)                                 *|
 +
|*  Autor původní anglické verze: [[:en:User:Mr.Z-man]]                                                      *|
 +
|*  Na cs.wiki přenesl a nástroj udržuje [[Wikipedista:Michal Bělka]]                                      *|
 +
|*  Na zprovoznení české verze se podíleli [[Wikipedista:Reaperman]] a [[Wikipedista:Vojtech.dostal]]      *|
 +
\************************************************************************************************************/
 
   
 
   
            var isCollapsed = $( NavFrame ).hasClass( 'collapsed' );
+
function initializeRefTools() {
            /**
+
    if ( window.refToolbarInstalled === undefined ) {
            * Check if any children are already hidden.  This loop is here for backwards compatibility:
+
        importScriptURI('//en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-refToolbarBase.js&action=raw&ctype=text/javascript');
            * 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 ( NavChild = NavFrame.firstChild; NavChild != null && !isCollapsed; NavChild = NavChild.nextSibling ) {
+
                if ( $( NavChild ).hasClass( 'NavPic' ) || $( NavChild ).hasClass( 'NavContent' ) ) {
+
                    if ( NavChild.style.display === 'none' ) {
+
                        isCollapsed = true;
+
                    }
+
                }
+
            }
+
            if ( isCollapsed ) {
+
                for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
+
                    if ( $( NavChild ).hasClass( 'NavPic' ) || $( NavChild ).hasClass( 'NavContent' ) ) {
+
                        NavChild.style.display = 'none';
+
                    }
+
                }
+
            }
+
            var NavToggleText = document.createTextNode( isCollapsed ? NavigationBarShow : NavigationBarHide );
+
            NavToggle.appendChild( NavToggleText );
+
 
   
 
   
            /* Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked) */
+
        if( mw.user.options.get('usebetatoolbar') && mw.user.options.get('usebetatoolbar-cgd') ) {
             for( var j = 0; j < NavFrame.childNodes.length; j++ ) {
+
            // Enhanced editing toolbar is on with dialogs. Load standard refToolbar.
                 if ( $( NavFrame.childNodes[j] ).hasClass( 'NavHead' ) ) {
+
             mw.loader.using( 'ext.wikiEditor.toolbar', function () {
                    NavToggle.style.color = NavFrame.childNodes[j].style.color;
+
                 importScript('MediaWiki:RefToolbar.js');
                    NavFrame.childNodes[j].appendChild( NavToggle );
+
            });
                }
+
        } else if( mw.user.options.get('usebetatoolbar') ) { if (navigator.appName != "Microsoft Internet Explorer") {
            }
+
            // Dialogs are off. Load refToolbar 2.0 without dialogs.
             NavFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar );
+
            mw.loader.using( 'ext.wikiEditor.toolbar', function () {
         }
+
            importScript('MediaWiki:RefToolbarNoDialogs.js');
 +
            });
 +
        }} else { if (navigator.appName != "Microsoft Internet Explorer") {
 +
             // Enhanced editing toolbar is off. Load legacy refToolbar 1.0.
 +
            importScript('MediaWiki:RefToolbarLegacy.js');
 +
         }}
 +
        window.refToolbarInstalled = true;
 
     }
 
     }
 
}
 
}
 
   
 
   
mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton );
+
$( initializeRefTools );
+
 
/**
+
// Results from Wikidata
* Uploadwizard_newusers
+
// [[File:Wdsearch_script_screenshot.png]]
* Switches in a message for non-autoconfirmed users at [[Wikipedia:Upload]]
+
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Search' ||  ( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgCanonicalSpecialPageName' ) === false ) ) {
*
+
importScriptURI("//en.wikipedia.org/w/index.php?title=MediaWiki:Wdsearch.js&action=raw&ctype=text/javascript");
* Maintainers: [[User:Krimpet]]
+
}
*/
+
 
function uploadwizard_newusers() {
+
// vyvolání stylu klikatelných tlačítek
    if ( mw.config.get( 'wgNamespaceNumber' ) === 4 && mw.config.get( 'wgTitle' ) === 'Upload' && mw.config.get( 'wgAction' ) === 'view' ) {
+
mw.hook( 'wikipage.content' ).add( function() {
        var oldDiv = document.getElementById( 'autoconfirmedusers' ),
+
    if ( ( mw.loader.getState( 'mediawiki.ui.button' ) === 'registered' ) && (  $( '.mw-ui-button' ).length ) ) {
            newDiv = document.getElementById( 'newusers' );
+
        mw.loader.load('mediawiki.ui.button');
        if ( oldDiv && newDiv ) {
+
            var userGroups = mw.config.get( 'wgUserGroups' );
+
            if ( userGroups ) {
+
                for ( var i = 0; i < userGroups.length; i++ ) {
+
                    if ( userGroups[i] === 'autoconfirmed' ) {
+
                        oldDiv.style.display = 'block';
+
                        newDiv.style.display = 'none';
+
                        return;
+
                    }
+
                }
+
            }
+
            oldDiv.style.display = 'none';
+
            newDiv.style.display = 'block';
+
            return;
+
        }
+
 
     }
 
     }
}
 
 
$(uploadwizard_newusers);
 
 
/**
 
* Magic editintros ****************************************************
 
*
 
* Description: Adds editintros on disambiguation pages and BLP pages.
 
* Maintainers: [[User:RockMFR]]
 
*/
 
function addEditIntro( name ) {
 
    $( '.mw-editsection, #ca-edit' ).find( 'a' ).each( function ( i, el ) {
 
        el.href = $( this ).attr( 'href' ) + '&editintro=' + name;
 
    } );
 
}
 
 
if ( mw.config.get( 'wgNamespaceNumber' ) === 0 ) {
 
    $( function () {
 
        if ( document.getElementById( 'disambigbox' ) ) {
 
            addEditIntro( 'Template:Disambig_editintro' );
 
        }
 
    } );
 
 
    $( function () {
 
        var cats = mw.config.get('wgCategories');
 
        if ( !cats ) {
 
            return;
 
        }
 
        if ( $.inArray( 'Living people', cats ) !== -1 || $.inArray( 'Possibly living people', cats ) !== -1 ) {
 
            addEditIntro( 'Template:BLP_editintro' );
 
        }
 
    } );
 
}
 
 
/* End of mw.loader.using callback */
 
 
} );
 
} );
/* DO NOT ADD CODE BELOW THIS LINE */
 

Aktuální verze z 25. 1. 2015, 23:55

/*<source lang="javascript">*/
 
/* hvězdičky pro featured+good articles v jiných jazycích */
function LinkFA() 
{
    var langbox = document.getElementById("p-lang");
    if (!langbox) return;
    var interwiki = langbox.getElementsByTagName("li");
    // iterace přes všechny mezijazykové odkazy
    for (var i = 0; i < interwiki.length; ++i)
    {
        var link = interwiki[i];
        var languageMatch = /\binterwiki-([a-z-]+)\b/.exec(link.className);
        if (!languageMatch) continue;
        var language = languageMatch[1];
        // zkusit najít odpovídající FA nebo GA element
        var falink = document.getElementById("fa-link-" + language) && link.className.indexOf("badge-featuredarticle") === -1;
        if (falink)
        {
            link.className += " featured";
            link.title = "Tento článek patří mezi nejlepší";
        } else {
            var galink = document.getElementById("ga-link-" + language) && link.className.indexOf("badge-goodarticle") === -1;
            if (galink)
            {
                link.className += " good";
                link.title = "Tento článek patří mezi dobré";
            }
        }
    }
}
 
/*******************************\
|*     Podpora pro navboxy     *|
\*******************************/
 
/* Pro další informace vizte [[:en:Help:Collapsing]]. */
 
var autoCollapse = 2;
var collapseCaption = "skrýt";
var expandCaption = "zobrazit";
 
function collapseTable( tableIndex )
{
    var Button = document.getElementById( "collapseButton" + tableIndex );
    var Table = document.getElementById( "collapsibleTable" + tableIndex );
 
    if ( !Table || !Button ) {
        return false;
    }
 
    var Rows = Table.rows;
 
    if ( Button.firstChild.data == collapseCaption ) {
        for ( var i = 1; i < Rows.length; i++ ) {
            Rows[i].style.display = "none";
        }
        Button.firstChild.data = expandCaption;
    } else {
        for ( var i = 1; i < Rows.length; i++ ) {
            Rows[i].style.display = Rows[0].style.display;
        }
        Button.firstChild.data = collapseCaption;
    }
}
 
function createCollapseButtons()
{
    var tableIndex = 0;
    var NavigationBoxes = new Object();
    var Tables = document.getElementsByTagName( "table" );
 
    for ( var i = 0; i < Tables.length; i++ ) {
        if ( hasClass( Tables[i], "collapsible" ) ) {
 
            /* only add button and increment count if there is a header row to work with */
            var HeaderRow = Tables[i].getElementsByTagName( "tr" )[0];
            if (!HeaderRow) continue;
            var Header = HeaderRow.getElementsByTagName( "th" )[0];
            if (!Header) continue;
 
            NavigationBoxes[ tableIndex ] = Tables[i];
            Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex );
 
            var Button     = document.createElement( "span" );
            var ButtonLink = document.createElement( "a" );
            var ButtonText = document.createTextNode( collapseCaption );
 
            Button.className = "collapseButton";  //Styles are declared in Common.css
 
            ButtonLink.style.color = Header.style.color;
            ButtonLink.setAttribute( "id", "collapseButton" + tableIndex );
            ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" );
            ButtonLink.appendChild( ButtonText );
 
            Button.appendChild( document.createTextNode( "[" ) );
            Button.appendChild( ButtonLink );
            Button.appendChild( document.createTextNode( "]" ) );
 
            Header.insertBefore( Button, Header.childNodes[0] );
            tableIndex++;
        }
    }
 
    for ( var i = 0;  i < tableIndex; i++ ) {
        if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) {
            collapseTable( i );
        } 
        else if ( hasClass( NavigationBoxes[i], "innercollapse" ) ) {
            var element = NavigationBoxes[i];
            while (element = element.parentNode) {
                if ( hasClass( element, "outercollapse" ) ) {
                    collapseTable ( i );
                    break;
                }
            }
        }
    }
} 
 
 
/* Test if an element has a certain class *
 *
 * Převzato z [[:en:MediaWiki:Common.js]]
 */
 
var hasClass = (function () {
    var reCache = {};
    return function (element, className) {
        return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);
    };
})();
 
 
/**********************\
|* Změna názvu článku *|
|* vytvořil Danny B.  *|
\**********************/
function SpravnyNazev ()
  {
  if (mw.config.get('wgNamespaceNumber') === 0) return;
 
  var nodSpravnyNazev = document.getElementById ("Sablona__Nazev_Spravny-nazev");
 
  if (nodSpravnyNazev)
    {
    var nodSablonaNazev = document.getElementById ("Sablona__Nazev");
    var nodNadpis = document.getElementsByTagName ("h1") [0];
    var anodNadpisObsah = nodNadpis.getElementsByTagName("span");
    var nodPuvodniNazev = null;
    for (var i = 0; i < anodNadpisObsah.length; ++i)
      {
      var n = anodNadpisObsah[i];
      if (n.className != "editsection")
        {
        nodPuvodniNazev = n;
        break;
        }
      }
    if (nodPuvodniNazev == null) return;
    nodNadpis.replaceChild (nodSpravnyNazev, nodPuvodniNazev);
    nodSablonaNazev.parentNode.removeChild (nodSablonaNazev);
    }
  }
 
 
/****************************************************************************\
|* Přidá položku "Vypsat pahýly" do seznamu nástrojů na stránkách kategorií *|
|* vytvořil Danny B.                                                        *|
\****************************************************************************/
function addToolListStubs() {
 
  var nodDivTb = document.getElementById( "p-tb" );
 
  if( !nodDivTb || wgNamespaceNumber != 14 && wgNamespaceNumber != 15 ) return;
 
  var nodAListStubs = document.createElement( "a" );
  nodAListStubs.href = "http://toolserver.org/~danny_b/powersearch/pahyly-v-kategorii.php?kategorie=" + encodeURIComponent( wgTitle );
  nodAListStubs.title = "Zobrazit seznam všech pahýlů v této kategorii";
  nodAListStubs.appendChild( document.createTextNode( "Vypsat pahýly" ) );
 
  var nodLiListStubs = document.createElement( "li" );
  nodLiListStubs.id = "t-liststubs";
  nodLiListStubs.appendChild( nodAListStubs );
 
  var nodUlTb = nodDivTb.getElementsByTagName( "ul" )[0];
  nodUlTb.appendChild( nodLiListStubs );
 
}
 
 
/*****************\
|*  csWikipedia  *|
|* customization *|
\*****************/
 
function CustomizeCsWikipedia ()
  {
  LinkFA();
  SpravnyNazev();
  addToolListStubs();
  createCollapseButtons ();
  }
 
if (window.addEventListener)
  {
  window.addEventListener ("load", CustomizeCsWikipedia, false)
  }
else if (window.attachEvent)
  {
  window.attachEvent ("onload", CustomizeCsWikipedia)
  };
 
/*</source>*/
 
/*************************\
|* české řazení dle ÚJČ AV ČR (prirucka.ujc.cas.cz/?id=900) *|
|* vytvořil Littledogboy                                    *|
\*************************/
mw.config.set( 'tableSorterCollation', {'á':'a','č':'cÑÑ','ď':'d','é':'e','ě':'e','í':'i','ň':'n','ó':'o','ř':'rÑÑ','š':'sÑÑ','ť':'t','ú':'u','ů':'u','ý':'y','ž':'zÑÑ','Á':'A','Č':'CÑÑ','Ď':'D','É':'E','Ě':'E','Í':'I','Ň':'N','Ó':'O','Ř':'RÑÑ','Š':'SÑÑ','Ť':'T','Ú':'U','Ů':'U','Ý':'Y','Ž':'ZÑÑ'} );
 
/************************************************************************************************************\
|* Panel referencí - RefToolbar                                                                             *|
|*  Informace na [[Wikipedie:Panel referencí]], chyby hlašte na [[Diskuse k Wikipedii:Panel referencí]]     *|
|*  Nechcete-li nástroj používat, můžete jej odstranit ze svého editačního rozhraní následujícím kódem:     *|
|*     refToolbarInstalled = 'bypass';                                                                      *|
|*  ...který vložíte na [[Special:Mypage/vector.js]] (případně monobook.js)                                 *|
|*  Autor původní anglické verze: [[:en:User:Mr.Z-man]]                                                      *|
|*  Na cs.wiki přenesl a nástroj udržuje [[Wikipedista:Michal Bělka]]                                       *|
|*  Na zprovoznení české verze se podíleli [[Wikipedista:Reaperman]] a [[Wikipedista:Vojtech.dostal]]       *|
\************************************************************************************************************/
 
function initializeRefTools() {
    if ( window.refToolbarInstalled === undefined ) {
        importScriptURI('//en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-refToolbarBase.js&action=raw&ctype=text/javascript');
 
        if( mw.user.options.get('usebetatoolbar') && mw.user.options.get('usebetatoolbar-cgd') ) {
            // Enhanced editing toolbar is on with dialogs. Load standard refToolbar.
            mw.loader.using( 'ext.wikiEditor.toolbar', function () {
                importScript('MediaWiki:RefToolbar.js');
            });
        } else if( mw.user.options.get('usebetatoolbar') ) { if (navigator.appName != "Microsoft Internet Explorer") {
            // Dialogs are off. Load refToolbar 2.0 without dialogs.
            mw.loader.using( 'ext.wikiEditor.toolbar', function () {
            importScript('MediaWiki:RefToolbarNoDialogs.js');
            });
        }} else { if (navigator.appName != "Microsoft Internet Explorer") {
            // Enhanced editing toolbar is off. Load legacy refToolbar 1.0.
            importScript('MediaWiki:RefToolbarLegacy.js');
        }}
        window.refToolbarInstalled = true;
    }
}
 
$( initializeRefTools );
 
// Results from Wikidata
// [[File:Wdsearch_script_screenshot.png]]
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Search' ||  ( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgCanonicalSpecialPageName' ) === false ) ) {
	importScriptURI("//en.wikipedia.org/w/index.php?title=MediaWiki:Wdsearch.js&action=raw&ctype=text/javascript");
}
 
// vyvolání stylu klikatelných tlačítek
mw.hook( 'wikipage.content' ).add( function() {
    if ( ( mw.loader.getState( 'mediawiki.ui.button' ) === 'registered'  ) && (  $( '.mw-ui-button' ).length ) ) {
        mw.loader.load('mediawiki.ui.button');
    }
} );