Différences entre les versions de « MediaWiki:Common.js »

De Nations.fr
fr>Od1n
(ajout commentaire pour prévenir régressions (et me rassurer))
 
en>Galobtter
(remove unused class per request)
Ligne 1 : Ligne 1 :
/* jshint scripturl:true, laxbreak:true, loopfunc:true */
/* global mw, $, importScript */
/**
/**
  * N'importe quel JavaScript ici sera chargé pour n'importe quel utilisateur et pour chaque page accédée.
  * 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.)
  *
  *
  * ATTENTION : Avant de modifier cette page, veuillez tester vos changements avec votre propre
  * Since Common.js isn't a gadget, there is no place to declare its
* vector.js. Une erreur sur cette page peut faire bugger le site entier (et gêner l'ensemble des
  * dependencies, so we have to lazy load them with mw.loader.using on demand and
  * visiteurs), même plusieurs heures après la modification !
  * 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
  * Prière de ranger les nouvelles fonctions dans les sections adaptées :
  * dependency hasn't arrived yet it'll make sure those are loaded before this.
  * - Fonctions JavaScript
* - Fonctions spécifiques pour MediaWiki
* - Applications spécifiques à la fenêtre d'édition
* - Applications qui peuvent être utilisées sur toute page
* - Applications spécifiques à un espace de nom ou une page
*
* <nowiki> /!\ Ne pas retirer cette balise
  */
  */


/* global mw, $ */
/* jshint strict:false, browser:true */


/**********************************************************************************************************/
mw.loader.using( ['mediawiki.user', 'mediawiki.util', 'mediawiki.notify'] ).done( function () {
/* Fonctions générales MediaWiki (pallient les limitations du logiciel)                                  */
/* Begin of mw.loader.using callback */
/* Surveiller : https://git.wikimedia.org/history/mediawiki%2Fcore.git/HEAD/skins%2Fcommon%2Fwikibits.js  */
/**********************************************************************************************************/


/**
/**
  * Projet JavaScript
  * 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]]
  */
  */
window.obtenir = function ( name ) {
if ( mw.config.get( 'wgPageName' ) === 'Main_Page' || mw.config.get( 'wgPageName' ) === 'Talk:Main_Page' ) {
if ( mw.loader.getState( 'ext.gadget.' + name ) !== null ) {
$( function () {
mw.loader.load( 'ext.gadget.' + name );
mw.util.addPortletLink( 'p-lang', '//meta.wikimedia.org/wiki/List_of_Wikipedias',
} else {
'Complete list', 'interwiki-completelist', 'Complete list of Wikipedias' );
importScript( 'MediaWiki:Gadget-' + name + '.js' );
} );
}
}
};


/**
/**
  * Transformer les pages du Bistro, du BA et les pages spécifiées en page de discussion
  * 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( 'wgNamespaceNumber' ) >= 2 ) {
if ( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgNamespaceNumber' ) === 2 ) {
$( function ( $ ) {
var titleParts = mw.config.get( 'wgPageName' ).split( '/' );
if (
/* Make sure there was a part before and after the slash
/^Wikipédia:(Le_Bistro|Bulletin_des_administrateurs|Questions_techniques)/.test( mw.config.get( 'wgPageName' ) ) ||
  and that the latter is 'skin.js' or 'skin.css' */
$( '#transformeEnPageDeDiscussion' ).length
if ( titleParts.length == 2 ) {
) {
var userSkinPage = titleParts.shift() + '/' + mw.config.get( 'skin' );
$( 'body' ).removeClass( 'ns-subject' ).addClass( 'ns-talk' );
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
/* Applications pour l'ensemble du site */
* @deprecated: Use mw.util.addPortletLink instead.
/****************************************/
*/
mw.log.deprecate( window, 'addPortletLink', mw.util.addPortletLink, 'Use mw.util.addPortletLink instead' );


/**
/**
  * Tout ce qui concerne la page d'édition
  * Extract a URL parameter from the current URL
* @deprecated: Use mw.util.getParamValue with proper escaping
  */
  */
if ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) {
mw.log.deprecate( window, 'getURLParamValue', mw.util.getParamValue, 'Use mw.util.getParamValue instead' );
 
// chargement de [[MediaWiki:Gadget-CommonEdit.js]]
mw.loader.load( 'ext.gadget.CommonEdit' );
 
// pour que les fonctions soient définies dès maintenant,
// mais l'exécution réelle ne se fait qu'une fois le module chargé
window.addSpecialCharset = function ( title, chars ) {
mw.loader.using( 'ext.gadget.CommonEdit', function () {
window.realAddSpecialCharset( title, chars );
} );
};
window.addSpecialCharsetHTML = function ( title, charsHTML ) {
mw.loader.using( 'ext.gadget.CommonEdit', function () {
window.realAddSpecialCharsetHTML( title, charsHTML );
} );
};
 
// fonction pour ajouter un bouton à la fin de la barre d'outils
// permet d'utiliser [[MediaWiki:Gadget-MonobookToolbar.js]] sans se préoccuper de son chargement
window.addCustomButton = ( function () {
var promise;
 
return function () {
var buttonArguments = [].slice.call( arguments );
 
if ( !promise ) {
promise = mw.loader.using( 'ext.gadget.MonobookToolbar' );
}
 
promise.done( function () {
MonobookToolbar.addButton.apply( MonobookToolbar, buttonArguments );
} );
};
} )();
 
} else {
// pour que les fonctions soient toujours définies,
// afin d'éviter aux scripts utilisateur de planter
window.addSpecialCharset = function () {};
window.addSpecialCharsetHTML = function () {};
window.addCustomButton = function () {};
}


/**
/**
  * Réécriture des titres
  * Test if an element has a certain class
  *
  * @deprecatedUse $(element).hasClass() instead.
* Fonction utilisée par [[Modèle:Titre incorrect]]
*
* La fonction cherche un bandeau de la forme
  * <div id="RealTitleBanner">
*  <span id="RealTitle">titre</span>
* </div>
*
* Un élément comportant id="DisableRealTitle" désactive la fonction
  */
  */
function rewritePageTitle( $ ) {
mw.log.deprecate( window, 'hasClass', function ( element, className ) {
var $realTitle, titleHtml, $h1,
return $( element ).hasClass( className );
$realTitleBanner = $( '#RealTitleBanner' );
}, 'Use jQuery.hasClass() instead' );
if ( $realTitleBanner.length && !$( '#DisableRealTitle' ).length ) {
$realTitle = $( '#RealTitle' );
$h1 = $( 'h1:first' );
if ( $realTitle.length && $h1.length ) {
titleHtml = $realTitle.html();
if ( titleHtml === '' ) {
$h1.hide();
} else {
$h1.html( titleHtml );
if ( mw.config.get( 'wgAction' ) === 'view' ) {
// using a callback for replacement, to prevent interpreting "$" characters that realTitle might contain
document.title = document.title.replace( /^.+( [—–-] Wikipédia)$/, function ( match, p1 ) {
return $realTitle.text() + p1;
} );
}
}
$realTitleBanner.hide();
$( '<p>' ).css( 'font-size', '80%' )
.append( 'Titre à utiliser pour créer un lien interne : ', $( '<b>' ).text( mw.config.get( 'wgPageName' ).replace( /_/g, ' ' ) ) )
.insertAfter( $h1 );
}
}
}
$( rewritePageTitle );
 


/**
/**
  * Ajout d'un sous-titre
  * @source www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL
*
  * @rev 6
* Fonction utilisée par [[Modèle:Sous-titre]]
*
* La fonction cherche un élément de la forme
  * <span id="sous_titre_h1">Sous-titre</span>
  */
  */
var extraCSS = mw.util.getParamValue( 'withCSS' ),
extraJS = mw.util.getParamValue( 'withJS' );


function sousTitreH1( $content ) {
if ( extraCSS ) {
$( '#firstHeading > #sous_titre_h1' ).remove();
if ( extraCSS.match( /^MediaWiki:[^&<>=%#]*\.css$/ ) ) {
var $span = $content.find( '#sous_titre_h1' );
mw.loader.load( '/w/index.php?title=' + extraCSS + '&action=raw&ctype=text/css', 'text/css' );
if ( $span.length ) {
} else {
$span.prepend( ' ' );
mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withCSS value' } );
$( '#firstHeading' ).append( $span );
}
}
}
}
mw.hook( 'wikipage.content' ).add( sousTitreH1 );


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' } );
}
}


/**
/**
  * Boîtes déroulantes
  * WikiMiniAtlas
  *
  *
  * Pour [[Modèle:Méta palette de navigation]]
  * 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 Palette_Derouler = '[afficher]';
var require_wikiminiatlas = false;
var Palette_Enrouler = '[masquer]';
var coord_filter = /geohack/;
 
$( function () {
var Palette_max = 1;
$( 'a.external.text' ).each( function( key, link ) {
 
if ( link.href && coord_filter.exec( link.href ) ) {
function Palette_toggle( $table ) {
require_wikiminiatlas = true;
$table.find( 'tr:not(:first)' ).toggleClass( 'navboxHidden' );
// break from loop
}
return false;
 
}
function Palette( $content ) {
} );
 
if ( $( 'div.kmldata' ).length ) {
var $tables = $content.find( 'table.collapsible' );
require_wikiminiatlas = true;
var groups = {};
}
 
if ( require_wikiminiatlas ) {
$tables.each( function( _, table ) {
mw.loader.load( '//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript' );
var group = table.dataset.autocollapseGroup || '__default__';
}
groups[group] = ( groups[group] || 0 ) + 1;
} );
} );
} )();


$tables.each( function( _, table ) {
/**
var $table = $( table );
* Collapsible tables; reimplemented with mw-collapsibe
 
* Styling is also in place to avoid FOUC
var group = table.dataset.autocollapseGroup || '__default__';
*
var autoCollapse = groups[group] > Palette_max;
* Allows tables to be collapsed, showing only the header. See [[Help:Collapsing]].
var collapsed = $table.hasClass( 'collapsed' ) || ( autoCollapse && $table.hasClass( 'autocollapse' ) );
* @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' );


// le modèle dispose d'une classe "navbox-title",
$.each( $tables, function( index, table ) {
// sauf que les palettes "inlinées" (e.g. « {| class="navbox collapsible collapsed" ») n'ont pas cette classe
// mw.log.warn( 'This page is using the deprecated class collapsible. Please replace it with mw-collapsible.');
$table.find( 'tr:first th:first' ).prepend(
if( $( table ).hasClass( 'collapsed') ) {
$( '<span class="navboxToggle">\u00a0</span>' ).append(
$( table ).addClass( 'mw-collapsed' );
$( '<a href="javascript:">' + (collapsed ? Palette_Derouler : Palette_Enrouler) + '</a>' ).click( function ( e ) {
// mw.log.warn( 'This page is using the deprecated class collapsed. Please replace it with mw-collapsed.');
e.preventDefault();
if ( this.textContent === Palette_Enrouler ) {
this.textContent = Palette_Derouler;
} else {
this.textContent = Palette_Enrouler;
}
Palette_toggle( $table );
} )
)
);
if ( collapsed ) {
Palette_toggle( $table );
}
}
} );
} );
 
if( $tables.length > 0 ) {
// permet de dérouler/enrouler les palettes en cliquant n'importe où sur l'entête
mw.loader.using( 'jquery.makeCollapsible' ).then( function() {
// (utilisation de la classe "navbox-title", comme ça seules les vraies palettes utilisant le modèle sont ciblées)
$tables.makeCollapsible();
$content.find( '.navbox-title' )
} );
.click( function ( e ) {
}
if ( $( e.target ).closest( 'a' ).length ) {
return;
}
$( this ).find( '.navboxToggle a' ).click();
} )
.css( 'cursor', 'pointer' );
}
}
mw.hook( 'wikipage.content' ).add( Palette );
mw.hook( 'wikipage.content' ).add( makeCollapsibleMwCollapsible );
 


/**
/**
  * Pour [[Modèle:Boîte déroulante]]
  * Add support to mw-collapsible for autocollapse, innercollapse and outercollapse
*
* Maintainers: TheDJ
  */
  */
 
function mwCollapsibleSetup( $collapsibleContent ) {
var BoiteDeroulante_Derouler = '[afficher]';
var $element,
var BoiteDeroulante_Enrouler = '[masquer]';
$toggle,
 
autoCollapseThreshold = 2;
function BoiteDeroulante_toggle(NavToggle){
$.each( $collapsibleContent, function (index, element) {
var NavFrame = NavToggle.parentNode;
$element = $( element );
 
if ( $element.hasClass( 'collapsible' ) ) {
var caption = [];
$element.find('tr:first > th:first').prepend( $element.find('tr:first > * > .mw-collapsible-toggle'));
caption[0] = NavFrame.dataset.boiteDeroulanteDerouler;
caption[1] = NavFrame.dataset.boiteDeroulanteEnrouler;
 
var $NavContent = $(NavFrame).find('.NavContent').first();
 
if ( NavToggle.textContent === caption[1] ) {
NavToggle.textContent = caption[0];
$NavContent.hide();
} else {
NavToggle.textContent = caption[1];
$NavContent.show();
}
}
 
function BoiteDeroulante( $content ) {
 
$content.find( '.NavFrame' ).each( function ( _, NavFrame ) {
var CustomTexts, Derouler, Enrouler, NavToggle;
 
if (NavFrame.title && NavFrame.title.indexOf("/") !== -1) {
CustomTexts = NavFrame.title.split("/");
Derouler = CustomTexts[0];
Enrouler = CustomTexts[1];
} else {
Derouler = BoiteDeroulante_Derouler;
Enrouler = BoiteDeroulante_Enrouler;
}
}
NavFrame.title = '';
if ( $collapsibleContent.length >= autoCollapseThreshold && $element.hasClass( 'autocollapse' ) ) {
NavFrame.dataset.boiteDeroulanteDerouler = Derouler;
$element.data( 'mw-collapsible' ).collapse();
NavFrame.dataset.boiteDeroulanteEnrouler = Enrouler;
} else if ( $element.hasClass( 'innercollapse' ) ) {
 
if ( $element.parents( '.outercollapse' ).length > 0 ) {
NavToggle = document.createElement("a");
$element.data( 'mw-collapsible' ).collapse();
NavToggle.className = 'NavToggle';
NavToggle.href = 'javascript:';
NavToggle.onclick = function (e) {
e.preventDefault();
BoiteDeroulante_toggle(e.target);
};
NavToggle.textContent = Enrouler;
 
NavFrame.insertBefore(NavToggle, NavFrame.firstChild);
 
BoiteDeroulante_toggle(NavToggle);
} );
 
// permet de dérouler/enrouler les boîtes en cliquant n'importe où sur l'entête
$content.find( '.NavHead' )
.click( function ( e ) {
if ( $( e.target ).closest( 'a' ).length ) {
return;
}
}
var toggle = $( this ).siblings( 'a.NavToggle' )[0];
}
if ( toggle ) {
// because of colored backgrounds, style the link in the text color
toggle.click(); // pas du jquery, mais du vanilla js
// 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' );
}
}
} )
}
.css( 'cursor', 'pointer' );
} );
}
}


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


/**
/**
  * Fonctionnement du [[Modèle:Animation]]
  * Dynamic Navigation Bars (experimental)
  * Le JavaScript principal se situe dans [[MediaWiki:Gadget-Diaporama.js]]
*
* Description: See [[Wikipedia:NavFrame]].
  * Maintainers: UNMAINTAINED
  */
  */
mw.hook( 'wikipage.content' ).add( function ( $content ) {
if ( $content.find( '.diaporama' ).length ) {
var collapseCaption = 'hide';
mw.loader.using( 'ext.gadget.Diaporama', function () {
var expandCaption = 'show';
Diaporama_Init( $content );
} );
}
} );


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


/**
/**
  * Permet d'afficher les catégories cachées pour les contributeurs enregistrés, en ajoutant un (+) à la manière des boîtes déroulantes
  * 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 hiddencat( $ ) {
function toggleNavigationBar( indexNavigationBar, event ) {
if (mw.util.getParamValue('printable') === 'yes') {
var navToggle = document.getElementById( 'NavToggle' + indexNavigationBar );
return;
var navFrame = document.getElementById( 'NavFrame' + indexNavigationBar );
}
var navChild;
var cl = document.getElementById('catlinks');
if (!cl) {
return;
}
var $hc = $('#mw-hidden-catlinks');
if ( !$hc.length ) {
return;
}
if ( $hc.hasClass('mw-hidden-cats-user-shown') ) {
return;
}
if ( $hc.hasClass('mw-hidden-cats-ns-shown') ) {
$hc.addClass('mw-hidden-cats-hidden');
}
var nc = document.getElementById('mw-normal-catlinks');
if ( !nc ) {
var catline = document.createElement('div');
catline.id = 'mw-normal-catlinks';
var a = document.createElement('a');
a.href = '/wiki/Catégorie:Accueil';
a.title = 'Catégorie:Accueil';
a.appendChild(document.createTextNode('Catégories'));
catline.appendChild(a);
catline.appendChild(document.createTextNode(' : '));
nc = cl.insertBefore(catline, cl.firstChild);
}
var lnk = document.createElement('a');
lnk.id = 'mw-hidden-cats-link';
lnk.title = 'Cet article contient des catégories cachées';
lnk.style.cursor = 'pointer';
lnk.style.color = 'black';
lnk.style.marginLeft = '0.3em';
$(lnk).click(toggleHiddenCats);
lnk.appendChild(document.createTextNode('[+]'));
nc.appendChild(lnk);
}


function toggleHiddenCats(e) {
if ( !navFrame || !navToggle ) {
var $hc = $('#mw-hidden-catlinks');
return false;
if ( $hc.hasClass('mw-hidden-cats-hidden') ) {
$hc.removeClass('mw-hidden-cats-hidden');
$hc.addClass('mw-hidden-cat-user-shown');
$(e.target).text('[–]');
} else {
$hc.removeClass('mw-hidden-cat-user-shown');
$hc.addClass('mw-hidden-cats-hidden');
$(e.target).text('[+]');
}
}
}
mw.loader.using('mediawiki.util', function () {
$( hiddencat );
});
/**
* Script pour alterner entre plusieurs cartes de géolocalisation
*/
function GeoBox_Init($content){


$content.find( 'div.img_toogle' ).each( function ( i, Container ) {
// If shown now
Container.id = 'img_toogle_' + i;
if ( navToggle.firstChild.data === navigationBarHide ) {
var Boxes = $( Container ).find( '.geobox' );
for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {
var ToggleLinksDiv = document.createElement('ul');
if ( $( navChild ).hasClass( 'NavContent' ) ) {
ToggleLinksDiv.id = 'geoboxToggleLinks_' + i;
navChild.style.display = 'none';
Boxes.each( function ( a, ThisBox ) {
ThisBox.id = 'geobox_' + i + "_" + a;
ThisBox.style.borderTop='0';
var ThisAlt = ThisBox.getElementsByTagName('img')[0].alt;
var toggle = document.createElement('a');
toggle.id = 'geoboxToggle_' + i + "_" + a;
toggle.appendChild(document.createTextNode(ThisAlt));
toggle.href = 'javascript:';
toggle.onclick = function (e) {
e.preventDefault();
GeoBox_Toggle(this);
};
var Li = document.createElement('li');
Li.appendChild(toggle);
ToggleLinksDiv.appendChild(Li);
if (a === (Boxes.length - 1)) {
Li.style.display = "none";
} else {
ThisBox.style.display = "none";
}
}
} );
Container.appendChild(ToggleLinksDiv);
} );
}
function GeoBox_Toggle(link){
var ImgToggleIndex = link.id.replace('geoboxToggle_', '').replace(/_.*/g, "");
var GeoBoxIndex = link.id.replace(/.*_/g, "");
var ImageToggle = document.getElementById('img_toogle_' + ImgToggleIndex);
var Links = document.getElementById('geoboxToggleLinks_' + ImgToggleIndex);
var Geobox = document.getElementById('geobox_' + ImgToggleIndex + "_" + GeoBoxIndex);
var Link = document.getElementById('geoboxToggle_' + ImgToggleIndex + "_" + GeoBoxIndex);
if ( (!ImageToggle) || (!Links) || (!Geobox) || (!Link) ) {
return;
}
$( ImageToggle ).find( '.geobox' ).each( function ( _, ThisgeoBox ) {
if (ThisgeoBox.id === Geobox.id) {
ThisgeoBox.style.display = "";
} else {
ThisgeoBox.style.display = "none";
}
}
} );
navToggle.firstChild.data = navigationBarShow;
$( Links ).find( 'a' ).each( function ( _, thisToggleLink ) {
if (thisToggleLink.id === Link.id){
// If hidden now
thisToggleLink.parentNode.style.display = "none";
} else if ( navToggle.firstChild.data === navigationBarShow ) {
} else {
for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {
thisToggleLink.parentNode.style.display = "";
if ( $( navChild ).hasClass( 'NavContent' ) ) {
navChild.style.display = 'block';
}
}
}
} );
navToggle.firstChild.data = navigationBarHide;
}
}


mw.hook( 'wikipage.content' ).add( GeoBox_Init );
event.preventDefault();
 
 
/**
* permet d'ajouter un petit lien (par exemple d'aide) à la fin du titre d'une page.
* utilisé par [[Modèle:Aide contextuelle]]
* known bug : conflit avec le changement de titre classique.
* Pour les commentaires, merci de contacter [[user:Plyd|Plyd]].
*/
function rewritePageH1bis() {
var helpPage = document.getElementById("helpPage");
if (helpPage) {
var h1 = document.getElementById('firstHeading');
if (h1) {
h1.innerHTML += '<span id="h1-helpPage">' + helpPage.innerHTML + '</span>';
}
}
}
}
$( rewritePageH1bis );
/**
* Configuration du tri des diacritique dans les tables de class "sortable"
*/
mw.config.set( 'tableSorterCollation', {'à':'a', 'â':'a', 'æ':'ae', 'é':'e', 'è':'e', 'ê':'e', 'î':'i', 'ï':'i', 'ô':'o', 'œ':'oe', 'û':'u', 'ç':'c',  } );


/**
/**
  * Direct imagelinks to Commons
  * Adds show/hide-button to navigation bars.
*
* Required modules: mediawiki.RegExp, mediawiki.util, user.options
  *
  *
  * @source www.mediawiki.org/wiki/Snippets/Direct_imagelinks_to_Commons
  * @param {jQuery} $content
* @author Krinkle
* @version 2015-06-23
* Ajouté le 'uselang' ce 18 janvier 2016 — Ltrlg
  */
  */
if ( mw.config.get( 'wgNamespaceNumber' ) >= 0 ) {
function createNavigationBarToggleButton( $content ) {
mw.loader.using( [ 'mediawiki.RegExp', 'mediawiki.util', 'user.options' ] ).done(function(){
var i, j, navChild, navToggle, navToggleText, isCollapsed,
mw.hook( 'wikipage.content' ).add( function ( $content ) {
indexNavigationBar = 0;
var
// Iterate over all < div >-elements
uploadBase = '//upload.wikimedia.org/wikipedia/commons/',
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 ) );


fileNamespace = mw.config.get( 'wgFormattedNamespaces' )['6'],
isCollapsed = $( navFrame ).hasClass( 'collapsed' );
localBasePath = new RegExp( '^' + mw.RegExp.escape( mw.util.getUrl( fileNamespace + ':' ) ) ),
/**
localBaseScript = new RegExp( '^' + mw.RegExp.escape( mw.util.wikiScript() + '?title=' + mw.util.wikiUrlencode( fileNamespace + ':' ) ) ),
* 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"
commonsBasePath = '//commons.wikimedia.org/wiki/File:',
* to all the NavPic/NavContent elements. Since this was bad for accessibility (no way to make
commonsBaseScript = '//commons.wikimedia.org/w/index.php?title=File:',
* 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.
lang = mw.user.options.get( 'language' );
*/
 
for ( navChild = navFrame.firstChild; navChild !== null && !isCollapsed; navChild = navChild.nextSibling ) {
$content.find( 'a.image' ).attr( 'href', function ( i, currVal ) {
if ( $( navChild ).hasClass( 'NavPic' ) || $( navChild ).hasClass( 'NavContent' ) ) {
if ( $( this ).find( 'img' ).attr( 'src' ).indexOf( uploadBase ) === 0 ) {
if ( navChild.style.display === 'none' ) {
if ( localBasePath.test( currVal ) ) {
isCollapsed = true;
return currVal.replace( localBasePath, commonsBasePath ) + '?uselang=' + lang;
}
} else if ( localBaseScript.test( currVal ) ) {
}
return currVal.replace( localBaseScript, commonsBaseScript ) + '&uselang=' + lang;
}
} else {
if ( isCollapsed ) {
return currVal;
for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {
}
if ( $( navChild ).hasClass( 'NavPic' ) || $( navChild ).hasClass( 'NavContent' ) ) {
navChild.style.display = 'none';
}
}
} );
}
} );
} );
}
 
/**
* Ajout d'un lien « ajouter une section » en bas de page
*/
if ( mw.config.get( 'wgAction' ) === 'view' ) {
$( function( $ ) {
var $newSectionLink = $( '#ca-addsection' ).find( 'a' );
if ( $newSectionLink.length ) {
$( '#mw-content-text' ).append(
'<div style="text-align:right; font-size:0.9em; margin:1em 0 -0.5em">'
+ '<a href="' + $newSectionLink.attr( 'href' ) + '" title="Commencer une nouvelle section">Ajouter un sujet</a>'
+ '</div>'
);
}
}
} );
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)
* Repositionnement de la page sur l'ancre avec laquelle elle a été appelée
for ( j = 0; j < navFrame.childNodes.length; j++ ) {
* après le repli des boîtes déroulantes, entre autres.
if ( $( navFrame.childNodes[j] ).hasClass( 'NavHead' ) ) {
*/
navToggle.style.color = navFrame.childNodes[j].style.color;
if ( window.location.hash ) {
navFrame.childNodes[j].appendChild( navToggle );
$( function ( $ ) {
setTimeout( function () {
var currentTarget = document.getElementById( decodeURIComponent( window.location.hash.substring( 1 ) ) );
if ( currentTarget ) {
currentTarget.scrollIntoView();
}
}
}, 1 );
}
navFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar );
} );
} );
}
}


 
mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton );
/************************************************************/
/* Function Strictement spécifiques à un espace de nom ou à une page */
/************************************************************/
 
// ESPACE DE NOM 'SPECIAL'
if ( mw.config.get( 'wgNamespaceNumber' ) === -1 ) {


/**
/**
  * Ajoute le namespace aux filtres personnalisés sur [[Spécial:Pages liées]]
  * Magic editintros ****************************************************
  * Voir aussi [[MediaWiki:Linkshere]]
*
* Description: Adds editintros on disambiguation pages and BLP pages.
  * Maintainers: [[User:RockMFR]]
  */
  */
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Whatlinkshere' ) {
function addEditIntro( name ) {
 
$( '.mw-editsection, #ca-edit, #ca-ve-edit' ).find( 'a' ).each( function ( i, el ) {
mw.loader.using( 'mediawiki.Uri', function () {
el.href = $( this ).attr( 'href' ) + '&editintro=' + name;
$( function ( $ ) {
 
var query = ( new mw.Uri( null, { overrideKeys: true } ) ).query;
 
var append = ( query.namespace ? '&namespace=' + encodeURIComponent( query.namespace ) : '' )
+ ( query.invert ? '&invert=' + encodeURIComponent( query.invert ) : '' );
 
if ( append !== '' ) {
$( '#whatlinkshere-customfilters' ).find( 'a' ).each( function () {
this.href += append;
} );
}
} );
} );
} );
}
}


/**
if ( mw.config.get( 'wgNamespaceNumber' ) === 0 ) {
* Affiche un modèle Information sur la page de téléchargement de fichiers [[Spécial:Téléchargement]]
$( function () {
* Voir aussi [[MediaWiki:Onlyifuploading.js]]
if ( document.getElementById( 'disambigbox' ) ) {
*/
addEditIntro( 'Template:Disambig_editintro' );
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Upload' ) {
}
importScript( 'MediaWiki:Onlyifuploading.js' );
} );
}


/**
$( function () {
* Supprime de la liste des balises disponibles et de la liste des balises supprimables
var cats = mw.config.get('wgCategories');
* certaines balises réservées à des outils automatiques
if ( !cats ) {
*/
return;
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'EditTags' ) {
}
importScript( 'MediaWiki:Common.js/EditTags.js' );
if ( $.inArray( 'Living people', cats ) !== -1 || $.inArray( 'Possibly living people', cats ) !== -1 ) {
addEditIntro( 'Template:BLP_editintro' );
}
} );
}
}


} // Fin du code concernant l'espace de nom 'Special'
/* Actions specific to the edit page */
 
if ( mw.config.get( 'wgAction' ) === 'edit' || mw.config.get( 'wgAction' ) === 'submit' ) {
 
/**
// ESPACE DE NOM 'UTILISATEUR'
* Fix edit summary prompt for undo
if ( mw.config.get( 'wgNamespaceNumber' ) === 2 ) {
*
 
* Fixes the fact that the undo function combined with the "no edit summary prompter"
/*
*  complains about missing editsummary, if leaving the edit summary unchanged.
* Fonctionnement du [[Modèle:Cadre à onglets]]
*  Added by [[User:Deskana]], code by [[User:Tra]].
* Le JavaScript principal se situe dans [[MediaWiki:Gadget-CadreOnglets.js]]
*  See also [[phab:T10912]].
*/
*/
mw.hook( 'wikipage.content' ).add( function ( $content ) {
$(function () {
if ( $content.find( '.cadre_a_onglets' ).length ) {
if (document.location.search.indexOf('undo=') !== -1 && document.getElementsByName('wpAutoSummary')[0]) {
mw.loader.using( 'ext.gadget.CadreOnglets', function () {
document.getElementsByName('wpAutoSummary')[0].value = '1';
CadreOnglets_Init( $content );
} );
}
} );
 
} // Fin du code concernant l'espace de nom 'Utilisateur'
 
 
// ESPACE DE NOM 'RÉFÉRENCE'
if ( mw.config.get( 'wgNamespaceNumber' ) === 104 ) {
 
/*
* Choix du mode d'affichage des références
* @note L'ordre de cette liste doit correspondre a celui de Modèle:Édition !
  */
 
var addBibSubsetMenu = function ( $content ) {
var $specialBib = $content.find( '#specialBib' );
if ( !$specialBib.length ) {
return;
}
 
// select subsection of special characters
var chooseBibSubset = function ( s ) {
$content.find( '.edition-Liste' ).css( 'display', s === 0 ? 'block' : 'none' );
$content.find( '.edition-WikiNorme' ).css( 'display', s === 1 ? 'block' : 'none' );
$content.find( '.edition-BibTeX' ).css( 'display', s === 2 ? 'block' : 'none' );
$content.find( '.edition-ISBD' ).css( 'display', s === 3 ? 'block' : 'none' );
$content.find( '.edition-ISO690' ).css( 'display', s === 4 ? 'block' : 'none' );
};
 
var $menu = $( '<select>' )
.css( 'display', 'inline' )
.change( function () {
chooseBibSubset( this.selectedIndex );
} )
.append(
$( '<option>' ).text( 'Liste' ),
$( '<option>' ).text( 'WikiNorme' ),
$( '<option>' ).text( 'BibTeX' ),
$( '<option>' ).text( 'ISBD' ),
$( '<option>' ).text( 'ISO690' )
);
 
$specialBib.append( $menu );
 
/* default subset - try to use a cookie some day */
chooseBibSubset( 0 );
};
 
mw.hook( 'wikipage.content' ).add( addBibSubsetMenu );
 
} // Fin du code concernant l'espace de nom 'Référence'
 
 
// PAGES SPÉCIFIQUES
 
// Personnalisation des liens dans les pages d'aide selon un paramètre de l'URL.
// Utilisé par [[Aide:Comment créer un article/publier]].
function ReplaceSourcePageInLinks() {
var match = window.location.search.match( /[?&]sourcepage=([^&]*)/ );
if ( !match ) {
return;
}
var page = decodeURIComponent( match[1] );
$( '.sourcepage-subst a' ).each( function() {
if ( /^(https?:)?\/\/[^/]+\.wikipedia\.org\//.test( this.href ) ) {
this.href = this.href.replace( 'TITRE-A-REMPLACER', encodeURIComponent( page ) );
}
}
} );
});
}
}


if ( mw.config.get( 'wgPageName' ) === 'Aide:Comment_créer_un_article/publier' ) {
/* End of mw.loader.using callback */
$( ReplaceSourcePageInLinks );
} );
}
/* DO NOT ADD CODE BELOW THIS LINE */

Version du 19 mars 2019 à 17:20

/**
 * 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 */