extensions/VisualEditor/modules/ve-mw/dm/models/ve.dm.MWTransclusionContentModel.js
raw symbols SCIP| 1 | /*! |
| 2 | * VisualEditor DataModel MWTransclusionContentModel class. |
| 3 | * |
| 4 | * @copyright See AUTHORS.txt |
| 5 | * @license The MIT License (MIT); see LICENSE.txt |
| 6 | */ |
| 7 | |
| 8 | /** |
| 9 | * Represents a raw wikitext snippet that is part of an unbalanced sequence of template invocations. |
| 10 | * Meant to be an item in a {@see ve.dm.MWTransclusionModel}. Holds a back-reference to it's parent. |
| 11 | * |
| 12 | * @class |
| 13 | * @extends ve.dm.MWTransclusionPartModel |
| 14 | * |
| 15 | * @constructor |
| 16 | * @param {ve.dm.MWTransclusionModel} transclusion |
| 17 | * @param {string} [wikitext=''] |
| 18 | */ |
| 19 | ve.dm.MWTransclusionContentModel = function VeDmMWTransclusionContentModel( transclusion, wikitext ) { |
| 20 | // Parent constructor |
| 21 | ve.dm.MWTransclusionContentModel.super.call( this, transclusion ); |
| 22 | |
| 23 | // Properties |
| 24 | this.wikitext = wikitext || ''; |
| 25 | }; |
| 26 | |
| 27 | /* Inheritance */ |
| 28 | |
| 29 | OO.inheritClass( ve.dm.MWTransclusionContentModel, ve.dm.MWTransclusionPartModel ); |
| 30 | |
| 31 | /* Events */ |
| 32 | |
| 33 | /** |
| 34 | * Emitted when the wikitext changed. |
| 35 | * |
| 36 | * @event ve.dm.MWTransclusionContentModel#change |
| 37 | */ |
| 38 | |
| 39 | /* Methods */ |
| 40 | |
| 41 | /** |
| 42 | * @param {string} wikitext |
| 43 | * @fires ve.dm.MWTransclusionContentModel#change |
| 44 | */ |
| 45 | ve.dm.MWTransclusionContentModel.prototype.setWikitext = function ( wikitext ) { |
| 46 | if ( this.wikitext !== wikitext ) { |
| 47 | this.wikitext = wikitext; |
| 48 | this.emit( 'change' ); |
| 49 | } |
| 50 | }; |
| 51 | |
| 52 | /** |
| 53 | * @inheritdoc |
| 54 | */ |
| 55 | ve.dm.MWTransclusionContentModel.prototype.serialize = function () { |
| 56 | return this.wikitext; |
| 57 | }; |
| 58 | |
| 59 | /** |
| 60 | * @inheritdoc |
| 61 | */ |
| 62 | ve.dm.MWTransclusionContentModel.prototype.containsValuableData = function () { |
| 63 | return this.wikitext !== ''; |
| 64 | }; |