mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +00:00
Merge "Transclusion editor template naming goodness"
This commit is contained in:
commit
ebddcf9239
|
@ -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 ) { }
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue