mediawiki-extensions-Visual.../modules/ve-mw/ui/tools/ve.ui.MWTransclusionDialogTool.js
Florian 5627701cb1 Fix inheritance of ve.ui.MWTransclusionDialogTool
From the description of the commit message[1] for WindowTool and
FragmentWindowTool, the ve.ui.MWTransclusionDialogTool should be
a FragmentWindowTool, and not a WindowTool.

In fact, the bug is caused by the missing isCompatibleWith method
in WindowTool.

[1] I3a0e761f0d6e942d503ec

Follow up: I676af9c50b09ef007926240eb2327d1a0fdd80f5

Bug: T121596
Change-Id: I9a47e5d67fcd7a94155b7cf77c734c94b0ed69e1
2015-12-19 11:52:44 +00:00

93 lines
2.4 KiB
JavaScript

/*!
* VisualEditor MediaWiki UserInterface transclusion tool classes.
*
* @copyright 2011-2015 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* MediaWiki UserInterface transclusion tool.
*
* @class
* @extends ve.ui.FragmentWindowTool
* @constructor
* @param {OO.ui.ToolGroup} toolGroup
* @param {Object} [config] Configuration options
*/
ve.ui.MWTransclusionDialogTool = function VeUiMWTransclusionDialogTool() {
ve.ui.MWTransclusionDialogTool.super.apply( this, arguments );
};
/* Inheritance */
OO.inheritClass( ve.ui.MWTransclusionDialogTool, ve.ui.FragmentWindowTool );
/* Static Properties */
ve.ui.MWTransclusionDialogTool.static.name = 'transclusion';
ve.ui.MWTransclusionDialogTool.static.group = 'object';
ve.ui.MWTransclusionDialogTool.static.icon = 'template';
ve.ui.MWTransclusionDialogTool.static.title =
OO.ui.deferMsg( 'visualeditor-dialogbutton-template-tooltip' );
ve.ui.MWTransclusionDialogTool.static.modelClasses = [ ve.dm.MWTransclusionNode ];
ve.ui.MWTransclusionDialogTool.static.commandName = 'transclusion';
/**
* Only display tool for single-template transclusions of these templates.
*
* @property {string|string[]|null}
* @static
* @inheritable
*/
ve.ui.MWTransclusionDialogTool.static.template = null;
/* Methods */
/**
* @inheritdoc
*/
ve.ui.MWTransclusionDialogTool.static.isCompatibleWith = function ( model ) {
var compatible;
// Parent method
compatible = ve.ui.MWTransclusionDialogTool.super.static.isCompatibleWith.call( this, model );
if ( compatible && this.template ) {
return model.isSingleTemplate( this.template );
}
return compatible;
};
/* Registration */
ve.ui.toolFactory.register( ve.ui.MWTransclusionDialogTool );
ve.ui.commandRegistry.register(
new ve.ui.Command(
'transclusion', 'window', 'open',
{ args: [ 'transclusion' ], supportedSelections: [ 'linear' ] }
)
);
ve.ui.commandRegistry.register(
new ve.ui.Command(
'transclusionFromSequence', 'window', 'open',
{ args: [ 'transclusion', { cancelCommand: 'undo' } ], supportedSelections: [ 'linear' ] }
)
);
ve.ui.sequenceRegistry.register(
new ve.ui.Sequence( 'wikitextTemplate', 'transclusionFromSequence', '{{', 2 )
);
ve.ui.commandHelpRegistry.register( 'insert', 'template', {
sequences: [ 'wikitextTemplate' ],
label: OO.ui.deferMsg( 'visualeditor-dialog-template-title' )
} );