Remove duplicate startSanityCheck from ViewPageTarget

Method was moved to parent, but not deleted from child. Also move
sanityCheckPromise to parent where it is used.

Change-Id: Ie2b00330d796cd089fd4bc84d9332c316500633f
This commit is contained in:
Ed Sanders 2014-11-27 20:43:50 +00:00 committed by Catrope
parent 15ed437331
commit 7dc4dd66a0
2 changed files with 5 additions and 61 deletions

View file

@ -60,11 +60,6 @@ ve.init.mw.ViewPageTarget = function VeInitMwViewPageTarget() {
this.originalDocumentTitle = document.title; this.originalDocumentTitle = document.title;
this.tabLayout = mw.config.get( 'wgVisualEditorConfig' ).tabLayout; this.tabLayout = mw.config.get( 'wgVisualEditorConfig' ).tabLayout;
/**
* @property {jQuery.Promise|null}
*/
this.sanityCheckPromise = null;
// Add modules specific to desktop (modules shared with mobile go in MWTarget) // Add modules specific to desktop (modules shared with mobile go in MWTarget)
this.modules.push( this.modules.push(
'ext.visualEditor.mwformatting', 'ext.visualEditor.mwformatting',
@ -989,62 +984,6 @@ ve.init.mw.ViewPageTarget.prototype.getSaveOptions = function () {
return options; return options;
}; };
/**
* Fire off the sanity check. Must be called before the surface is activated.
*
* To access the result, check whether #sanityCheckPromise has been resolved or rejected
* (it's asynchronous, so it may still be pending when you check).
*/
ve.init.mw.ViewPageTarget.prototype.startSanityCheck = function () {
// We have to get a copy of the data now, before we unlock the surface and let the user edit,
// but we can defer the actual conversion and comparison
var viewPage = this,
doc = viewPage.surface.getModel().getDocument(),
data = new ve.dm.FlatLinearData( doc.getStore().clone(), ve.copy( doc.getFullData() ) ),
oldDom = viewPage.doc,
d = $.Deferred();
// Reset
viewPage.sanityCheckFinished = false;
viewPage.sanityCheckVerified = false;
setTimeout( function () {
// We can't compare oldDom.body and newDom.body directly, because the attributes on the
// <body> were ignored in the conversion. So compare each child separately.
var i,
len = oldDom.body.childNodes.length,
newDoc = new ve.dm.Document( data, oldDom, undefined, doc.getInternalList(), doc.getInnerWhitespace(), doc.getLang(), doc.getDir() ),
newDom = ve.dm.converter.getDomFromModel( newDoc );
// Explicitly unlink our full copy of the original version of the document data
data = undefined;
if ( len !== newDom.body.childNodes.length ) {
// Different number of children, so they're definitely different
d.reject();
return;
}
for ( i = 0; i < len; i++ ) {
if ( !oldDom.body.childNodes[i].isEqualNode( newDom.body.childNodes[i] ) ) {
d.reject();
return;
}
}
d.resolve();
} );
viewPage.sanityCheckPromise = d.promise()
.done( function () {
// If we detect no roundtrip errors,
// don't emphasize "review changes" to the user.
viewPage.sanityCheckVerified = true;
})
.always( function () {
viewPage.sanityCheckFinished = true;
viewPage.updateToolbarSaveButtonState();
} );
};
/** /**
* Switch to viewing mode. * Switch to viewing mode.
* *

View file

@ -40,6 +40,11 @@ ve.init.mw.Target = function VeInitMwTarget( $container, pageName, revisionId )
.extend( { action: 'submit' } ); .extend( { action: 'submit' } );
this.events = new ve.init.mw.TargetEvents( this ); this.events = new ve.init.mw.TargetEvents( this );
/**
* @property {jQuery.Promise|null}
*/
this.sanityCheckPromise = null;
this.modules = [ this.modules = [
'ext.visualEditor.mwcore', 'ext.visualEditor.mwcore',
'ext.visualEditor.mwlink', 'ext.visualEditor.mwlink',