resources: Strip '$' and 'mw' from file closures
[lhc/web/wiklou.git] / resources / src / mediawiki.action / mediawiki.action.edit.preview.js
index ab1ce27..b90427e 100644 (file)
@@ -1,7 +1,7 @@
 /*!
  * Live edit preview.
  */
-( function ( mw, $ ) {
+( function () {
 
        /**
         * @ignore
@@ -99,7 +99,8 @@
                                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 ) {
+                                       newList = response.parse.langlinks.map( function ( langlink ) {
                                                var bcp47 = mw.language.bcp47( langlink.lang );
-                                               li = $( '<li>' )
+                                               return $( '<li>' )
                                                        .addClass( 'interlanguage-link interwiki-' + langlink.lang )
                                                        .append( $( '<a>' )
                                                                .attr( {
                                                                } )
                                                                .text( langlink.autonym )
                                                        );
-                                               newList.push( li );
                                        } );
                                        $list = $( '#p-lang ul' );
                                        $parent = $list.parent();
                $( document.body ).on( 'click', '#wpPreview, #wpDiff', doLivePreview );
        } );
 
-}( mediaWiki, jQuery ) );
+}() );