File: ve.dm.MWTransclusionPartModel.js

package info (click to toggle)
mediawiki 1%3A1.43.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 417,464 kB
  • sloc: php: 1,062,949; javascript: 664,290; sql: 9,714; python: 5,458; xml: 3,489; sh: 1,131; makefile: 64
file content (88 lines) | stat: -rw-r--r-- 2,417 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*!
 * VisualEditor DataModel MWTransclusionPartModel class.
 *
 * @copyright See AUTHORS.txt
 * @license The MIT License (MIT); see LICENSE.txt
 */

/**
 * Abstract base class for items in a {@see ve.dm.MWTransclusionModel}. Holds a back-reference to
 * it's parent. Currently used for:
 * - {@see ve.dm.MWTemplateModel} for a single template invocation.
 * - {@see ve.dm.MWTemplatePlaceholderModel} while searching for a template name to be added.
 * - {@see ve.dm.MWTransclusionContentModel} for a raw wikitext snippet.
 *
 * @abstract
 * @class
 * @mixes OO.EventEmitter
 *
 * @constructor
 * @param {ve.dm.MWTransclusionModel} transclusion
 */
ve.dm.MWTransclusionPartModel = function VeDmMWTransclusionPartModel( transclusion ) {
	// Mixin constructors
	OO.EventEmitter.call( this );

	// Properties
	this.transclusion = transclusion;
	this.id = this.transclusion.nextUniquePartId();
};

/* Inheritance */

OO.mixinClass( ve.dm.MWTransclusionPartModel, OO.EventEmitter );

/* Events */

/**
 * Emitted when anything changed in the content the part represents, e.g. a parameter was added to a
 * template, or a value edited.
 *
 * @event ve.dm.MWTransclusionPartModel#change
 */

/* Methods */

/**
 * Get transclusion part is in.
 *
 * @return {ve.dm.MWTransclusionModel} Transclusion
 */
ve.dm.MWTransclusionPartModel.prototype.getTransclusion = function () {
	return this.transclusion;
};

/**
 * Get a unique part ID within the transclusion.
 *
 * @return {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 );
};

/**
 * Create a serialized representation of this part. Contains all information needed to recreate the
 * original wikitext, including extra whitespace. Used in
 * {@see ve.dm.MWTransclusionModel.getPlainObject}. The corresponding deserializer is in
 * {@see ve.dm.MWTransclusionNode.static.getWikitext}.
 *
 * @return {Object|string|undefined} Serialized representation, raw wikitext, or undefined if empty
 */
ve.dm.MWTransclusionPartModel.prototype.serialize = function () {
	return undefined;
};

/**
 * @return {boolean} True if there is meaningful user input that was not e.g. auto-generated
 */
ve.dm.MWTransclusionPartModel.prototype.containsValuableData = function () {
	return false;
};