(bug 39273) add diff support to LivePreview
authorMatmaRex <matma.rex@gmail.com>
Thu, 23 Aug 2012 22:56:50 +0000 (00:56 +0200)
committerMatmaRex <matma.rex@gmail.com>
Wed, 29 Aug 2012 17:59:18 +0000 (19:59 +0200)
Now both "Show preview" and "Show changes" result in an AJAX call;
previously, "Show changes" would just reload the form as usual, and
LivePreview wouldn't handle the #wikiDiff element at all, which resulted
in both the new preview and stale diff being shown.

We load the diff styles using mw.loader.load if necessary (which will
probably be basically always).

Change-Id: Iaf9edf947e019ec7fa949d664b46b88161235b41

RELEASE-NOTES-1.20
skins/common/preview.js

index cdd2707..b192a11 100644 (file)
@@ -134,6 +134,7 @@ upgrade PHP if you have not done so prior to upgrading MediaWiki.
 * SVG files will now show the actual width in the SVG's specified units
   in the metadata box.
 * Added ResourceLoader module "jquery.jStorage".
+* (bug 39273) Added AJAX support for "Show changes" (diff) in LivePreview.
 
 === Bug fixes in 1.20 ===
 * (bug 30245) Use the correct way to construct a log page title.
@@ -225,6 +226,7 @@ upgrade PHP if you have not done so prior to upgrading MediaWiki.
 * (bug 27111) Cascading foreign file repos now fetch shared descriptions properly.
 * EXIF below sea level GPS altitude data is now shown correctly.
 * (bug 39284) jquery.tablesorter should not consider "."" or "?"" to be a currency.
+* (bug 39273) "Show changes" should not be incorrectly displayed in the Live Preview state.
 
 === API changes in 1.20 ===
 * (bug 34316) Add ability to retrieve maximum upload size from MediaWiki API.
index a332a8e..823d467 100644 (file)
@@ -8,10 +8,10 @@
                $( mw ).trigger( 'LivePreviewPrepare' );
 
                var postData = $('#editform').formToArray();
-               postData.push( { 'name' : 'wpPreview', 'value' : '1' } );
+               postData.push( { 'name' : e.target.name, 'value' : '1' } );
 
                // Hide active diff, used templates, old preview if shown
-               var copyElements = ['#wikiPreview', '.templatesUsed', '.hiddencats',
+               var copyElements = ['#wikiPreview', '#wikiDiff', '.templatesUsed', '.hiddencats',
                                                        '#catlinks', '#p-lang', '.mw-summary-preview'];
                var copySelector = copyElements.join(',');
 
                        $( '.editCheckboxes' ).before( $( '<div>' ).addClass( 'mw-summary-preview' ) );
                }
 
-               $( '#wpPreview' ).click( doLivePreview );
+               // construct space for diff if missing. also load diff styles.
+               if ( !document.getElementById( 'wikiDiff' ) && document.getElementById( 'wikiPreview' ) ) {
+                       $( '#wikiPreview' ).after( $( '<div>' ).attr( 'id', 'wikiDiff' ) );
+                       // diff styles are by default only loaded when needed
+                       // if there was no diff container, we can expect the styles not to be there either
+                       mw.loader.load( 'mediawiki.action.history.diff' );
+               }
+
+               $( '#wpPreview, #wpDiff' ).click( doLivePreview );
        } );
 }) ( jQuery );