diff options
Diffstat (limited to 'MLEB/Translate/resources/src/ve-translate/ve.dm.MWTranslateAnnotationNode.js')
-rw-r--r-- | MLEB/Translate/resources/src/ve-translate/ve.dm.MWTranslateAnnotationNode.js | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/MLEB/Translate/resources/src/ve-translate/ve.dm.MWTranslateAnnotationNode.js b/MLEB/Translate/resources/src/ve-translate/ve.dm.MWTranslateAnnotationNode.js new file mode 100644 index 00000000..d2e8d898 --- /dev/null +++ b/MLEB/Translate/resources/src/ve-translate/ve.dm.MWTranslateAnnotationNode.js @@ -0,0 +1,58 @@ +/*! + * VisualEditor DataModel MWTranslateAnnotationNode class. + */ + +/** + * DataModel MediaWiki translate annotation node. + * + * @class + * @abstract + * @extends ve.dm.MWAnnotationNode + * + * @constructor + * @param {Object} [element] Reference to element in linear model + * @param {ve.dm.Node[]} [children] + */ +ve.dm.MWTranslateAnnotationNode = function VeDmMWTranslateAnnotationNode() { + // Parent constructor + ve.dm.MWTranslateAnnotationNode.super.apply( this, arguments ); +}; + +/* Inheritance */ + +OO.inheritClass( ve.dm.MWTranslateAnnotationNode, ve.dm.MWAnnotationNode ); + +/* Static members */ + +ve.dm.MWTranslateAnnotationNode.static.name = 'mwTranslateAnnotation'; + +ve.dm.MWTranslateAnnotationNode.static.matchRdfaTypes = [ + 'mw:Annotation/translate', + 'mw:Annotation/translate/End', + 'mw:Annotation/tvar', + 'mw:Annotation/tvar/End' +]; + +/* Methods */ + +ve.dm.MWTranslateAnnotationNode.static.toDataElement = function ( domElements ) { + // 'Parent' method + var element = ve.dm.MWTranslateAnnotationNode.super.static.toDataElement.call( this, domElements ); + + element.type = 'mwTranslateAnnotation'; + return element; +}; + +ve.dm.MWTranslateAnnotationNode.prototype.getWikitextTag = function () { + var map = { + 'mw:Annotation/translate': '<translate>', + 'mw:Annotation/translate/End': '</translate>', + 'mw:Annotation/tvar': '<tvar>', + 'mw:Annotation/tvar/End': '</tvar>' + }; + return map[ this.getAttribute( 'type' ) ]; +}; + +/* Registration */ + +ve.dm.modelRegistry.register( ve.dm.MWTranslateAnnotationNode ); |