*/
( function ( mw, $ ) {
- var oojsuieditform;
-
/**
* @ignore
* @param {jQuery.Event} e
*/
function doLivePreview( e ) {
var isDiff, api, parseRequest, diffRequest, postData, copySelectors, section, summary,
- $wikiPreview, $wikiDiff, $editform, $textbox, $summary, $copyElements, $spinner, $errorBox;
+ $wikiPreview, $wikiDiff, $editform, $textbox, $copyElements, $spinner, $errorBox;
isDiff = ( e.target.name === 'wpDiff' );
$wikiPreview = $( '#wikiPreview' );
$editform = $( '#editform' );
$textbox = $editform.find( '#wpTextbox1' );
- if ( oojsuieditform ) {
- summary = OO.ui.infuse( $( '#wpSummaryWidget' ) );
- } else {
- $summary = $editform.find( '#wpSummary' );
- }
+ summary = OO.ui.infuse( $( '#wpSummaryWidget' ) );
$spinner = $( '.mw-spinner-preview' );
$errorBox = $( '.errorbox' );
formatversion: 2,
action: 'parse',
title: mw.config.get( 'wgPageName' ),
- summary: oojsuieditform ? summary.getValue() : $summary.val(),
+ 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 );
}
$( '.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();
}
$( function () {
- oojsuieditform = $( '#editform' ).hasClass( 'mw-editform-ooui' );
-
// Do not enable on user .js/.css pages, as there's no sane way of "previewing"
// the scripts or styles without reloading the page.
if ( $( '#mw-userjsyoucanpreview' ).length || $( '#mw-usercssyoucanpreview' ).length ) {
}
if ( !$( '.mw-summary-preview' ).length ) {
- $( oojsuieditform ? '#wpSummaryWidget' : '#wpSummary' ).after(
+ $( '#wpSummaryWidget' ).after(
$( '<div>' ).addClass( 'mw-summary-preview' )
);
}