2013-06-11 19:16:04 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor DataModel MWTemplateParameterModel class.
|
|
|
|
*
|
2014-01-05 12:05:05 +00:00
|
|
|
* @copyright 2011-2014 VisualEditor Team and others; see AUTHORS.txt
|
2013-06-11 19:16:04 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* MediaWiki template parameter.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @param {ve.dm.MWTemplateModel} template Template
|
|
|
|
* @param {string} name Parameter name
|
|
|
|
* @param {string} value Parameter value
|
|
|
|
*/
|
|
|
|
ve.dm.MWTemplateParameterModel = function VeDmMWTemplateParameterModel( template, name, value ) {
|
|
|
|
// Properties
|
|
|
|
this.template = template;
|
2013-07-10 19:04:11 +00:00
|
|
|
this.originalName = name;
|
|
|
|
this.name = name.trim();
|
2013-06-11 19:16:04 +00:00
|
|
|
this.value = value || '';
|
|
|
|
this.id = this.template.getId() + '/' + name;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get template parameter is part of.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @returns {ve.dm.MWTemplateModel} Template
|
|
|
|
*/
|
|
|
|
ve.dm.MWTemplateParameterModel.prototype.getTemplate = function () {
|
|
|
|
return this.template;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get unique parameter ID within the transclusion.
|
|
|
|
*
|
2013-06-17 10:50:24 +00:00
|
|
|
* @returns {string} Unique ID
|
2013-06-11 19:16:04 +00:00
|
|
|
*/
|
|
|
|
ve.dm.MWTemplateParameterModel.prototype.getId = function () {
|
|
|
|
return this.id;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get parameter name.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @returns {string} Parameter name
|
|
|
|
*/
|
|
|
|
ve.dm.MWTemplateParameterModel.prototype.getName = function () {
|
|
|
|
return this.name;
|
|
|
|
};
|
|
|
|
|
2013-07-10 19:04:11 +00:00
|
|
|
/**
|
|
|
|
* Get parameter name.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @returns {string} Parameter name
|
|
|
|
*/
|
|
|
|
ve.dm.MWTemplateParameterModel.prototype.getOriginalName = function () {
|
|
|
|
return this.originalName;
|
|
|
|
};
|
|
|
|
|
2013-06-11 19:16:04 +00:00
|
|
|
/**
|
|
|
|
* Get parameter value.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @returns {string} Parameter value
|
|
|
|
*/
|
|
|
|
ve.dm.MWTemplateParameterModel.prototype.getValue = function () {
|
|
|
|
return this.value;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set parameter value.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @param {string} value Parameter value
|
|
|
|
*/
|
|
|
|
ve.dm.MWTemplateParameterModel.prototype.setValue = function ( value ) {
|
|
|
|
this.value = value;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove parameter from template.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
ve.dm.MWTemplateParameterModel.prototype.remove = function () {
|
2013-06-29 02:37:42 +00:00
|
|
|
this.template.removeParameter( this );
|
2013-06-11 19:16:04 +00:00
|
|
|
};
|