mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 18:39:52 +00:00
ve.ui.MWBackTool: Avoid using global ve.init.target
We have to move the activation logic from a ve.ui.Command to the ve.ui.Tool, as the Command is unable to refer to the Target. Previous attempt:4984c5ffbb
reverted infb32aa4978
. Bug: T279313 Change-Id: I3cb74aa5123b67a6c63b8e07ea7f93a6d4a07d4f
This commit is contained in:
parent
06ea3f84f8
commit
5badd4fcd4
|
@ -18,9 +18,7 @@ ve.ui.MWBackTool.static.group = 'navigation';
|
|||
ve.ui.MWBackTool.static.icon = 'close';
|
||||
ve.ui.MWBackTool.static.title =
|
||||
OO.ui.deferMsg( 'visualeditor-backbutton-tooltip' );
|
||||
ve.ui.MWBackTool.static.commandName = 'back';
|
||||
|
||||
/** */
|
||||
ve.ui.MWBackTool.prototype.onUpdateState = function () {
|
||||
// Parent method
|
||||
ve.ui.MWBackTool.super.prototype.onUpdateState.apply( this, arguments );
|
||||
|
@ -29,17 +27,13 @@ ve.ui.MWBackTool.prototype.onUpdateState = function () {
|
|||
this.setDisabled( false );
|
||||
};
|
||||
|
||||
ve.ui.toolFactory.register( ve.ui.MWBackTool );
|
||||
ve.ui.MWBackTool.prototype.onSelect = function () {
|
||||
// Parent method
|
||||
ve.ui.MWBackTool.super.prototype.onSelect.apply( this, arguments );
|
||||
|
||||
/**
|
||||
* Back command
|
||||
*/
|
||||
ve.ui.MWBackCommand = function VeUiMWBackCommand() {
|
||||
// Parent constructor
|
||||
ve.ui.MWBackCommand.super.call( this, 'back' );
|
||||
if ( this.toolbar instanceof ve.ui.TargetToolbar ) {
|
||||
this.toolbar.target.tryTeardown();
|
||||
}
|
||||
};
|
||||
OO.inheritClass( ve.ui.MWBackCommand, ve.ui.Command );
|
||||
ve.ui.MWBackCommand.prototype.execute = function () {
|
||||
ve.init.target.tryTeardown();
|
||||
};
|
||||
ve.ui.commandRegistry.register( new ve.ui.MWBackCommand() );
|
||||
|
||||
ve.ui.toolFactory.register( ve.ui.MWBackTool );
|
||||
|
|
Loading…
Reference in a new issue