mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 16:20:52 +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
|
* @returns {string} Template label
|
||||||
*/
|
*/
|
||||||
ve.dm.MWTemplateSpecModel.prototype.getLabel = function () {
|
ve.dm.MWTemplateSpecModel.prototype.getLabel = function () {
|
||||||
var titleObj, title = this.template.getTitle(),
|
var titleObj,
|
||||||
|
title = this.template.getTitle(),
|
||||||
target = this.template.getTarget();
|
target = this.template.getTarget();
|
||||||
|
|
||||||
if ( title ) {
|
if ( title ) {
|
||||||
try {
|
try {
|
||||||
// Normalize and remove namespace prefix if in the Template: namespace
|
// Normalize and remove namespace prefix if in the Template: namespace
|
||||||
titleObj = new mw.Title( title );
|
titleObj = new mw.Title( title );
|
||||||
switch ( titleObj.getNamespaceId() ) {
|
if ( titleObj.getNamespaceId() === 10 ) {
|
||||||
case 10:
|
// Template namespace, remove namespace prefix
|
||||||
// Template namespace, remove namespace prefix
|
title = titleObj.getNameText();
|
||||||
title = titleObj.getNameText();
|
} else {
|
||||||
break;
|
// Other namespace, already has a prefix
|
||||||
case 0:
|
title = titleObj.getPrefixedText();
|
||||||
// Main namespace, prepend a colon
|
|
||||||
title = ':' + titleObj.getPrefixedText();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
title = titleObj.getPrefixedText();
|
|
||||||
}
|
}
|
||||||
} catch ( e ) { }
|
} catch ( e ) { }
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
* @license The MIT License (MIT); see LICENSE.txt
|
* @license The MIT License (MIT); see LICENSE.txt
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*global mw */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Document dialog.
|
* Document dialog.
|
||||||
*
|
*
|
||||||
|
@ -553,9 +555,14 @@ ve.ui.MWTransclusionDialog.prototype.getPlaceholderPage = function ( placeholder
|
||||||
function addTemplate() {
|
function addTemplate() {
|
||||||
var target, part,
|
var target, part,
|
||||||
parts = placeholder.getTransclusion().getParts(),
|
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 ) );
|
part = this.transclusion.addTemplate( target, ve.indexOf( placeholder, parts ) );
|
||||||
this.setPageByName( part.getId() );
|
this.setPageByName( part.getId() );
|
||||||
placeholder.remove();
|
placeholder.remove();
|
||||||
|
|
Loading…
Reference in a new issue