2013-06-11 19:16:04 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor DataModel MWTransclusionPartModel class.
|
|
|
|
*
|
|
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* MediaWiki transclusion part model.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @mixins ve.EventEmitter
|
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @param {ve.dm.MWTransclusionModel} transclusion Transclusion
|
2013-07-11 00:33:21 +00:00
|
|
|
* @param {string} [origin] Origin of part, e.g. 'data' or 'user'
|
2013-06-11 19:16:04 +00:00
|
|
|
*/
|
2013-07-11 00:33:21 +00:00
|
|
|
ve.dm.MWTransclusionPartModel = function VeDmMWTransclusionPartModel( transclusion, origin ) {
|
2013-06-11 19:16:04 +00:00
|
|
|
// Mixin constructors
|
|
|
|
ve.EventEmitter.call( this );
|
|
|
|
|
|
|
|
// Properties
|
|
|
|
this.transclusion = transclusion;
|
2013-07-11 00:33:21 +00:00
|
|
|
this.origin = origin;
|
2013-06-18 19:39:21 +00:00
|
|
|
this.id = 'part_' + this.transclusion.getUniquePartId();
|
2013-06-11 19:16:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
ve.mixinClass( ve.dm.MWTransclusionPartModel, ve.EventEmitter );
|
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get transclusion part is in.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @returns {ve.dm.MWTransclusionModel} Transclusion
|
|
|
|
*/
|
|
|
|
ve.dm.MWTransclusionPartModel.prototype.getTransclusion = function () {
|
|
|
|
return this.transclusion;
|
|
|
|
};
|
|
|
|
|
2013-07-11 00:33:21 +00:00
|
|
|
/**
|
|
|
|
* Get part origin.
|
|
|
|
*
|
|
|
|
* @returns {string} Origin
|
|
|
|
*/
|
|
|
|
ve.dm.MWTransclusionPartModel.prototype.getOrigin = function () {
|
|
|
|
return this.origin;
|
|
|
|
};
|
|
|
|
|
2013-06-11 19:16:04 +00:00
|
|
|
/**
|
|
|
|
* Get a unique part ID within the transclusion.
|
|
|
|
*
|
2013-07-11 00:33:21 +00:00
|
|
|
* @returns {string} Unique ID
|
2013-06-11 19:16:04 +00:00
|
|
|
*/
|
|
|
|
ve.dm.MWTransclusionPartModel.prototype.getId = function () {
|
|
|
|
return this.id;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove part from transclusion.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
ve.dm.MWTransclusionPartModel.prototype.remove = function () {
|
|
|
|
this.transclusion.removePart( this );
|
|
|
|
};
|