mediawiki-extensions-Visual.../modules/ve-mw/dm/models/ve.dm.MWTransclusionPartModel.js
Trevor Parscal 92746ef3da Implement 'change' events in templates models
This will make generating live previews possible.

Changes:
* Add change events to template model.
* Set up connect/disconnect.

Also:
* Add missing fallback for getParameterLabel (Param#label is
  optional per the TemplateData spec).
* Implement getWikitext, to be used by the UI dialog later
  to create a preview from the wikitext.
* Correctly mark ve.dm.MWTransclusionNode#escapeParameter as
  being a static method.

Change-Id: Ie306ed03babf11568e954b1813ce5324f57d7f0e
2014-01-22 19:03:17 +00:00

80 lines
1.6 KiB
JavaScript

/*!
* VisualEditor DataModel MWTransclusionPartModel class.
*
* @copyright 2011-2014 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* MediaWiki transclusion part model.
*
* @class
* @mixins OO.EventEmitter
*
* @constructor
* @param {ve.dm.MWTransclusionModel} transclusion Transclusion
*/
ve.dm.MWTransclusionPartModel = function VeDmMWTransclusionPartModel( transclusion ) {
// Mixin constructors
OO.EventEmitter.call( this );
// Properties
this.transclusion = transclusion;
this.id = 'part_' + this.transclusion.getUniquePartId();
};
/* Inheritance */
OO.mixinClass( ve.dm.MWTransclusionPartModel, OO.EventEmitter );
/* Events */
/**
* @event change
*/
/* Methods */
/**
* Get transclusion part is in.
*
* @returns {ve.dm.MWTransclusionModel} Transclusion
*/
ve.dm.MWTransclusionPartModel.prototype.getTransclusion = function () {
return this.transclusion;
};
/**
* Get a unique part ID within the transclusion.
*
* @returns {string} Unique ID
*/
ve.dm.MWTransclusionPartModel.prototype.getId = function () {
return this.id;
};
/**
* Remove part from transclusion.
*/
ve.dm.MWTransclusionPartModel.prototype.remove = function () {
this.transclusion.removePart( this );
};
/**
* Get serialized representation of transclusion part.
*
* @returns {Mixed} Serialized representation, or undefined if empty
*/
ve.dm.MWTransclusionPartModel.prototype.serialize = function () {
return undefined;
};
/**
* Get the wikitext for this part.
*
* @returns {string} Wikitext
*/
ve.dm.MWTransclusionPartModel.prototype.getWikitext = function () {
return '';
};