From 7dc4dd66a07ec19f19925a940ae0f564e60d5ad5 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Thu, 27 Nov 2014 20:43:50 +0000 Subject: [PATCH] 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 --- .../init/targets/ve.init.mw.ViewPageTarget.js | 61 ------------------- modules/ve-mw/init/ve.init.mw.Target.js | 5 ++ 2 files changed, 5 insertions(+), 61 deletions(-) diff --git a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js index b79fdfc241..32af43db6c 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js +++ b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js @@ -60,11 +60,6 @@ ve.init.mw.ViewPageTarget = function VeInitMwViewPageTarget() { this.originalDocumentTitle = document.title; 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) this.modules.push( 'ext.visualEditor.mwformatting', @@ -989,62 +984,6 @@ ve.init.mw.ViewPageTarget.prototype.getSaveOptions = function () { 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 - // 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. * diff --git a/modules/ve-mw/init/ve.init.mw.Target.js b/modules/ve-mw/init/ve.init.mw.Target.js index 733a41c7a3..775ff68253 100644 --- a/modules/ve-mw/init/ve.init.mw.Target.js +++ b/modules/ve-mw/init/ve.init.mw.Target.js @@ -40,6 +40,11 @@ ve.init.mw.Target = function VeInitMwTarget( $container, pageName, revisionId ) .extend( { action: 'submit' } ); this.events = new ve.init.mw.TargetEvents( this ); + /** + * @property {jQuery.Promise|null} + */ + this.sanityCheckPromise = null; + this.modules = [ 'ext.visualEditor.mwcore', 'ext.visualEditor.mwlink',