Alex Monk has uploaded a new change for review. https://gerrit.wikimedia.org/r/134621
Change subject: Clean up interaction with confirmation dialog ...................................................................... Clean up interaction with confirmation dialog It now only sends a single 'done' event, which we can use .once on Relies on I4f485d4f Bug: 65571 Change-Id: I19aa65612bf02bed056de292f212d2f5732a8fec --- M modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js 1 file changed, 12 insertions(+), 23 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor refs/changes/21/134621/1 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 fb9efa8..109b439 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js +++ b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js @@ -279,7 +279,7 @@ * @method */ ve.init.mw.ViewPageTarget.prototype.deactivate = function ( override ) { - var confirmDialog; + var confirmDialog, target = this; if ( override || ( this.active && !this.deactivating ) ) { if ( override || !this.edited ) { this.cancel(); @@ -292,15 +292,9 @@ 'cancelLabel': ve.msg( 'visualeditor-viewpage-savewarning-keep' ), 'cancelFlags': [] } ); - confirmDialog.connect( this, { - 'ok': function () { - // Prevent future confirm dialogs from executing this handler (bug 65557) - confirmDialog.disconnect( this ); - this.cancel(); - }, - 'cancel': function () { - // Prevent future confirm dialogs from executing this handler (bug 65557) - confirmDialog.disconnect( this ); + confirmDialog.once( 'done', function ( result ) { + if ( result === 'ok' ) { + target.cancel(); } } ); } @@ -903,7 +897,7 @@ * @method */ ve.init.mw.ViewPageTarget.prototype.editSource = function () { - var confirmDialog = this.surface.dialogs.getWindow( 'confirm' ); + var confirmDialog = this.surface.dialogs.getWindow( 'confirm' ), target = this; this.$document.css( 'opacity', 0.5 ); @@ -914,21 +908,16 @@ 'cancelLabel': ve.msg( 'visualeditor-mweditmodesource-warning-cancel' ), 'cancelFlags': [] } ); - confirmDialog.connect( this, { - 'ok': function () { - // Prevent future confirm dialogs from executing this handler (bug 65557) - confirmDialog.disconnect( this ); + confirmDialog.once( 'done', function ( result ) { + if ( result === 'ok' ) { // Get Wikitext from the DOM - this.serialize( - this.docToSave || ve.dm.converter.getDomFromModel( this.surface.getModel().getDocument() ), - ve.bind( this.submitWithSaveFields, this, { 'wpDiff': 1, 'veswitched': 1 } ) + target.serialize( + target.docToSave || ve.dm.converter.getDomFromModel( target.surface.getModel().getDocument() ), + ve.bind( target.submitWithSaveFields, target, { 'wpDiff': 1, 'veswitched': 1 } ) ); - }, - 'cancel': function () { - // Prevent future confirm dialogs from executing this handler (bug 65557) - confirmDialog.disconnect( this ); + } else { // Undo the opacity change - this.$document.css( 'opacity', 1 ); + target.$document.css( 'opacity', 1 ); } } ); }; -- To view, visit https://gerrit.wikimedia.org/r/134621 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I19aa65612bf02bed056de292f212d2f5732a8fec Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/VisualEditor Gerrit-Branch: master Gerrit-Owner: Alex Monk <kren...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits