e.preventDefault();
$( mw ).trigger( 'LivePreviewPrepare' );
-
+
var postData = $('#editform').formToArray();
postData.push( { 'name' : 'wpPreview', 'value' : '1' } );
-
+
// Hide active diff, used templates, old preview if shown
var copyElements = ['#wikiPreview', '.templatesUsed', '.hiddencats',
'#catlinks'];
var copySelector = copyElements.join(',');
$.each( copyElements, function(k,v) { $(v).fadeOut('fast'); } );
-
+
// Display a loading graphic
var loadSpinner = $('<div class="mw-ajax-loader"/>');
$('#wikiPreview').before( loadSpinner );
-
+
var page = $('<div/>');
var target = $('#editform').attr('action');
-
+
if ( !target ) {
target = window.location.href;
}
-
+
page.load( target + ' ' + copySelector, postData,
function() {
-
+
for( var i=0; i<copyElements.length; ++i) {
// For all the specified elements, find the elements in the loaded page
// and the real page, empty the element in the real page, and fill it
var newClasses = page.find( copyElements[i] ).attr('class');
$(copyElements[i]).attr( 'class', newClasses );
}
-
+
$.each( copyElements, function(k,v) {
// Don't belligerently show elements that are supposed to be hidden
$(v).fadeIn( 'fast', function() { $(this).css('display', ''); } );
} );
-
+
loadSpinner.remove();
$( mw ).trigger( 'LivePreviewDone', [copyElements] );