Merge "Remove unused 'XMPGetInfo' and 'XMPGetResults' hooks"
[lhc/web/wiklou.git] / resources / src / mediawiki.action / mediawiki.action.edit.preview.js
index 3a6110d..5074d94 100644 (file)
@@ -9,15 +9,20 @@
         */
        function doLivePreview( e ) {
                var isDiff, api, request, postData, copySelectors, section,
-                       $wikiPreview, $wikiDiff, $editform, $copyElements, $spinner, $errorBox;
+                       $wikiPreview, $wikiDiff, $editform, $textbox, $summary, $copyElements, $spinner, $errorBox;
 
                isDiff = ( e.target.name === 'wpDiff' );
                $wikiPreview = $( '#wikiPreview' );
                $wikiDiff = $( '#wikiDiff' );
                $editform = $( '#editform' );
+               $textbox = $editform.find( '#wpTextbox1' );
+               $summary = $editform.find( '#wpSummary' );
                $errorBox = $( '.errorbox' );
                section = $editform.find( '[name="wpSection"]' ).val();
 
+               if ( $textbox.length === 0 ) {
+                       return;
+               }
                // Show changes for a new section is not yet supported
                if ( isDiff && section === 'new' ) {
                        return;
@@ -68,8 +73,8 @@
                        action: 'parse',
                        uselang: mw.config.get( 'wgUserLanguage' ),
                        title: mw.config.get( 'wgPageName' ),
-                       text: $editform.find( '#wpTextbox1' ).textSelection( 'getContents' ),
-                       summary: $editform.find( '#wpSummary' ).textSelection( 'getContents' )
+                       text: $textbox.textSelection( 'getContents' ),
+                       summary: $summary.textSelection( 'getContents' )
                };
 
                if ( section !== '' ) {
                        $.extend( postData, {
                                pst: '',
                                preview: '',
-                               prop: 'text|displaytitle|modules|categorieshtml|templates|langlinks|limitreporthtml',
+                               prop: 'text|displaytitle|modules|jsconfigvars|categorieshtml|templates|langlinks|limitreporthtml',
                                disableeditsection: true
                        } );
                        request = api.post( postData );
                        request.done( function ( response ) {
                                var li, newList, $displaytitle, $content, $parent, $list;
+                               if ( response.parse.jsconfigvars ) {
+                                       mw.config.set( response.parse.jsconfigvars );
+                               }
                                if ( response.parse.modules ) {
                                        mw.loader.load( response.parse.modules.concat(
                                                response.parse.modulescripts,
                                                newList.push( li );
                                        } );
 
-                                       $editform.find( '.mw-editfooter-list' ).detach().empty().append( newList ).appendTo( '.templatesUsed' );
+                                       $editform.find( '.templatesUsed .mw-editfooter-list' ).detach().empty().append( newList ).appendTo( '.templatesUsed' );
                                }
                                if ( response.parse.limitreporthtml ) {
                                        $( '.limitreport' ).html( response.parse.limitreporthtml['*'] );
        $( function () {
                // Do not enable on user .js/.css pages, as there's no sane way of "previewing"
                // the scripts or styles without reloading the page.
-               // Do not enable for ProofreadPage Index page editors, which have no textbox
-               if ( $( '#mw-userjsyoucanpreview' ).length || $( '#mw-usercssyoucanpreview' ).length || $( '#wpTextbox1' ).length === 0 ) {
+               if ( $( '#mw-userjsyoucanpreview' ).length || $( '#mw-usercssyoucanpreview' ).length ) {
                        return;
                }