Merge "Transclusion editor template naming goodness"

This commit is contained in:
jenkins-bot 2013-06-19 01:37:07 +00:00 committed by Gerrit Code Review
commit ebddcf9239
2 changed files with 17 additions and 14 deletions

View file

@ -129,24 +129,20 @@ ve.dm.MWTemplateSpecModel.prototype.getDefaultParameterSpec = function ( name )
* @returns {string} Template label
*/
ve.dm.MWTemplateSpecModel.prototype.getLabel = function () {
var titleObj, title = this.template.getTitle(),
var titleObj,
title = this.template.getTitle(),
target = this.template.getTarget();
if ( title ) {
try {
// Normalize and remove namespace prefix if in the Template: namespace
titleObj = new mw.Title( title );
switch ( titleObj.getNamespaceId() ) {
case 10:
// Template namespace, remove namespace prefix
title = titleObj.getNameText();
break;
case 0:
// Main namespace, prepend a colon
title = ':' + titleObj.getPrefixedText();
break;
default:
title = titleObj.getPrefixedText();
if ( titleObj.getNamespaceId() === 10 ) {
// Template namespace, remove namespace prefix
title = titleObj.getNameText();
} else {
// Other namespace, already has a prefix
title = titleObj.getPrefixedText();
}
} catch ( e ) { }
}

View file

@ -5,6 +5,8 @@
* @license The MIT License (MIT); see LICENSE.txt
*/
/*global mw */
/**
* Document dialog.
*
@ -553,9 +555,14 @@ ve.ui.MWTransclusionDialog.prototype.getPlaceholderPage = function ( placeholder
function addTemplate() {
var target, part,
parts = placeholder.getTransclusion().getParts(),
title = addTemplateInput.getValue();
value = addTemplateInput.getValue(),
href = value;
target = { 'href': title, 'wt': title.replace( /^[^:]+:/, '' ) };
if ( href.charAt( 0 ) !== ':' ) {
href = mw.config.get( 'wgFormattedNamespaces' )[10] + ':' + href;
}
target = { 'href': new mw.Title( href ).getPrefixedText(), 'wt': value };
part = this.transclusion.addTemplate( target, ve.indexOf( placeholder, parts ) );
this.setPageByName( part.getId() );
placeholder.remove();