mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 16:20:52 +00:00
Merge "Make generateCitationFeatures() idempotent"
This commit is contained in:
commit
54b9bf76ae
|
@ -804,81 +804,94 @@ ve.init.mw.Target.prototype.generateCitationFeatures = function () {
|
||||||
for ( i = 0, len = Math.min( limit, tools.length ); i < len; i++ ) {
|
for ( i = 0, len = Math.min( limit, tools.length ); i < len; i++ ) {
|
||||||
item = tools[i];
|
item = tools[i];
|
||||||
data = { template: item.template };
|
data = { template: item.template };
|
||||||
|
|
||||||
// Generate transclusion tool
|
// Generate transclusion tool
|
||||||
name = 'cite-transclusion-' + item.name;
|
name = 'cite-transclusion-' + item.name;
|
||||||
tool = function GeneratedMWTransclusionDialogTool( toolbar, config ) {
|
if ( !ve.ui.toolFactory.lookup( name ) ) {
|
||||||
ve.ui.MWTransclusionDialogTool.call( this, toolbar, config );
|
tool = function GeneratedMWTransclusionDialogTool( toolbar, config ) {
|
||||||
};
|
ve.ui.MWTransclusionDialogTool.call( this, toolbar, config );
|
||||||
OO.inheritClass( tool, ve.ui.MWTransclusionDialogTool );
|
};
|
||||||
tool.static.group = 'cite-transclusion';
|
OO.inheritClass( tool, ve.ui.MWTransclusionDialogTool );
|
||||||
tool.static.name = name;
|
tool.static.group = 'cite-transclusion';
|
||||||
tool.static.icon = item.icon;
|
tool.static.name = name;
|
||||||
tool.static.title = item.title;
|
tool.static.icon = item.icon;
|
||||||
tool.static.commandName = name;
|
tool.static.title = item.title;
|
||||||
tool.static.template = item.template;
|
tool.static.commandName = name;
|
||||||
tool.static.autoAddToCatchall = false;
|
tool.static.template = item.template;
|
||||||
tool.static.autoAddToGroup = true;
|
tool.static.autoAddToCatchall = false;
|
||||||
ve.ui.toolFactory.register( tool );
|
tool.static.autoAddToGroup = true;
|
||||||
ve.ui.commandRegistry.register(
|
ve.ui.toolFactory.register( tool );
|
||||||
new ve.ui.Command(
|
ve.ui.commandRegistry.register(
|
||||||
name, 'window', 'open',
|
new ve.ui.Command(
|
||||||
{ args: ['transclusion', data], supportedSelections: ['linear'] }
|
name, 'window', 'open',
|
||||||
)
|
{ 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
|
// Generate citation tool
|
||||||
name = 'cite-' + item.name;
|
name = 'cite-' + item.name;
|
||||||
tool = function GeneratedMWCitationDialogTool( toolbar, config ) {
|
if ( !ve.ui.toolFactory.lookup( name ) ) {
|
||||||
ve.ui.MWCitationDialogTool.call( this, toolbar, config );
|
tool = function GeneratedMWCitationDialogTool( toolbar, config ) {
|
||||||
};
|
ve.ui.MWCitationDialogTool.call( this, toolbar, config );
|
||||||
OO.inheritClass( tool, ve.ui.MWCitationDialogTool );
|
};
|
||||||
tool.static.group = 'cite';
|
OO.inheritClass( tool, ve.ui.MWCitationDialogTool );
|
||||||
tool.static.name = name;
|
tool.static.group = 'cite';
|
||||||
tool.static.icon = item.icon;
|
tool.static.name = name;
|
||||||
tool.static.title = item.title;
|
tool.static.icon = item.icon;
|
||||||
tool.static.commandName = name;
|
tool.static.title = item.title;
|
||||||
tool.static.template = item.template;
|
tool.static.commandName = name;
|
||||||
tool.static.autoAddToCatchall = false;
|
tool.static.template = item.template;
|
||||||
tool.static.autoAddToGroup = true;
|
tool.static.autoAddToCatchall = false;
|
||||||
ve.ui.toolFactory.register( tool );
|
tool.static.autoAddToGroup = true;
|
||||||
ve.ui.commandRegistry.register(
|
ve.ui.toolFactory.register( tool );
|
||||||
new ve.ui.Command(
|
ve.ui.commandRegistry.register(
|
||||||
name, 'window', 'open',
|
new ve.ui.Command(
|
||||||
{ args: [name, data], supportedSelections: ['linear'] }
|
name, 'window', 'open',
|
||||||
)
|
{ 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
|
// Generate citation context item
|
||||||
name = 'cite-' + item.name;
|
if ( !ve.ui.contextItemFactory.lookup( name ) ) {
|
||||||
contextItem = function GeneratedMWCitationContextItem( toolbar, config ) {
|
contextItem = function GeneratedMWCitationContextItem( toolbar, config ) {
|
||||||
ve.ui.MWCitationContextItem.call( this, toolbar, config );
|
ve.ui.MWCitationContextItem.call( this, toolbar, config );
|
||||||
};
|
};
|
||||||
OO.inheritClass( contextItem, ve.ui.MWCitationContextItem );
|
OO.inheritClass( contextItem, ve.ui.MWCitationContextItem );
|
||||||
contextItem.static.name = name;
|
contextItem.static.name = name;
|
||||||
contextItem.static.icon = item.icon;
|
contextItem.static.icon = item.icon;
|
||||||
contextItem.static.label = item.title;
|
contextItem.static.label = item.title;
|
||||||
contextItem.static.commandName = name;
|
contextItem.static.commandName = name;
|
||||||
contextItem.static.template = item.template;
|
contextItem.static.template = item.template;
|
||||||
ve.ui.contextItemFactory.register( contextItem );
|
ve.ui.contextItemFactory.register( contextItem );
|
||||||
|
}
|
||||||
|
|
||||||
// Generate dialog
|
// Generate dialog
|
||||||
dialog = function GeneratedMWCitationDialog( config ) {
|
if ( !ve.ui.windowFactory.lookup( name ) ) {
|
||||||
ve.ui.MWCitationDialog.call( this, config );
|
dialog = function GeneratedMWCitationDialog( config ) {
|
||||||
};
|
ve.ui.MWCitationDialog.call( this, config );
|
||||||
OO.inheritClass( dialog, ve.ui.MWCitationDialog );
|
};
|
||||||
dialog.static.name = name;
|
OO.inheritClass( dialog, ve.ui.MWCitationDialog );
|
||||||
dialog.static.icon = item.icon;
|
dialog.static.name = name;
|
||||||
dialog.static.title = item.title;
|
dialog.static.icon = item.icon;
|
||||||
ve.ui.windowFactory.register( dialog );
|
dialog.static.title = item.title;
|
||||||
|
ve.ui.windowFactory.register( dialog );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue