mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-16 02:51:50 +00:00
d3a2fab2c4
Objectives: * Rename just about every use of "template" to "transclusion" * Make a proper data structure for transclusions * Abstract away template data * Use more template data in the user interface * Allow adding parameters * Allow removing templates, parameters and content Changes: ve.ui.Dialog.css * Add rule to place add param controls on a single line ve.ui.MWTemplateDialogs.js * Move template spec loading into transclusion class * Add remove button for parts and parameters * Add parameter adding form * Use template data for labels and descriptions ve.dm.* * Add new transclusion data structures *.php * Add links to new files *.* * Rename all things "template" to "transclusion" Bug: 39598 Bug: 49403 Change-Id: I3bcf924a3e179cb65f19e833277a39dfd3dad8bd
85 lines
1.7 KiB
JavaScript
85 lines
1.7 KiB
JavaScript
/*!
|
|
* VisualEditor DataModel MWTemplateParameterModel class.
|
|
*
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
* @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;
|
|
this.name = name;
|
|
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.
|
|
*
|
|
* @return {string} Unique ID
|
|
*/
|
|
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;
|
|
};
|
|
|
|
/**
|
|
* 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 () {
|
|
this.template.removeParameter( this.name );
|
|
};
|