Use promises for confirmation dialog instead of done event

Should be merged at the same time as I70af4f4f
Unbreaks the confirm dialogs (I5f971852)

Change-Id: I7e7a5fcef4e749a3196f675e9f1f8e8bc5c11ca0
This commit is contained in:
Krenair 2014-05-31 16:24:14 +01:00
parent f65c3c6ef1
commit e59b1e7f60

View file

@ -291,11 +291,10 @@ ve.init.mw.ViewPageTarget.prototype.deactivate = function ( override ) {
'okFlags': [ 'destructive' ],
'cancelLabel': ve.msg( 'visualeditor-viewpage-savewarning-keep' ),
'cancelFlags': []
} );
confirmDialog.once( 'done', function ( result ) {
if ( result === 'ok' ) {
} ).then( function ( closingPromise ) {
closingPromise.then( function () {
target.cancel();
}
} );
} );
}
}
@ -911,18 +910,17 @@ ve.init.mw.ViewPageTarget.prototype.editSource = function () {
'okFlags': [ 'primary' ],
'cancelLabel': ve.msg( 'visualeditor-mweditmodesource-warning-cancel' ),
'cancelFlags': []
} );
confirmDialog.once( 'done', function ( result ) {
if ( result === 'ok' ) {
} ).then( function ( closingPromise ) {
closingPromise.then( function () {
// Get Wikitext from the DOM
target.serialize(
target.docToSave || ve.dm.converter.getDomFromModel( target.surface.getModel().getDocument() ),
ve.bind( target.submitWithSaveFields, target, { 'wpDiff': 1, 'veswitched': 1 } )
);
} else {
}, function () {
// Undo the opacity change
target.$document.css( 'opacity', 1 );
}
} );
} );
};