mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
Merge "ve.dm.MWTemplateSpecModel: Expand parameter aliases"
This commit is contained in:
commit
0a0265cb77
|
@ -67,16 +67,25 @@ ve.dm.MWTemplateSpecModel.getMessage = function ( val, fallback, lang ) {
|
||||||
* @param {string[][]} [data.sets] Lists of param sets
|
* @param {string[][]} [data.sets] Lists of param sets
|
||||||
*/
|
*/
|
||||||
ve.dm.MWTemplateSpecModel.prototype.extend = function ( data ) {
|
ve.dm.MWTemplateSpecModel.prototype.extend = function ( data ) {
|
||||||
var key;
|
var key, paramObj, i, len;
|
||||||
|
|
||||||
if ( data.description !== null ) {
|
if ( data.description !== null ) {
|
||||||
this.description = data.description;
|
this.description = data.description;
|
||||||
}
|
}
|
||||||
if ( ve.isPlainObject( data.params ) ) {
|
if ( ve.isPlainObject( data.params ) ) {
|
||||||
for ( key in data.params ) {
|
for ( key in data.params ) {
|
||||||
|
paramObj = data.params[key];
|
||||||
this.params[key] = ve.extendObject(
|
this.params[key] = ve.extendObject(
|
||||||
true, this.getDefaultParameterSpec( key ), data.params[key]
|
true,
|
||||||
|
this.getDefaultParameterSpec( key ),
|
||||||
|
paramObj
|
||||||
);
|
);
|
||||||
|
if ( paramObj.aliases.length ) {
|
||||||
|
for ( i = 0, len = paramObj.aliases.length; i < len; i++ ) {
|
||||||
|
this.params[ paramObj.aliases[i] ] = paramObj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete paramObj.aliases;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( data.sets ) {
|
if ( data.sets ) {
|
||||||
|
|
|
@ -79,10 +79,10 @@ ve.dm.MWTransclusionModel.prototype.load = function ( data ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Promise is resolved passing the specs object as the first argument - binding #specs
|
// Add fetched specs to #specs store when the promise is resolved
|
||||||
// to precede that argument and passing them both to extendObject will cause #specs to be added
|
return this.fetchSpecs( templates ).done( function ( specs ) {
|
||||||
// to when the promise is resolved
|
ve.extendObject( this.specs, specs );
|
||||||
return this.fetchSpecs( templates ).done( ve.bind( ve.extendObject, null, this.specs ) );
|
} );
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -92,7 +92,8 @@ ve.dm.MWTransclusionModel.prototype.load = function ( data ) {
|
||||||
* @returns {jQuery.Promise} Promise, resolved when spec is loaded
|
* @returns {jQuery.Promise} Promise, resolved when spec is loaded
|
||||||
*/
|
*/
|
||||||
ve.dm.MWTransclusionModel.prototype.fetchSpecs = function ( templates ) {
|
ve.dm.MWTransclusionModel.prototype.fetchSpecs = function ( templates ) {
|
||||||
var i, len, title, deferred = $.Deferred(),
|
var i, len, title,
|
||||||
|
deferred = $.Deferred(),
|
||||||
specs = {},
|
specs = {},
|
||||||
titles = [];
|
titles = [];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue