diff --git a/modules/ve-mw/ce/nodes/ve.ce.MWTransclusionNode.js b/modules/ve-mw/ce/nodes/ve.ce.MWTransclusionNode.js index 207635455b..3e84a6625c 100644 --- a/modules/ve-mw/ce/nodes/ve.ce.MWTransclusionNode.js +++ b/modules/ve-mw/ce/nodes/ve.ce.MWTransclusionNode.js @@ -54,23 +54,26 @@ ve.ce.MWTransclusionNode.static.iconWhenInvisible = 'puzzle'; * @return {string[]} List of template part descriptions */ ve.ce.MWTransclusionNode.static.getTemplatePartDescriptions = function ( model ) { - var i, len, part, title, - parts = model.getPartsList(), - words = []; + return model.getPartsList().map( this.getTemplatePartDescription ); +}; - for ( i = 0, len = parts.length; i < len; i++ ) { - part = parts[ i ]; - // Ignore parts that are just content - if ( part.templatePage ) { - title = mw.Title.newFromText( part.templatePage ); - words.push( title.getRelativeText( mw.config.get( 'wgNamespaceIds' ).template ) ); - } else if ( part.template ) { - // Not actually a template, but e.g. a parser function - words.push( part.template ); - } +/** + * Get a description of a template part in a transclusion node + * + * @static + * @param {Object} part Template part + * @return {string} Template part description + */ +ve.ce.MWTransclusionNode.static.getTemplatePartDescription = function ( part ) { + var title; + // Ignore parts that are just content + if ( part.templatePage ) { + title = mw.Title.newFromText( part.templatePage ); + return title.getRelativeText( mw.config.get( 'wgNamespaceIds' ).template ); + } else if ( part.template ) { + // Not actually a template, but e.g. a parser function + return part.template; } - - return words; }; /** diff --git a/modules/ve-mw/ui/contextitems/ve.ui.MWTransclusionContextItem.js b/modules/ve-mw/ui/contextitems/ve.ui.MWTransclusionContextItem.js index ea2c4b8c63..e55844ee47 100644 --- a/modules/ve-mw/ui/contextitems/ve.ui.MWTransclusionContextItem.js +++ b/modules/ve-mw/ui/contextitems/ve.ui.MWTransclusionContextItem.js @@ -67,10 +67,11 @@ ve.ui.MWTransclusionContextItem.static.isCompatibleWith = * @inheritdoc */ ve.ui.MWTransclusionContextItem.prototype.getDescription = function () { + var nodeClass = ve.ce.nodeFactory.lookup( this.model.constructor.static.name ); return ve.msg( 'visualeditor-dialog-transclusion-contextitem-description', - ve.ce.MWTransclusionNode.static.getDescription( this.model ), - ve.ce.MWTransclusionNode.static.getTemplatePartDescriptions( this.model ).length + nodeClass.static.getDescription( this.model ), + nodeClass.static.getTemplatePartDescriptions( this.model ).length ); }; @@ -78,8 +79,9 @@ ve.ui.MWTransclusionContextItem.prototype.getDescription = function () { * @inheritdoc */ ve.ui.MWTransclusionContextItem.prototype.renderDescription = function () { + var nodeClass = ve.ce.nodeFactory.lookup( this.model.constructor.static.name ); // No "Generated from" prefix in mobile context - this.$description.text( ve.ce.MWTransclusionNode.static.getDescription( this.model ) ); + this.$description.text( nodeClass.static.getDescription( this.model ) ); }; /**