summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'MLEB/Translate/resources/src/ve-translate')
-rw-r--r--MLEB/Translate/resources/src/ve-translate/.eslintrc.json5
-rw-r--r--MLEB/Translate/resources/src/ve-translate/ve.ce.MWTranslateAnnotationNode.js31
-rw-r--r--MLEB/Translate/resources/src/ve-translate/ve.dm.MWTranslateAnnotationNode.js58
-rw-r--r--MLEB/Translate/resources/src/ve-translate/ve.ui.MWTranslateAnnotationContextItem.js64
4 files changed, 158 insertions, 0 deletions
diff --git a/MLEB/Translate/resources/src/ve-translate/.eslintrc.json b/MLEB/Translate/resources/src/ve-translate/.eslintrc.json
new file mode 100644
index 00000000..1d9cfb0a
--- /dev/null
+++ b/MLEB/Translate/resources/src/ve-translate/.eslintrc.json
@@ -0,0 +1,5 @@
+{
+ "globals": {
+ "ve": "readonly"
+ }
+}
diff --git a/MLEB/Translate/resources/src/ve-translate/ve.ce.MWTranslateAnnotationNode.js b/MLEB/Translate/resources/src/ve-translate/ve.ce.MWTranslateAnnotationNode.js
new file mode 100644
index 00000000..1d000e11
--- /dev/null
+++ b/MLEB/Translate/resources/src/ve-translate/ve.ce.MWTranslateAnnotationNode.js
@@ -0,0 +1,31 @@
+/*!
+ * VisualEditor ContentEditable MWTranslateAnnotationNode class.
+ */
+
+/**
+ * ContentEditable MediaWiki translate annotation node.
+ *
+ * @class
+ * @abstract
+ * @extends ve.ce.MWAnnotationNode
+ *
+ * @constructor
+ * @param {ve.dm.MWTranslateAnnotationNode} model Model to observe
+ * @param {Object} [config] Configuration options
+ */
+ve.ce.MWTranslateAnnotationNode = function VeCeMWTranslateAnnotationNode() {
+ // Parent constructor
+ ve.ce.MWTranslateAnnotationNode.super.apply( this, arguments );
+};
+
+/* Inheritance */
+
+OO.inheritClass( ve.ce.MWTranslateAnnotationNode, ve.ce.MWAnnotationNode );
+
+/* Static members */
+
+ve.ce.MWTranslateAnnotationNode.static.name = 'mwTranslateAnnotation';
+
+/* Registration */
+
+ve.ce.nodeFactory.register( ve.ce.MWTranslateAnnotationNode );
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 );
diff --git a/MLEB/Translate/resources/src/ve-translate/ve.ui.MWTranslateAnnotationContextItem.js b/MLEB/Translate/resources/src/ve-translate/ve.ui.MWTranslateAnnotationContextItem.js
new file mode 100644
index 00000000..a69a0953
--- /dev/null
+++ b/MLEB/Translate/resources/src/ve-translate/ve.ui.MWTranslateAnnotationContextItem.js
@@ -0,0 +1,64 @@
+/*!
+ * VisualEditor MWTranslateAnnotationContextItem class.
+ */
+
+/**
+ * Context item for a MWTranslateAnnotation
+ *
+ * @class
+ * @extends ve.ui.MWAnnotationContextItem
+ *
+ * @constructor
+ * @param {ve.ui.Context} context Context item is in
+ * @param {ve.dm.Model} model Model item is related to
+ * @param {Object} config Configuration options
+ */
+ve.ui.MWTranslateAnnotationContextItem = function VeUiMWTranslateAnnotationContextItem() {
+ // Parent constructor
+ ve.ui.MWTranslateAnnotationContextItem.super.apply( this, arguments );
+};
+
+/* Inheritance */
+
+OO.inheritClass( ve.ui.MWTranslateAnnotationContextItem, ve.ui.MWAnnotationContextItem );
+
+/* Static Properties */
+
+ve.ui.MWTranslateAnnotationContextItem.static.name = 'mwTranslateAnnotation';
+
+ve.ui.MWTranslateAnnotationContextItem.static.modelClasses = [
+ ve.dm.MWTranslateAnnotationNode
+];
+
+/* Methods */
+
+ve.ui.MWTranslateAnnotationContextItem.prototype.getLabelMessage = function () {
+ var map = {
+ 'mw:Annotation/translate': 'visualeditor-annotations-translate-start',
+ 'mw:Annotation/translate/End': 'visualeditor-annotations-translate-end',
+ 'mw:Annotation/tvar': 'visualeditor-annotations-tvar-start',
+ 'mw:Annotation/tvar/End': 'visualeditor-annotations-tvar-end'
+ };
+
+ var type = this.model.getAttribute( 'type' );
+ // eslint-disable-next-line mediawiki/msg-doc
+ var msg = mw.message( map[ type ] );
+ return msg.text();
+};
+
+ve.ui.MWTranslateAnnotationContextItem.prototype.getDescriptionMessage = function () {
+ var type = this.model.getAttribute( 'type' );
+ if ( type.indexOf( '/End', type.length - 4 ) !== -1 ) {
+ return '';
+ }
+ var map = {
+ 'mw:Annotation/translate': 'visualeditor-annotations-translate-description',
+ 'mw:Annotation/tvar': 'visualeditor-annotations-tvar-description'
+ };
+
+ // eslint-disable-next-line mediawiki/msg-doc
+ var msg = mw.message( map[ type ] );
+ return msg.parseDom();
+};
+
+ve.ui.contextItemFactory.register( ve.ui.MWTranslateAnnotationContextItem );