mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 06:24:08 +00:00
Inline private helper functions in MWTransclusionNode
Change-Id: Ie14ad29e214f3440f60a7e13ed660fff85c7c448
This commit is contained in:
parent
1ba1bc76f4
commit
efc50591c1
|
@ -45,39 +45,23 @@ ve.ce.MWTransclusionNode.static.iconWhenInvisible = 'puzzle';
|
|||
/* Static Methods */
|
||||
|
||||
/**
|
||||
* Get a list of descriptions of template parts in a transclusion node, excluding raw wikitext
|
||||
* Get a plain text description of the template parts in a transclusion node, excluding raw wikitext
|
||||
* snippets.
|
||||
*
|
||||
* @static
|
||||
* @param {ve.dm.MWTransclusionNode} model Node model
|
||||
* @return {(string|undefined)[]} List of template part descriptions
|
||||
*/
|
||||
ve.ce.MWTransclusionNode.static.getTemplatePartDescriptions = function ( model ) {
|
||||
return model.getPartsList().map( this.getTemplatePartDescription );
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a description of a template part in a transclusion node, except it's a raw wikitext snippet.
|
||||
*
|
||||
* @static
|
||||
* @param {Object} part Template part
|
||||
* @return {string|undefined}
|
||||
*/
|
||||
ve.ce.MWTransclusionNode.static.getTemplatePartDescription = function ( part ) {
|
||||
if ( part.templatePage ) {
|
||||
return mw.Title.newFromText( part.templatePage )
|
||||
.getRelativeText( mw.config.get( 'wgNamespaceIds' ).template );
|
||||
} else if ( part.template ) {
|
||||
// Not actually a template, but e.g. a parser function
|
||||
return part.template;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* @param {ve.dm.MWTransclusionNode} model
|
||||
* @return {string} Comma-separated list of template names
|
||||
*/
|
||||
ve.ce.MWTransclusionNode.static.getDescription = function ( model ) {
|
||||
return this.getTemplatePartDescriptions( model )
|
||||
return model.getPartsList()
|
||||
.map( function ( part ) {
|
||||
if ( part.templatePage ) {
|
||||
return mw.Title.newFromText( part.templatePage )
|
||||
.getRelativeText( mw.config.get( 'wgNamespaceIds' ).template );
|
||||
}
|
||||
// Not actually a template, but e.g. a parser function
|
||||
return part.template || '';
|
||||
} )
|
||||
.filter( function ( desc ) {
|
||||
return desc;
|
||||
} )
|
||||
|
|
|
@ -67,11 +67,12 @@ ve.ui.MWTransclusionContextItem.static.isCompatibleWith =
|
|||
* @inheritdoc
|
||||
*/
|
||||
ve.ui.MWTransclusionContextItem.prototype.getDescription = function () {
|
||||
/** @var {ve.ce.MWTransclusionNode} nodeClass */
|
||||
var nodeClass = ve.ce.nodeFactory.lookup( this.model.constructor.static.name );
|
||||
return ve.msg(
|
||||
'visualeditor-dialog-transclusion-contextitem-description',
|
||||
nodeClass.static.getDescription( this.model ),
|
||||
nodeClass.static.getTemplatePartDescriptions( this.model ).length
|
||||
this.model.getPartsList().length
|
||||
);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue