mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-24 08:23:52 +00:00
Merge "Fix <escape> handler again"
This commit is contained in:
commit
d6874dcbab
|
@ -37,7 +37,7 @@ function ReplyWidget( comment, config ) {
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
this.replyButton.connect( this, { click: 'onReplyClick' } );
|
this.replyButton.connect( this, { click: 'onReplyClick' } );
|
||||||
this.cancelButton.connect( this, { click: [ 'teardown', true ] } );
|
this.cancelButton.connect( this, { click: 'tryTeardown' } );
|
||||||
this.$element.on( 'keydown', this.onKeyDown.bind( this ) );
|
this.$element.on( 'keydown', this.onKeyDown.bind( this ) );
|
||||||
this.beforeUnloadHandler = this.onBeforeUnload.bind( this );
|
this.beforeUnloadHandler = this.onBeforeUnload.bind( this );
|
||||||
|
|
||||||
|
@ -112,10 +112,11 @@ ReplyWidget.prototype.setup = function () {
|
||||||
this.bindBeforeUnloadHandler();
|
this.bindBeforeUnloadHandler();
|
||||||
};
|
};
|
||||||
|
|
||||||
ReplyWidget.prototype.teardown = function ( confirm ) {
|
ReplyWidget.prototype.tryTeardown = function () {
|
||||||
var promise,
|
var promise,
|
||||||
widget = this;
|
widget = this;
|
||||||
if ( confirm && !this.isEmpty() ) {
|
|
||||||
|
if ( !this.isEmpty() ) {
|
||||||
// TODO: Override messages in dialog to be more ReplyWidget specific
|
// TODO: Override messages in dialog to be more ReplyWidget specific
|
||||||
promise = OO.ui.getWindowManager().openWindow( 'abandonedit' )
|
promise = OO.ui.getWindowManager().openWindow( 'abandonedit' )
|
||||||
.closed.then( function ( data ) {
|
.closed.then( function ( data ) {
|
||||||
|
@ -127,16 +128,20 @@ ReplyWidget.prototype.teardown = function ( confirm ) {
|
||||||
promise = $.Deferred().resolve().promise();
|
promise = $.Deferred().resolve().promise();
|
||||||
}
|
}
|
||||||
promise.then( function () {
|
promise.then( function () {
|
||||||
widget.unbindBeforeUnloadHandler();
|
widget.teardown();
|
||||||
widget.clear();
|
|
||||||
widget.$preview.empty();
|
|
||||||
widget.emit( 'teardown' );
|
|
||||||
} );
|
} );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ReplyWidget.prototype.teardown = function () {
|
||||||
|
this.unbindBeforeUnloadHandler();
|
||||||
|
this.clear();
|
||||||
|
this.$preview.empty();
|
||||||
|
this.emit( 'teardown' );
|
||||||
|
};
|
||||||
|
|
||||||
ReplyWidget.prototype.onKeyDown = function ( e ) {
|
ReplyWidget.prototype.onKeyDown = function ( e ) {
|
||||||
if ( e.which === OO.ui.Keys.ESCAPE ) {
|
if ( e.which === OO.ui.Keys.ESCAPE ) {
|
||||||
this.emit( 'teardown' );
|
this.tryTeardown();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue