mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +00:00
Merge "Make generateCitationFeatures() idempotent"
This commit is contained in:
commit
54b9bf76ae
|
@ -804,8 +804,10 @@ ve.init.mw.Target.prototype.generateCitationFeatures = function () {
|
|||
for ( i = 0, len = Math.min( limit, tools.length ); i < len; i++ ) {
|
||||
item = tools[i];
|
||||
data = { template: item.template };
|
||||
|
||||
// Generate transclusion tool
|
||||
name = 'cite-transclusion-' + item.name;
|
||||
if ( !ve.ui.toolFactory.lookup( name ) ) {
|
||||
tool = function GeneratedMWTransclusionDialogTool( toolbar, config ) {
|
||||
ve.ui.MWTransclusionDialogTool.call( this, toolbar, config );
|
||||
};
|
||||
|
@ -825,8 +827,25 @@ ve.init.mw.Target.prototype.generateCitationFeatures = function () {
|
|||
{ args: ['transclusion', data], supportedSelections: ['linear'] }
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Generate transclusion context item
|
||||
if ( !ve.ui.contextItemFactory.lookup( name ) ) {
|
||||
contextItem = function GeneratedMWTransclusionContextItem( toolbar, config ) {
|
||||
ve.ui.MWTransclusionContextItem.call( this, toolbar, config );
|
||||
};
|
||||
OO.inheritClass( contextItem, ve.ui.MWTransclusionContextItem );
|
||||
contextItem.static.name = name;
|
||||
contextItem.static.icon = item.icon;
|
||||
contextItem.static.label = item.title;
|
||||
contextItem.static.commandName = name;
|
||||
contextItem.static.template = item.template;
|
||||
ve.ui.contextItemFactory.register( contextItem );
|
||||
}
|
||||
|
||||
// Generate citation tool
|
||||
name = 'cite-' + item.name;
|
||||
if ( !ve.ui.toolFactory.lookup( name ) ) {
|
||||
tool = function GeneratedMWCitationDialogTool( toolbar, config ) {
|
||||
ve.ui.MWCitationDialogTool.call( this, toolbar, config );
|
||||
};
|
||||
|
@ -846,20 +865,10 @@ ve.init.mw.Target.prototype.generateCitationFeatures = function () {
|
|||
{ args: [name, data], supportedSelections: ['linear'] }
|
||||
)
|
||||
);
|
||||
// Generate transclusion context item
|
||||
name = 'cite-transclusion-' + item.name;
|
||||
contextItem = function GeneratedMWTransclusionContextItem( toolbar, config ) {
|
||||
ve.ui.MWTransclusionContextItem.call( this, toolbar, config );
|
||||
};
|
||||
OO.inheritClass( contextItem, ve.ui.MWTransclusionContextItem );
|
||||
contextItem.static.name = name;
|
||||
contextItem.static.icon = item.icon;
|
||||
contextItem.static.label = item.title;
|
||||
contextItem.static.commandName = name;
|
||||
contextItem.static.template = item.template;
|
||||
ve.ui.contextItemFactory.register( contextItem );
|
||||
}
|
||||
|
||||
// Generate citation context item
|
||||
name = 'cite-' + item.name;
|
||||
if ( !ve.ui.contextItemFactory.lookup( name ) ) {
|
||||
contextItem = function GeneratedMWCitationContextItem( toolbar, config ) {
|
||||
ve.ui.MWCitationContextItem.call( this, toolbar, config );
|
||||
};
|
||||
|
@ -870,7 +879,10 @@ ve.init.mw.Target.prototype.generateCitationFeatures = function () {
|
|||
contextItem.static.commandName = name;
|
||||
contextItem.static.template = item.template;
|
||||
ve.ui.contextItemFactory.register( contextItem );
|
||||
}
|
||||
|
||||
// Generate dialog
|
||||
if ( !ve.ui.windowFactory.lookup( name ) ) {
|
||||
dialog = function GeneratedMWCitationDialog( config ) {
|
||||
ve.ui.MWCitationDialog.call( this, config );
|
||||
};
|
||||
|
@ -881,6 +893,7 @@ ve.init.mw.Target.prototype.generateCitationFeatures = function () {
|
|||
ve.ui.windowFactory.register( dialog );
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue