mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 02:23:58 +00:00
Merge "DesktopArticleTarget.init: Wait for deactivating to finish before activating"
This commit is contained in:
commit
82051a35d3
|
@ -32,6 +32,7 @@ ve.init.mw.DesktopArticleTarget = function VeInitMwDesktopArticleTarget( config
|
|||
this.onUnloadHandler = this.onUnload.bind( this );
|
||||
this.activating = false;
|
||||
this.deactivating = false;
|
||||
this.deactivatingDeferred = null;
|
||||
this.recreating = false;
|
||||
this.activatingDeferred = null;
|
||||
this.toolbarSetupDeferred = null;
|
||||
|
@ -575,8 +576,6 @@ ve.init.mw.DesktopArticleTarget.prototype.teardown = function ( trackMechanism )
|
|||
saveDialogPromise = ve.createDeferred().resolve().promise(),
|
||||
target = this;
|
||||
|
||||
this.emit( 'deactivate' );
|
||||
|
||||
// Event tracking
|
||||
var abortType, abortedMode;
|
||||
if ( trackMechanism ) {
|
||||
|
@ -596,10 +595,13 @@ ve.init.mw.DesktopArticleTarget.prototype.teardown = function ( trackMechanism )
|
|||
|
||||
// Cancel activating, start deactivating
|
||||
this.deactivating = true;
|
||||
this.deactivatingDeferred = ve.createDeferred();
|
||||
this.activating = false;
|
||||
this.activatingDeferred.reject();
|
||||
$( 'html' ).addClass( 've-deactivating' ).removeClass( 've-activated ve-active' );
|
||||
|
||||
this.emit( 'deactivate' );
|
||||
|
||||
// Restore TemplateStyles of the original content
|
||||
// (We do this here because toggling 've-active' class above displays it)
|
||||
this.$editableContent.find( 'style[data-mw-deduplicate^="TemplateStyles:"]' ).prop( 'disabled', false );
|
||||
|
@ -642,15 +644,16 @@ ve.init.mw.DesktopArticleTarget.prototype.teardown = function ( trackMechanism )
|
|||
target.initialEditSummary = new mw.Uri().query.summary;
|
||||
target.editSummaryValue = null;
|
||||
|
||||
target.deactivating = false;
|
||||
$( 'html' ).removeClass( 've-deactivating' );
|
||||
|
||||
// Move original content back out of the target
|
||||
target.$element.parent().append( target.$originalContent.children() );
|
||||
|
||||
$( '.ve-init-mw-desktopArticleTarget-uneditableContent' )
|
||||
.removeClass( 've-init-mw-desktopArticleTarget-uneditableContent' );
|
||||
|
||||
target.deactivating = false;
|
||||
target.deactivatingDeferred.resolve();
|
||||
$( 'html' ).removeClass( 've-deactivating' );
|
||||
|
||||
// Event tracking
|
||||
if ( trackMechanism ) {
|
||||
ve.track( 'mwedit.abort', {
|
||||
|
|
|
@ -548,15 +548,19 @@
|
|||
if ( tempWikitextEditor ) {
|
||||
syncTempWikitextEditor();
|
||||
}
|
||||
var activatePromise = target.activate( dataPromise );
|
||||
|
||||
// toolbarSetupDeferred resolves slightly before activatePromise, use done
|
||||
// to run in the same paint cycle as the VE toolbar being drawn
|
||||
target.toolbarSetupDeferred.done( function () {
|
||||
hideToolbarPlaceholder();
|
||||
var deactivating = target.deactivatingDeferred || $.Deferred().resolve();
|
||||
return deactivating.then( function () {
|
||||
var activatePromise = target.activate( dataPromise );
|
||||
|
||||
// toolbarSetupDeferred resolves slightly before activatePromise, use done
|
||||
// to run in the same paint cycle as the VE toolbar being drawn
|
||||
target.toolbarSetupDeferred.done( function () {
|
||||
hideToolbarPlaceholder();
|
||||
} );
|
||||
|
||||
return activatePromise;
|
||||
} );
|
||||
|
||||
return activatePromise;
|
||||
} )
|
||||
.then( function () {
|
||||
if ( mode === 'visual' ) {
|
||||
|
|
Loading…
Reference in a new issue