mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-25 06:46:26 +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++ ) {
|
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;
|
||||||
|
if ( !ve.ui.toolFactory.lookup( name ) ) {
|
||||||
tool = function GeneratedMWTransclusionDialogTool( toolbar, config ) {
|
tool = function GeneratedMWTransclusionDialogTool( toolbar, config ) {
|
||||||
ve.ui.MWTransclusionDialogTool.call( this, 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'] }
|
{ 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;
|
||||||
|
if ( !ve.ui.toolFactory.lookup( name ) ) {
|
||||||
tool = function GeneratedMWCitationDialogTool( toolbar, config ) {
|
tool = function GeneratedMWCitationDialogTool( toolbar, config ) {
|
||||||
ve.ui.MWCitationDialogTool.call( this, 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'] }
|
{ 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 );
|
||||||
};
|
};
|
||||||
|
@ -870,7 +879,10 @@ ve.init.mw.Target.prototype.generateCitationFeatures = function () {
|
||||||
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
|
||||||
|
if ( !ve.ui.windowFactory.lookup( name ) ) {
|
||||||
dialog = function GeneratedMWCitationDialog( config ) {
|
dialog = function GeneratedMWCitationDialog( config ) {
|
||||||
ve.ui.MWCitationDialog.call( this, config );
|
ve.ui.MWCitationDialog.call( this, config );
|
||||||
};
|
};
|
||||||
|
@ -881,6 +893,7 @@ ve.init.mw.Target.prototype.generateCitationFeatures = function () {
|
||||||
ve.ui.windowFactory.register( dialog );
|
ve.ui.windowFactory.register( dialog );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue