/*!
* Live edit preview.
*/
-( function ( mw, $ ) {
+( function () {
/**
* @ignore
rvdifftotext: $textbox.textSelection( 'getContents' ),
rvdifftotextpst: true,
rvprop: '',
- rvsection: section === '' ? undefined : section
+ rvsection: section === '' ? undefined : section,
+ uselang: mw.config.get( 'wgUserLanguage' )
} );
// Wait for the summary before showing the diff so the page doesn't jump twice
parseRequest = api.post( postData );
parseRequest.done( function ( response ) {
- var li, newList, $displaytitle, $content, $parent, $list;
+ var newList, $displaytitle, $content, $parent, $list;
if ( response.parse.jsconfigvars ) {
mw.config.set( response.parse.jsconfigvars );
}
}
newList = [];
+ // eslint-disable-next-line no-restricted-properties
$.each( response.parse.indicators, function ( name, indicator ) {
newList.push(
$( '<div>' )
$( '.catlinks[data-mw="interface"]' ).replaceWith( $content );
}
if ( response.parse.templates ) {
- newList = [];
- $.each( response.parse.templates, function ( i, template ) {
- li = $( '<li>' )
+ newList = response.parse.templates.map( function ( template ) {
+ return $( '<li>' )
.append( $( '<a>' )
.attr( {
href: mw.util.getUrl( template.title ),
} )
.text( template.title )
);
- newList.push( li );
} );
$editform.find( '.templatesUsed .mw-editfooter-list' ).detach().empty().append( newList ).appendTo( '.templatesUsed' );
$( '.limitreport' ).html( response.parse.limitreporthtml );
}
if ( response.parse.langlinks && mw.config.get( 'skin' ) === 'vector' ) {
- newList = [];
- $.each( response.parse.langlinks, function ( i, langlink ) {
- li = $( '<li>' )
+ newList = response.parse.langlinks.map( function ( langlink ) {
+ var bcp47 = mw.language.bcp47( langlink.lang );
+ return $( '<li>' )
.addClass( 'interlanguage-link interwiki-' + langlink.lang )
.append( $( '<a>' )
.attr( {
href: langlink.url,
title: langlink.title + ' - ' + langlink.langname,
- lang: langlink.lang,
- hreflang: langlink.lang
+ lang: bcp47,
+ hreflang: bcp47
} )
.text( langlink.autonym )
);
- newList.push( li );
} );
$list = $( '#p-lang ul' );
$parent = $list.parent();
$( document.body ).on( 'click', '#wpPreview, #wpDiff', doLivePreview );
} );
-}( mediaWiki, jQuery ) );
+}() );