jenkins-bot has submitted this change and it was merged.

Change subject: Language Inspector: CE / DM
......................................................................


Language Inspector: CE / DM

This is the infrastructure for the Language Inspector prototype, defining
the dm and ce pieces of the <span lang='xx' dir='yy'> annotations. It also
sets up a visual indicator for language blocks (with informational tooltip
for the user while editing. The UI is built on top of this.

Bug: 47759
Change-Id: I239eef5124e29369ea9c5d8c0f49b2f6a61bc053
---
M VisualEditor.i18n.php
M VisualEditor.php
A modules/ve/ce/annotations/ve.ce.LanguageAnnotation.js
M modules/ve/ce/styles/ve.ce.Node.css
A modules/ve/dm/annotations/ve.dm.LanguageAnnotation.js
5 files changed, 135 insertions(+), 0 deletions(-)

Approvals:
  Catrope: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/VisualEditor.i18n.php b/VisualEditor.i18n.php
index f206557..666a098 100644
--- a/VisualEditor.i18n.php
+++ b/VisualEditor.i18n.php
@@ -113,6 +113,8 @@
        'visualeditor-linkinspector-suggest-new-page' => 'New page',
        'visualeditor-linkinspector-title' => 'Hyperlink',
        'visualeditor-mwmathinspector-title' => 'LaTeX',
+       'visualeditor-languageinspector-block-tooltip' => 'Language Block: 
$1$2',
+       'visualeditor-languageinspector-block-tooltip-rtldirection' => ': Right 
to Left',
        'visualeditor-listbutton-bullet-tooltip' => 'Bullet list',
        'visualeditor-listbutton-number-tooltip' => 'Numbered list',
        'visualeditor-loadwarning' => 'Error loading data from server: $1. 
Would you like to retry?',
@@ -372,6 +374,8 @@
        'visualeditor-mwmathinspector-title' => 'Used as title for 
MathInspector.
 
 See [[w:LaTeX]].',
+       'visualeditor-languageinspector-block-tooltip' => 'Tooltip identifying 
language block properties inside VisualEditor. $1 is the language code (for 
example "en"); $2 the rtl label 
{{msg-mw|visualeditor-languageinspector-block-tooltip-rtldirection}}',
+       'visualeditor-languageinspector-block-tooltip-rtldirection' => 'The 
label "Right To Left" at the end of the tooltip if the language is RTL.',
        'visualeditor-listbutton-bullet-tooltip' => 'Tooltip text for the 
bullet list button',
        'visualeditor-listbutton-number-tooltip' => 'Tooltip text for the 
numbered list button',
        'visualeditor-loadwarning' => 'Text (JavaScript confirm()) shown when 
the editor fails to load properly.
diff --git a/VisualEditor.php b/VisualEditor.php
index 61086f5..585c0a9 100644
--- a/VisualEditor.php
+++ b/VisualEditor.php
@@ -656,6 +656,8 @@
                        'visualeditor-linkinspector-suggest-matching-page',
                        'visualeditor-linkinspector-suggest-new-page',
                        'visualeditor-linkinspector-title',
+                       'visualeditor-languageinspector-block-tooltip',
+                       
'visualeditor-languageinspector-block-tooltip-rtldirection',
                        'visualeditor-listbutton-bullet-tooltip',
                        'visualeditor-listbutton-number-tooltip',
                        'visualeditor-media-input-placeholder',
@@ -704,6 +706,8 @@
                        've-mw/dm/nodes/ve.dm.MWMathNode.js',
                        've-mw/ui/inspectors/ve.ui.MWMathInspector.js',
                        've-mw/ui/tools/buttons/ve.ui.MWMathButtonTool.js',
+                       've/dm/annotations/ve.dm.LanguageAnnotation.js',
+                       've/ce/annotations/ve.ce.LanguageAnnotation.js',
                ),
                'dependencies' => array(
                        'ext.visualEditor.core',
diff --git a/modules/ve/ce/annotations/ve.ce.LanguageAnnotation.js 
b/modules/ve/ce/annotations/ve.ce.LanguageAnnotation.js
new file mode 100644
index 0000000..fc1c193
--- /dev/null
+++ b/modules/ve/ce/annotations/ve.ce.LanguageAnnotation.js
@@ -0,0 +1,52 @@
+/*!
+ * VisualEditor ContentEditable LanguageAnnotation class.
+ *
+ * @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
+ * @license The MIT License (MIT); see LICENSE.txt
+ */
+
+/**
+ * ContentEditable language annotation.
+ *
+ * @class
+ * @extends ve.ce.Annotation
+ * @constructor
+ * @param {ve.dm.LanguageAnnotation} model Model to observe
+ * @param {Object} [config] Config options
+ */
+ve.ce.LanguageAnnotation = function VeCeLanguageAnnotation( model, config ) {
+       var msgDir = '';
+       // Parent constructor
+       ve.ce.Annotation.call( this, model, config );
+
+       // DOM changes
+       this.$.addClass( 've-ce-LanguageAnnotation' );
+
+       this.$.attr( 'lang', model.getAttribute( 'lang' ) );
+       this.$.attr( 'dir', model.getAttribute( 'dir' ) );
+
+       // If the language is "RTL", make a mention in the tooltip
+       if ( model.getAttribute( 'dir' ) !== 'ltr' ) {
+               msgDir = ve.msg( 
'visualeditor-languageinspector-block-tooltip-rtldirection' );
+       }
+
+       // TODO:
+       // When ULS is active, use $.uls.getAutonym(lang) to get the full
+       // language name in the tooltip
+       // (eg 'he' will be 'Hebrew' and 'en' will be 'English')
+       this.$.attr( 'title' , ve.msg( 
'visualeditor-languageinspector-block-tooltip', model.getAttribute( 'lang' ), 
msgDir ) );
+};
+
+/* Inheritance */
+
+ve.inheritClass( ve.ce.LanguageAnnotation, ve.ce.Annotation );
+
+/* Static Properties */
+
+ve.ce.LanguageAnnotation.static.name = 'language';
+
+ve.ce.LanguageAnnotation.static.tagName = 'span';
+
+/* Registration */
+
+ve.ce.annotationFactory.register( ve.ce.LanguageAnnotation );
diff --git a/modules/ve/ce/styles/ve.ce.Node.css 
b/modules/ve/ce/styles/ve.ce.Node.css
index 5fca350..6458fb6 100644
--- a/modules/ve/ce/styles/ve.ce.Node.css
+++ b/modules/ve/ce/styles/ve.ce.Node.css
@@ -186,3 +186,9 @@
        margin: 0;
        padding: 0;
 }
+
+/* Language Annotation */
+.ve-ce-LanguageAnnotation {
+       border-bottom: dashed #ccc 1px;
+       background-color: #ebf3f5;
+}
diff --git a/modules/ve/dm/annotations/ve.dm.LanguageAnnotation.js 
b/modules/ve/dm/annotations/ve.dm.LanguageAnnotation.js
new file mode 100644
index 0000000..bf2311b
--- /dev/null
+++ b/modules/ve/dm/annotations/ve.dm.LanguageAnnotation.js
@@ -0,0 +1,69 @@
+/*!
+ * VisualEditor DataModel LanguageAnnotation class.
+ *
+ * @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
+ * @license The MIT License (MIT); see LICENSE.txt
+ */
+
+/**
+ * DataModel language annotation.
+ *
+ * Represents `<span>` tags with 'lang' and 'dir' properties.
+ *
+ * @class
+ * @extends ve.dm.Annotation
+ * @constructor
+ * @param {Object} element
+ */
+ve.dm.LanguageAnnotation = function VeDmLanguageAnnotation( element ) {
+       // Parent constructor
+       ve.dm.Annotation.call( this, element );
+};
+
+/* Inheritance */
+
+ve.inheritClass( ve.dm.LanguageAnnotation, ve.dm.Annotation );
+
+/* Static Properties */
+
+ve.dm.LanguageAnnotation.static.name = 'language';
+
+ve.dm.LanguageAnnotation.static.matchTagNames = [ 'span' ];
+
+ve.dm.LanguageAnnotation.static.matchFunction = function( domElement ) {
+       return ( domElement.getAttribute( 'lang' ) || domElement.getAttribute( 
'dir' ) );
+};
+
+ve.dm.LanguageAnnotation.static.applyToAppendedContent = false;
+
+ve.dm.LanguageAnnotation.static.toDataElement = function ( domElements ) {
+       return {
+               'type': 'language',
+               'attributes': {
+                       'lang': domElements[0].getAttribute( 'lang' ),
+                       'dir': domElements[0].getAttribute( 'dir' )
+               }
+       };
+};
+
+ve.dm.LanguageAnnotation.static.toDomElements = function ( dataElement, doc ) {
+       var domElement = doc.createElement( 'span' );
+       if ( dataElement.attributes.lang ) {
+               domElement.setAttribute( 'lang', dataElement.attributes.lang );
+       }
+       if ( dataElement.attributes.dir ) {
+               domElement.setAttribute( 'dir', dataElement.attributes.dir );
+       }
+
+       return [ domElement ];
+};
+
+/* Methods */
+
+// TODO:
+// Set up a proper comparable method for lang and dir attributes
+// ve.dm.LanguageAnnotation.prototype.getComparableObject
+
+/* Registration */
+
+ve.dm.modelRegistry.register( ve.dm.LanguageAnnotation );

-- 
To view, visit https://gerrit.wikimedia.org/r/70560
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I239eef5124e29369ea9c5d8c0f49b2f6a61bc053
Gerrit-PatchSet: 34
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo <[email protected]>
Gerrit-Reviewer: Amire80 <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Inez <[email protected]>
Gerrit-Reviewer: Trevor Parscal <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to