$wikiPreview[0].scrollIntoView();
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',
- '#catlinks'];
+ var copyElements = ['#wikiPreview', '#wikiDiff', '.templatesUsed', '.hiddencats',
+ '#catlinks', '#p-lang', '.mw-summary-preview'];
var copySelector = copyElements.join(',');
$.each( copyElements, function( k, v ) {
};
$(document).ready( function() {
- $('#wpPreview').click( doLivePreview );
+ // construct space for interwiki links if missing
+ // (it is usually not shown when action=edit, but shown if action=submit)
+ if ( !document.getElementById( 'p-lang' ) && document.getElementById( 'p-tb' ) ) {
+ // we need not hide this, because it's empty anyway
+ $( '#p-tb' ).after( $( '<div>' ).attr( 'id', 'p-lang' ) );
+ }
+
+ // construct space for summary preview if missing
+ if ( $( '.mw-summary-preview' ).length === 0 ) {
+ $( '.editCheckboxes' ).before( $( '<div>' ).addClass( 'mw-summary-preview' ) );
+ }
+
+ // 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 );