Notice: Template failed integrity check: /home/jvzmxxx/wiki/extensions/MobileFrontend/includes/skins/minerva.mustache in /home/jvzmxxx/wiki/includes/TemplateParser.php on line 121
MediaWiki:Common.js: Różnice pomiędzy wersjami – Czarnobyl Wiki
Otwórz menu główne

Czarnobyl Wiki β

MediaWiki:Common.js: Różnice pomiędzy wersjami

(WDsearch jako gadżet)
 
m (1 wersja)
 
(Nie pokazano 2 wersji utworzonych przez 2 użytkowników)
Linia 1: Linia 1:
// <pre>
+
/**
/*
+
* Keep code in MediaWiki:Common.js to a minimum as it is unconditionally
UWAGA! Ten JavaScript działa dla wszystkich skórek. Należy zachować szczególną ostrożność wprowadzając tutaj zmiany!
+
* 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
==== funkcja insertTagsTo_ ====
+
* optimized ResourceLoader modules with possibility to add dependencies etc.)
; Author: phpBB Team, WikiMedia, Maciej Jaros [[:pl:User:Nux]]
+
*
; Licence: [http://opensource.org/licenses/gpl-license.php GNU General Public License v2]
+
* Since Common.js isn't a gadget, there is no place to declare its
; Description: Apply tagOpen/tagClose to selection in given textarea/input, use sampleText instead of selection if there is none. Copied and adapted from phpBB
+
* 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
// outputid = 'some_id_of_a_textarea_or_a_text_input'
+
* be loaded (or loading) already and the callback will not be delayed. In case a
function insertTagsTo_(tagOpen, tagClose, sampleText, outputid) {
+
* dependency hasn't arrived yet it'll make sure those are loaded before this.
var txtarea = document.getElementById(outputid);
+
*/
if (!txtarea)
 
return
 
;
 
 
 
// IE
 
if (document.selection) {
 
var theSelection = document.selection.createRange().text;
 
if (!theSelection)
 
theSelection=sampleText;
 
txtarea.focus();
 
if (theSelection.charAt(theSelection.length - 1) == " ") { // exclude ending space char, if any
 
theSelection = theSelection.substring(0, theSelection.length - 1);
 
document.selection.createRange().text = tagOpen + theSelection + tagClose + " ";
 
} else {
 
document.selection.createRange().text = tagOpen + theSelection + tagClose;
 
}
 
 
 
// Mozilla
 
} else if(txtarea.selectionStart || txtarea.selectionStart == '0') {
 
var replaced = false;
 
var startPos = txtarea.selectionStart;
 
var endPos = txtarea.selectionEnd;
 
if (endPos-startPos)
 
replaced = true;
 
var scrollTop = txtarea.scrollTop;
 
var myText = (txtarea.value).substring(startPos, endPos);
 
if (!myText)
 
myText=sampleText;
 
if (myText.charAt(myText.length - 1) == " ") { // exclude ending space char, if any
 
subst = tagOpen + myText.substring(0, (myText.length - 1)) + tagClose + " ";
 
} else {
 
subst = tagOpen + myText + tagClose;
 
}
 
txtarea.value = txtarea.value.substring(0, startPos) + subst +
 
txtarea.value.substring(endPos, txtarea.value.length);
 
txtarea.focus();
 
//set new selection
 
if (replaced) {
 
var cPos = startPos+(tagOpen.length+myText.length+tagClose.length);
 
txtarea.selectionStart = cPos;
 
txtarea.selectionEnd = cPos;
 
} else {
 
txtarea.selectionStart = startPos+tagOpen.length;
 
txtarea.selectionEnd = startPos+tagOpen.length+myText.length;
 
}
 
txtarea.scrollTop = scrollTop;
 
}
 
// reposition cursor if possible
 
if (txtarea.createTextRange && document.selection)
 
txtarea.caretPos = document.selection.createRange().duplicate();
 
}
 
  
/* Test if an element has a certain class **************************************
+
/* global mw, $ */
  *
+
/* jshint strict:false, browser:true */
  * Description: Uses regular expressions and caching for better performance.
 
  * Maintainers: [[User:Mike Dillon]], [[User:R. Koot]], [[User:SG]]
 
  */
 
  
var hasClass = (function () {
+
mw.loader.using( ['mediawiki.user', 'mediawiki.util', 'mediawiki.notify'] ).done( function () {
    var reCache = {};
+
/* Begin of mw.loader.using callback */
    return function (element, className) {
 
return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);
 
    };
 
})();
 
  
/** Collapsible tables *********************************************************
+
/**
  *
+
* Main Page layout fixes
  * Description: Allows tables to be collapsed, showing only the header. See
+
*
  *       [[en:Wikipedia:NavFrame]].
+
* Description: Adds an additional link to the complete list of languages available.
  *  Maintainers: [[User:R. Koot]]
+
* Maintainers: [[User:AzaToth]], [[User:R. Koot]], [[User:Alex Smotrov]]
  */
+
*/
 
+
if ( mw.config.get( 'wgPageName' ) === 'Main_Page' || mw.config.get( 'wgPageName' ) === 'Talk:Main_Page' ) {
var autoCollapse = 2;
+
$( function () {
var collapseCaption = "ukryj";
+
mw.util.addPortletLink( 'p-lang', '//meta.wikimedia.org/wiki/List_of_Wikipedias',
var expandCaption = "pokaż";
+
'Complete list', 'interwiki-completelist', 'Complete list of Wikipedias' );
 
+
} );
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()
+
/**
{
+
* Redirect User:Name/skin.js and skin.css to the current skin's pages
    var tableIndex = 0;
+
* (unless the 'skin' page really exists)
    var NavigationBoxes = {};
+
* @source: http://www.mediawiki.org/wiki/Snippets/Redirect_skin.js
    var Tables = document.getElementsByTagName( "table" );
+
* @rev: 2
 
+
*/
    for ( var i = 0; i < Tables.length; i++ ) {
+
if ( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgNamespaceNumber' ) === 2 ) {
if ( hasClass( Tables[i], "collapsible" ) ) {
+
var titleParts = mw.config.get( 'wgPageName' ).split( '/' );
 
+
/* Make sure there was a part before and after the slash
    /* only add button and increment count if there is a header row to work with */
+
  and that the latter is 'skin.js' or 'skin.css' */
    var HeaderRow = Tables[i].getElementsByTagName( "tr" )[0];
+
if ( titleParts.length == 2 ) {
    if (!HeaderRow) continue;
+
var userSkinPage = titleParts.shift() + '/' + mw.config.get( 'skin' );
    var Header = HeaderRow.getElementsByTagName( "th" )[0];
+
if ( titleParts.slice( -1 ) == 'skin.js' ) {
    if (!Header) continue;
+
window.location.href = mw.util.getUrl( userSkinPage + '.js' );
 
+
} else if ( titleParts.slice( -1 ) == 'skin.css' ) {
    NavigationBoxes[ tableIndex ] = Tables[i];
+
window.location.href = mw.util.getUrl( userSkinPage + '.css' );
    Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex );
 
 
 
    var Button    = document.createElement( "span" );
 
    var ButtonLink = document.createElement( "a" );
 
    var ButtonText = document.createTextNode( collapseCaption );
 
 
 
    Button.style.styleFloat = "right";
 
    Button.style.cssFloat = "right";
 
    Button.style.fontWeight = "normal";
 
    Button.style.textAlign = "right";
 
    Button.style.width = "6em";
 
 
 
    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;
 
 
}
 
}
    }
 
 
}
 
}
    }
 
 
}
 
}
  
jQuery( createCollapseButtons );
+
/**
 +
* Map addPortletLink to mw.util
 +
* @deprecated: Use mw.util.addPortletLink instead.
 +
*/
 +
mw.log.deprecate( window, 'addPortletLink', mw.util.addPortletLink, 'Use mw.util.addPortletLink instead' );
  
 +
/**
 +
* 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' );
  
/** Dynamic Navigation Bars (experimental) *************************************
+
/**
  *
+
  * Test if an element has a certain class
  *  Description: See [[Wikipedia:NavFrame]].
+
  * @deprecated: Use $(element).hasClass() instead.
*  Maintainers: UNMAINTAINED
 
 
  */
 
  */
 +
mw.log.deprecate( window, 'hasClass', function ( element, className ) {
 +
return $( element ).hasClass( className );
 +
}, 'Use jQuery.hasClass() instead' );
  
// set up the words in your language
+
/**
var NavigationBarHide = '[' + collapseCaption + ']';
+
* @source www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL
var NavigationBarShow = '[' + expandCaption + ']';
+
* @rev 6
 +
*/
 +
var extraCSS = mw.util.getParamValue( 'withCSS' ),
 +
extraJS = mw.util.getParamValue( 'withJS' );
  
// shows and hides content and picture (if available) of navigation bars
+
if ( extraCSS ) {
// Parameters:
+
if ( extraCSS.match( /^MediaWiki:[^&<>=%#]*\.css$/ ) ) {
//    indexNavigationBar: the index of navigation bar to be toggled
+
mw.loader.load( '/w/index.php?title=' + extraCSS + '&action=raw&ctype=text/css', 'text/css' );
function toggleNavigationBar(indexNavigationBar)
+
} else {
{
+
mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withCSS value' } );
    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 ( hasClass( NavChild, 'NavPic' ) ) {
 
NavChild.style.display = 'none';
 
    }
 
    if ( hasClass( NavChild, 'NavContent') ) {
 
NavChild.style.display = 'none';
 
    }
 
 
}
 
}
    NavToggle.firstChild.data = NavigationBarShow;
+
}
  
    // if hidden now
+
if ( extraJS ) {
    } else if (NavToggle.firstChild.data == NavigationBarShow) {
+
if ( extraJS.match( /^MediaWiki:[^&<>=%#]*\.js$/ ) ) {
for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
+
mw.loader.load( '/w/index.php?title=' + extraJS + '&action=raw&ctype=text/javascript' );
    if (hasClass(NavChild, 'NavPic')) {
+
} else {
NavChild.style.display = 'block';
+
mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withJS value' } );
    }
 
    if (hasClass(NavChild, 'NavContent')) {
 
NavChild.style.display = 'block';
 
    }
 
 
}
 
}
NavToggle.firstChild.data = NavigationBarHide;
 
    }
 
 
}
 
}
  
// adds show/hide-button to navigation bars
+
/**
function createNavigationBarToggleButton()
+
* WikiMiniAtlas
{
+
*
    var indexNavigationBar = 0;
+
* Description: WikiMiniAtlas is a popup click and drag world map.
    // iterate over all < div >-elements
+
*              This script causes all of our coordinate links to display the WikiMiniAtlas popup button.
    var divs = document.getElementsByTagName("div");
+
*              The script itself is located on meta because it is used by many projects.
    for (var i = 0; NavFrame = divs[i]; i++) {
+
*              See [[Meta:WikiMiniAtlas]] for more information.
// if found a navigation bar
+
* Note - use of this service is recommended to be repalced with mw:Help:Extension:Kartographer
if (hasClass(NavFrame, "NavFrame")) {
+
*/
 
+
( function () {
    indexNavigationBar++;
+
var require_wikiminiatlas = false;
    var NavToggle = document.createElement("a");
+
var coord_filter = /geohack/;
    NavToggle.className = 'NavToggle';
+
$( function () {
    NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
+
$( 'a.external.text' ).each( function( key, link ) {
    NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');
+
if ( link.href && coord_filter.exec( link.href ) ) {
 
+
require_wikiminiatlas = true;
    var isCollapsed = hasClass( NavFrame, "collapsed" );
+
// break from loop
    /*
+
return false;
    * 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
+
if ( $( 'div.kmldata' ).length ) {
    * the content visible without JavaScript support), the new recommended way is to add the class
+
require_wikiminiatlas = true;
    * "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 ( NavChild.style.display == 'none' ) {
 
isCollapsed = true;
 
    }
 
 
}
 
}
    }
+
if ( require_wikiminiatlas ) {
    if (isCollapsed) {
+
mw.loader.load( '//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript' );
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);
+
 
 +
/**
 +
* Collapsible tables; reimplemented with mw-collapsibe
 +
* Styling is also in place to avoid FOUC
 +
*
 +
* Allows tables to be collapsed, showing only the header. See [[Help:Collapsing]].
 +
* @version 3.0.0 (2018-05-20)
 +
* @source https://www.mediawiki.org/wiki/MediaWiki:Gadget-collapsibleTables.js
 +
* @author [[User:R. Koot]]
 +
* @author [[User:Krinkle]]
 +
* @author [[User:TheDJ]]
 +
* @deprecated Since MediaWiki 1.20: Use class="mw-collapsible" instead which
 +
* is supported in MediaWiki core. Shimmable since MediaWiki 1.32
 +
*/
 +
function makeCollapsibleMwCollapsible( $content ) {
 +
var $tables = $content
 +
.find( 'table.collapsible:not(.mw-collapsible)' )
 +
.addClass( 'mw-collapsible' );
  
    // Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
+
$.each( $tables, function( index, table ) {
    for(var j=0; j < NavFrame.childNodes.length; j++) {
+
// mw.log.warn( 'This page is using the deprecated class collapsible. Please replace it with mw-collapsible.');
if (hasClass(NavFrame.childNodes[j], "NavHead")) {
+
if( $( table ).hasClass( 'collapsed') ) {
    NavFrame.childNodes[j].appendChild(NavToggle);
+
$( table ).addClass( 'mw-collapsed' );
 +
// mw.log.warn( 'This page is using the deprecated class collapsed. Please replace it with mw-collapsed.');
 
}
 
}
    }
+
} );
    NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
+
if( $tables.length > 0 ) {
 +
mw.loader.using( 'jquery.makeCollapsible' ).then( function() {
 +
$tables.makeCollapsible();
 +
} );
 
}
 
}
    }
 
 
}
 
}
 
+
mw.hook( 'wikipage.content' ).add( makeCollapsibleMwCollapsible );
jQuery( createNavigationBarToggleButton );
 
  
 
/**
 
/**
  * Skrypt dla Szablon:Galeria
+
  * Add support to mw-collapsible for autocollapse, innercollapse and outercollapse
 +
*
 +
* Maintainers: TheDJ
 
  */
 
  */
function toggleImage (group, remindex, shwindex) {
+
function mwCollapsibleSetup( $collapsibleContent ) {
jQuery("#ImageGroupsGr" + group + "Im" + remindex).hide();
+
var $element,
jQuery("#ImageGroupsGr" + group + "Im" + shwindex).show();
+
$toggle,
}
+
autoCollapseThreshold = 2;
function ImageGroup() {
+
$.each( $collapsibleContent, function (index, element) {
jQuery('div.ImageGroup').each(function(i, group) {
+
$element = $( element );
var unitnode = jQuery('div.ImageGroupUnits', group).get(0);
+
if ( $element.hasClass( 'collapsible' ) ) {
if (unitnode == undefined) {
+
$element.find('tr:first > th:first').prepend( $element.find('tr:first > * > .mw-collapsible-toggle'));
return 1;
 
 
}
 
}
var units = jQuery(unitnode).children('.center');
+
if ( $collapsibleContent.length >= autoCollapseThreshold && $element.hasClass( 'autocollapse' ) ) {
var count = units.get().length;
+
$element.data( 'mw-collapsible' ).collapse();
if (count <= 1) {
+
} else if ( $element.hasClass( 'innercollapse' ) ) {
return 1;
+
if ( $element.parents( '.outercollapse' ).length > 0 ) {
 +
$element.data( 'mw-collapsible' ).collapse();
 +
}
 
}
 
}
units.each(function(j, currentimage) {
+
// because of colored backgrounds, style the link in the text color
jQuery(currentimage).attr('id', "ImageGroupsGr" + i + "Im" + j);
+
// to ensure accessible contrast
var leftlink = jQuery('<a href="#"/>');
+
$toggle = $element.find( '.mw-collapsible-toggle' );
if (j != 0) {
+
if ( $toggle.length ) {
leftlink.text('').click(function() {
+
// Make the toggle inherit text color
toggleImage(i, j, j - 1); return false;
+
if( $toggle.parent()[0].style.color ) {
});
+
$toggle.find( 'a' ).css( 'color', 'inherit' );
 
}
 
}
var rightlink = jQuery('<a href="#"/>');
+
}
if (j != count - 1) {
+
} );
rightlink.text('▶').click(function() {
 
toggleImage(i, j, j + 1); return false;
 
});
 
}
 
jQuery('<div/>').css({ 'font-size' : '110%', 'font-weight' : 'bold' })
 
.addClass('disabled-user-selection')
 
.append(leftlink)
 
.append('<tt>(' + (j + 1) + '/' + count +  ')</tt>')
 
.append(rightlink)
 
.prependTo(jQuery(currentimage));
 
if (j != 0) {
 
jQuery(currentimage).hide().addClass('noprint');
 
}
 
});
 
});
 
 
}
 
}
jQuery(ImageGroup);
 
  
mw.loader.using( ["mediawiki.util", "jquery.cookie"] ).then( function() {
+
mw.hook( 'wikipage.collapsibleContent' ).add( mwCollapsibleSetup );
if ( mw.config.get( 'wgUserName' ) == null ) {
 
mw.util.addCSS( '.anon_hide_block{display:none}' );
 
  
// Skrypt dla anonimowych użytkowników umożliwiający odznaczenie wiadomości jako przeczytanych (na daną sesję).
+
/**
if ( mw.config.get( 'wgNamespaceNumber' ) === 3 ) {
+
* Dynamic Navigation Bars (experimental)
jQuery( function() {
+
*
re = new RegExp( 'title=[^:&]+:[0-9.]+\&diff=cur' );
+
* Description: See [[Wikipedia:NavFrame]].
if ( re.test( location.search ) ) {
+
* Maintainers: UNMAINTAINED
jQuery.cookie( 'read_memail_go_away', '1', {
+
*/
path: '/'
+
} );
+
var collapseCaption = 'hide';
}
+
var expandCaption = 'show';
} );
+
 
 +
// Set up the words in your language
 +
var navigationBarHide = '[' + collapseCaption + ']';
 +
var navigationBarShow = '[' + expandCaption + ']';
 +
 
 +
/**
 +
* Shows and hides content and picture (if available) of navigation bars.
 +
*
 +
* @param {number} indexNavigationBar The index of navigation bar to be toggled
 +
* @param {jQuery.Event} event Event object
 +
*/
 +
function toggleNavigationBar( indexNavigationBar, event ) {
 +
var navToggle = document.getElementById( 'NavToggle' + indexNavigationBar );
 +
var navFrame = document.getElementById( 'NavFrame' + indexNavigationBar );
 +
var navChild;
 +
 
 +
if ( !navFrame || !navToggle ) {
 +
return false;
 +
}
 +
 
 +
// If shown now
 +
if ( navToggle.firstChild.data === navigationBarHide ) {
 +
for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {
 +
if ( $( navChild ).hasClass( 'NavContent' ) ) {
 +
navChild.style.display = 'none';
 +
}
 
}
 
}
 
+
navToggle.firstChild.data = navigationBarShow;
if ( jQuery.cookie( 'read_memail_go_away' ) == '1' ) {
+
mw.util.addCSS( '.usermessage {display:none;}' );
+
// If hidden now
 +
} else if ( navToggle.firstChild.data === navigationBarShow ) {
 +
for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {
 +
if ( $( navChild ).hasClass( 'NavContent' ) ) {
 +
navChild.style.display = 'block';
 +
}
 
}
 
}
 
+
navToggle.firstChild.data = navigationBarHide;
} else {
 
mw.util.addCSS( '.nonanon_hide_block{display:none}' );
 
 
}
 
}
} );
 
  
/////////////////////////////////////////
+
event.preventDefault();
/////      Skrypty zewnętrzne    //////
+
}
/////////////////////////////////////////
 
  
/** Parametr &withJS= *******
+
/**
* Spróbuj załadować dodatkowy skrypt z przestrzeni MediaWiki
+
  * Adds show/hide-button to navigation bars.
  * bez potrzeby edytowania [[Special:Mypage/monobook.js]]
 
 
  *
 
  *
  * Maintainer: commons: [[User:Platonides]], plwiki: [[User:Saper]]
+
  * @param {jQuery} $content
 
  */
 
  */
 +
function createNavigationBarToggleButton( $content ) {
 +
var i, j, navChild, navToggle, navToggleText, isCollapsed,
 +
indexNavigationBar = 0;
 +
// Iterate over all < div >-elements
 +
var $divs = $content.find( 'div.NavFrame:not(.mw-collapsible)' );
 +
$divs.each( function ( i, navFrame ) {
 +
indexNavigationBar++;
 +
navToggle = document.createElement( 'a' );
 +
navToggle.className = 'NavToggle';
 +
navToggle.setAttribute( 'id', 'NavToggle' + indexNavigationBar );
 +
navToggle.setAttribute( 'href', '#' );
 +
$( navToggle ).on( 'click', $.proxy( toggleNavigationBar, null, indexNavigationBar ) );
  
mw.loader.using( "mediawiki.util" ).then(function() {
+
isCollapsed = $( navFrame ).hasClass( 'collapsed' );
var extraJS = mw.util.getParamValue( "withJS" );
+
/**
if ( extraJS ) {
+
* Check if any children are already hidden.  This loop is here for backwards compatibility:
if ( extraJS.match( "^MediaWiki:[^&<>=%]*\.js$" ) ) {
+
* the old way of making NavFrames start out collapsed was to manually add style="display:none"
importScript( extraJS );
+
* to all the NavPic/NavContent elements. Since this was bad for accessibility (no way to make
} else {
+
* the content visible without JavaScript support), the new recommended way is to add the class
alert( "Plik " + extraJS + " nie powinien byc ladowany." );
+
* "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';
 +
}
 +
}
 
}
 
}
}
+
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)
// Ustawienie wysokości "Usunięcie" pustego elementu contentSub
+
for ( j = 0; j < navFrame.childNodes.length; j++ ) {
//
+
if ( $( navFrame.childNodes[j] ).hasClass( 'NavHead' ) ) {
jQuery(function()
+
navToggle.style.color = navFrame.childNodes[j].style.color;
{
+
navFrame.childNodes[j].appendChild( navToggle );
var el=document.getElementById('mw-revisiontag');
+
}
if (el && el.className.indexOf('flaggedrevs_short')!=-1)
+
}
{
+
navFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar );
if (el.parentNode.id=='contentSub') el.parentNode.style.height='17px';
+
} );
}
+
}
});
 
  
jQuery(function()
+
mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton );
{
 
jQuery('table.navbox').first().addClass('firstNavbox');
 
})
 
  
/*
+
/**
  * Description: Redirects from User:UserName/skin.js or .css to the user's actual skin page
+
* Magic editintros ****************************************************
  * Maintainer: Nux
+
*
 +
  * Description: Adds editintros on disambiguation pages and BLP pages.
 +
  * Maintainers: [[User:RockMFR]]
 
  */
 
  */
if (mw.config.get('wgNamespaceNumber') == 2 && mw.config.get('wgArticleId') == 0 && mw.config.get('wgAction') == "view" // Nonexistent User:... page in view mode
+
function addEditIntro( name ) {
&& mw.config.get('wgUserName')    // Logged in User
+
$( '.mw-editsection, #ca-edit, #ca-ve-edit' ).find( 'a' ).each( function ( i, el ) {
&& mw.config.get('wgTitle').indexOf(mw.config.get('wgUserName')+"/skin.")===0
+
el.href = $( this ).attr( 'href' ) + '&editintro=' + name;
&& mw.config.get('wgTitle').search(/\/skin.(js|css)/)>0
+
} );
)
 
{
 
window.location.href = window.location.href.replace(/\/skin.(css|js)/i, '/' + skin + '.$1');
 
 
}
 
}
  
 +
if ( mw.config.get( 'wgNamespaceNumber' ) === 0 ) {
 +
$( function () {
 +
if ( document.getElementById( 'disambigbox' ) ) {
 +
addEditIntro( 'Template:Disambig_editintro' );
 +
}
 +
} );
  
// Kod pozwalający na skonstruowanie niesortującej się kolumny z liczbą porządkową w sortowalnych tabelkach.
+
$( function () {
// Odpowiednia komórka nagłówkowa sortowalnej tabelki (class="sortable") musi być oznaczona
+
var cats = mw.config.get('wgCategories');
// jako niesortowalna i zawierająca liczby porządkowe (class="unsortable ordinal").
+
if ( !cats ) {
// Dyskusja w kawiarence: [[Wikipedia:Kawiarenka/Kwestie techniczne#Poprawa tabeli w Miasta w Polsce (statystyki)]]
+
return;
// Zgłoszenie na Bugzilli: [https://bugzilla.wikimedia.org/show_bug.cgi?id=40618]
+
}
$('table.sortable th.unsortable.ordinal').each(function(i, th) {
+
if ( $.inArray( 'Living people', cats ) !== -1 || $.inArray( 'Possibly living people', cats ) !== -1 ) {
var $th = $(th), $table = $th.closest('table');
+
addEditIntro( 'Template:BLP_editintro' );
$table.on('sortEnd.tablesorter', function() {
+
}
$table.find('tr td:nth-child('+ (th.cellIndex+1) +')').each(function(j, td) {
+
} );
$(td).text( (j+1) );
+
}
});
 
})
 
});
 
  
// Sortowanie tekstów w tabelach (class="sortable") uwzględniające polskie diakrytyki.
+
/* Actions specific to the edit page */
// Nie jest to rozwiązanie "poprawne", ale de facto działa.
+
if ( mw.config.get( 'wgAction' ) === 'edit' || mw.config.get( 'wgAction' ) === 'submit' ) {
mw.config.set('tableSorterCollation', {
+
/**
'ą':'azz', 'Ą':'AZZ',
+
* Fix edit summary prompt for undo
'ć':'czz', 'Ć':'CZZ',
+
*
'ę':'ezz', 'Ę':'EZZ',
+
*  Fixes the fact that the undo function combined with the "no edit summary prompter"
'ł':'lzz', 'Ł':'LZZ',
+
*  complains about missing editsummary, if leaving the edit summary unchanged.
'ń':'nzz', 'Ń':'NZZ',
+
*  Added by [[User:Deskana]], code by [[User:Tra]].
'ó':'ozz', 'Ó':'OZZ',
+
*  See also [[phab:T10912]].
'ś':'szz', 'Ś':'SZZ',  
+
*/
'ź':'zzz', 'Ź':'ZZZ',
+
$(function () {
'ż':'zzzz', 'Ż':'ZZZZ'
+
if (document.location.search.indexOf('undo=') !== -1 && document.getElementsByName('wpAutoSummary')[0]) {
});
+
document.getElementsByName('wpAutoSummary')[0].value = '1';
 
 
// Załaduj edytor dla [[Wikipedia:Indeks biografii]], gdy ktoś zechce go edytować
 
$( function() {
 
if($('.bioindex-entry').length === 0) {
 
return;
 
}
 
 
 
mw.loader.using('jquery.spinner').then(function() {
 
function loadHandler(e) {
 
if(e.type === 'keypress' && e.which !== 13 && e.which !== 32) {
 
return; // handle enter and space
 
}
 
var $editlink = $(this);
 
var $spinner = $.createSpinner().css('margin-left', '1em');
 
$editlink.after($spinner);
 
 
mw.loader.using('ext.gadget.bioindex-editor').then(function() {
 
$spinner.remove();
 
$editlink.trigger('click');
 
});
 
 
$('#mw-content-text').off('click keypress', '.bioindex-entry .bioindex-edit a', loadHandler);
 
e.preventDefault();
 
 
}
 
}
 +
});
 +
}
  
$('#mw-content-text').on('click keypress', '.bioindex-entry .bioindex-edit a', loadHandler);
+
/* End of mw.loader.using callback */
});
 
 
} );
 
} );
 
+
/* DO NOT ADD CODE BELOW THIS LINE */
// ładuj tylko anonimowym (a nie wszystkim, a potem wychodź po sprawdzeniu)
 
if (mw.config.get('wgUserName') === null) {
 
    mw.loader.load('ext.gadget.allinterwiki');
 
}
 

Aktualna wersja na dzień 16:02, 5 maj 2019

/**
 * 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, $ */
/* jshint strict:false, browser:true */

mw.loader.using( ['mediawiki.user', 'mediawiki.util', 'mediawiki.notify'] ).done( function () {
/* Begin of mw.loader.using callback */

/**
 * Main Page layout fixes
 *
 * Description: Adds an additional link to the complete list of languages available.
 * Maintainers: [[User:AzaToth]], [[User:R. Koot]], [[User:Alex Smotrov]]
 */
if ( mw.config.get( 'wgPageName' ) === 'Main_Page' || mw.config.get( 'wgPageName' ) === 'Talk:Main_Page' ) {
	$( function () {
		mw.util.addPortletLink( 'p-lang', '//meta.wikimedia.org/wiki/List_of_Wikipedias',
			'Complete list', 'interwiki-completelist', 'Complete list of Wikipedias' );
	} );
}

/**
 * Redirect User:Name/skin.js and skin.css to the current skin's pages
 * (unless the 'skin' page really exists)
 * @source: http://www.mediawiki.org/wiki/Snippets/Redirect_skin.js
 * @rev: 2
 */
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
 * @deprecated: Use mw.util.addPortletLink instead.
 */
mw.log.deprecate( window, 'addPortletLink', mw.util.addPortletLink, 'Use mw.util.addPortletLink instead' );

/**
 * 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$/ ) ) {
		mw.loader.load( '/w/index.php?title=' + extraCSS + '&action=raw&ctype=text/css', 'text/css' );
	} else {
		mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withCSS value' } );
	}
}

if ( extraJS ) {
	if ( extraJS.match( /^MediaWiki:[^&<>=%#]*\.js$/ ) ) {
		mw.loader.load( '/w/index.php?title=' + extraJS + '&action=raw&ctype=text/javascript' );
	} else {
		mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withJS value' } );
	}
}

/**
 * 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.
 * Note - use of this service is recommended to be repalced with mw:Help:Extension:Kartographer
 */
( 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; reimplemented with mw-collapsibe
 * Styling is also in place to avoid FOUC
 * 
 * Allows tables to be collapsed, showing only the header. See [[Help:Collapsing]].
 * @version 3.0.0 (2018-05-20)
 * @source https://www.mediawiki.org/wiki/MediaWiki:Gadget-collapsibleTables.js
 * @author [[User:R. Koot]]
 * @author [[User:Krinkle]]
 * @author [[User:TheDJ]]
 * @deprecated Since MediaWiki 1.20: Use class="mw-collapsible" instead which
 * is supported in MediaWiki core. Shimmable since MediaWiki 1.32
 */
function makeCollapsibleMwCollapsible( $content ) {
	var $tables = $content
		.find( 'table.collapsible:not(.mw-collapsible)' )
		.addClass( 'mw-collapsible' );

	$.each( $tables, function( index, table ) {
		// mw.log.warn( 'This page is using the deprecated class collapsible. Please replace it with mw-collapsible.');
		if( $( table ).hasClass( 'collapsed') ) {
			$( table ).addClass( 'mw-collapsed' );
			// mw.log.warn( 'This page is using the deprecated class collapsed. Please replace it with mw-collapsed.');
		}
	} );
	if( $tables.length > 0 ) {
		mw.loader.using( 'jquery.makeCollapsible' ).then( function() {
			$tables.makeCollapsible();
		} );
	}
}
mw.hook( 'wikipage.content' ).add( makeCollapsibleMwCollapsible );

/**
 * Add support to mw-collapsible for autocollapse, innercollapse and outercollapse
 *
 * Maintainers: TheDJ
 */
function mwCollapsibleSetup( $collapsibleContent ) {
	var $element,
		$toggle,
		autoCollapseThreshold = 2;
	$.each( $collapsibleContent, function (index, element) {
		$element = $( element );
		if ( $element.hasClass( 'collapsible' ) ) {
			$element.find('tr:first > th:first').prepend( $element.find('tr:first > * > .mw-collapsible-toggle'));
		}
		if ( $collapsibleContent.length >= autoCollapseThreshold && $element.hasClass( 'autocollapse' ) ) {
			$element.data( 'mw-collapsible' ).collapse();
		} else if ( $element.hasClass( 'innercollapse' ) ) {
			if ( $element.parents( '.outercollapse' ).length > 0 ) {
				$element.data( 'mw-collapsible' ).collapse();
			}
		}
		// because of colored backgrounds, style the link in the text color
		// to ensure accessible contrast
		$toggle = $element.find( '.mw-collapsible-toggle' );
		if ( $toggle.length ) {
			// Make the toggle inherit text color
			if( $toggle.parent()[0].style.color ) {
				$toggle.find( 'a' ).css( 'color', 'inherit' );
			}
		}
	} );
}

mw.hook( 'wikipage.collapsibleContent' ).add( mwCollapsibleSetup );

/**
 * Dynamic Navigation Bars (experimental)
 *
 * Description: See [[Wikipedia:NavFrame]].
 * Maintainers: UNMAINTAINED
 */
 
var collapseCaption = 'hide';
var expandCaption = 'show';

// Set up the words in your language
var navigationBarHide = '[' + collapseCaption + ']';
var navigationBarShow = '[' + expandCaption + ']';

/**
 * Shows and hides content and picture (if available) of navigation bars.
 *
 * @param {number} indexNavigationBar The index of navigation bar to be toggled
 * @param {jQuery.Event} event Event object
 */
function toggleNavigationBar( indexNavigationBar, event ) {
	var navToggle = document.getElementById( 'NavToggle' + indexNavigationBar );
	var navFrame = document.getElementById( 'NavFrame' + indexNavigationBar );
	var navChild;

	if ( !navFrame || !navToggle ) {
		return false;
	}

	// If shown now
	if ( navToggle.firstChild.data === navigationBarHide ) {
		for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {
			if ( $( navChild ).hasClass( 'NavContent' ) ) {
				navChild.style.display = 'none';
			}
		}
		navToggle.firstChild.data = navigationBarShow;
	
	// If hidden now
	} else if ( navToggle.firstChild.data === navigationBarShow ) {
		for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {
			if ( $( navChild ).hasClass( 'NavContent' ) ) {
				navChild.style.display = 'block';
			}
		}
		navToggle.firstChild.data = navigationBarHide;
	}

	event.preventDefault();
}

/**
 * Adds show/hide-button to navigation bars.
 *
 * @param {jQuery} $content
 */
function createNavigationBarToggleButton( $content ) {
	var i, j, navChild, navToggle, navToggleText, isCollapsed,
		indexNavigationBar = 0;
	// Iterate over all < div >-elements
	var $divs = $content.find( 'div.NavFrame:not(.mw-collapsible)' );
	$divs.each( function ( i, navFrame ) {
		indexNavigationBar++;
		navToggle = document.createElement( 'a' );
		navToggle.className = 'NavToggle';
		navToggle.setAttribute( 'id', 'NavToggle' + indexNavigationBar );
		navToggle.setAttribute( 'href', '#' );
		$( navToggle ).on( 'click', $.proxy( toggleNavigationBar, null, indexNavigationBar ) );

		isCollapsed = $( navFrame ).hasClass( 'collapsed' );
		/**
		 * 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 ( 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';
				}
			}
		}
		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)
		for ( j = 0; j < navFrame.childNodes.length; j++ ) {
			if ( $( navFrame.childNodes[j] ).hasClass( 'NavHead' ) ) {
				navToggle.style.color = navFrame.childNodes[j].style.color;
				navFrame.childNodes[j].appendChild( navToggle );
			}
		}
		navFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar );
	} );
}

mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton );

/**
 * Magic editintros ****************************************************
 *
 * Description: Adds editintros on disambiguation pages and BLP pages.
 * Maintainers: [[User:RockMFR]]
 */
function addEditIntro( name ) {
	$( '.mw-editsection, #ca-edit, #ca-ve-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' );
		}
	} );
}

/* Actions specific to the edit page */
if ( mw.config.get( 'wgAction' ) === 'edit' || mw.config.get( 'wgAction' ) === 'submit' ) {
	/**
	 * Fix edit summary prompt for undo
	 *
	 *  Fixes the fact that the undo function combined with the "no edit summary prompter"
	 *  complains about missing editsummary, if leaving the edit summary unchanged.
	 *  Added by [[User:Deskana]], code by [[User:Tra]].
	 *  See also [[phab:T10912]].
	 */
	$(function () {
		if (document.location.search.indexOf('undo=') !== -1 && document.getElementsByName('wpAutoSummary')[0]) {
			document.getElementsByName('wpAutoSummary')[0].value = '1';
		}
	});
}

/* End of mw.loader.using callback */
} );
/* DO NOT ADD CODE BELOW THIS LINE */