/*!
* Live edit preview.
*/
-( function ( mw, $ ) {
+( function () {
/**
* @ignore
* @param {jQuery.Event} e
*/
function doLivePreview( e ) {
- var isDiff, api, parseRequest, diffRequest, postData, copySelectors, section,
- $wikiPreview, $wikiDiff, $editform, $textbox, $summary, $copyElements, $spinner, $errorBox;
+ var isDiff, api, parseRequest, diffRequest, postData, copySelectors, section, summary,
+ $wikiPreview, $wikiDiff, $editform, $textbox, $copyElements, $spinner, $errorBox;
isDiff = ( e.target.name === 'wpDiff' );
$wikiPreview = $( '#wikiPreview' );
$wikiDiff = $( '#wikiDiff' );
$editform = $( '#editform' );
$textbox = $editform.find( '#wpTextbox1' );
- $summary = $editform.find( '#wpSummary' );
+
+ summary = OO.ui.infuse( $( '#wpSummaryWidget' ) );
+
$spinner = $( '.mw-spinner-preview' );
$errorBox = $( '.errorbox' );
section = $editform.find( '[name="wpSection"]' ).val();
formatversion: 2,
action: 'parse',
title: mw.config.get( 'wgPageName' ),
- summary: $summary.textSelection( 'getContents' ),
+ summary: summary.getValue(),
prop: ''
};
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();
}
if ( !$( '.mw-summary-preview' ).length ) {
- $( '#wpSummary' ).after(
+ $( '#wpSummaryWidget' ).after(
$( '<div>' ).addClass( 'mw-summary-preview' )
);
}
$( document.body ).on( 'click', '#wpPreview, #wpDiff', doLivePreview );
} );
-}( mediaWiki, jQuery ) );
+}() );