Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/140053

Change subject: Use experimental WSYSIWYG editor conditionally
......................................................................

Use experimental WSYSIWYG editor conditionally

Introducing boolean global $wgContentTranslationWYSIWYGEditor
Default value is false.

Change-Id: I9f604f53ef333a9f980aefdc628abd25fa3f4728
---
M ContentTranslation.hooks.php
M ContentTranslation.php
M Resources.php
M modules/editor/ext.cx.editor.js
4 files changed, 21 insertions(+), 11 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/53/140053/1

diff --git a/ContentTranslation.hooks.php b/ContentTranslation.hooks.php
index 54b4fda..d87a812 100644
--- a/ContentTranslation.hooks.php
+++ b/ContentTranslation.hooks.php
@@ -16,7 +16,7 @@
         * Hook: BeforePageDisplay
         */
        public static function addModules( $out, $skin ) {
-               global $wgContentTranslationEventLogging;
+               global $wgContentTranslationEventLogging, 
$wgContentTranslationWYSIWYGEditor;
 
                $title = $out->getTitle();
                $user = $out->getUser();
@@ -41,6 +41,13 @@
                        ) );
                }
 
+               if ( $wgContentTranslationWYSIWYGEditor ) {
+                       // WYSIWYGEditor
+                       $out->addModules( 'ext.cx.editor.medium' );
+               } else {
+                       // Just ContentEditable
+                       $out->addModules( 'ext.cx.editor' );
+               }
                return true;
        }
 
@@ -75,11 +82,12 @@
         * @return bool
         */
        public static function addConfig( &$vars ) {
-               global $wgContentTranslationServerURL, 
$wgContentTranslationDomainTemplate;
+               global $wgContentTranslationServerURL, 
$wgContentTranslationDomainTemplate,
+                       $wgContentTranslationWYSIWYGEditor;
 
                $vars['wgContentTranslationServerURL'] = 
$wgContentTranslationServerURL;
                $vars['wgContentTranslationDomainTemplate'] = 
$wgContentTranslationDomainTemplate;
-
+               $vars['wgContentTranslationWYSIWYGEditor'] = 
$wgContentTranslationWYSIWYGEditor;
                return true;
        }
 }
diff --git a/ContentTranslation.php b/ContentTranslation.php
index 0f91931..12804eb 100644
--- a/ContentTranslation.php
+++ b/ContentTranslation.php
@@ -46,7 +46,7 @@
 
 // Content translation server URL
 $GLOBALS['wgContentTranslationServerURL'] = 'http://localhost:8080';
-
+$GLOBALS['wgContentTranslationWYSIWYGEditor'] = false;
 $GLOBALS['wgContentTranslationParsoid'] = array(
        'url' => 'http://parsoid.wmflabs.org/',
        'timeout' => 100 * 1000, // Parsoid timeout in milliseconds
diff --git a/Resources.php b/Resources.php
index 8d64aa3..8d0d61a 100644
--- a/Resources.php
+++ b/Resources.php
@@ -77,7 +77,6 @@
        'dependencies' => array(
                'jquery.uls.data',
                'mediawiki.Uri',
-               'ext.cx.editor'
        ),
        'styles' => array(
                'translation/styles/ext.cx.translation.less',
@@ -237,14 +236,16 @@
 $wgResourceModules['ext.cx.editor'] = array(
        'scripts' => array(
                'editor/ext.cx.editor.js',
+       ),
+) + $resourcePaths;
+
+$wgResourceModules['ext.cx.editor.medium'] = array(
+       'scripts' => array(
+               'editor/ext.cx.editor.js',
                'editor/medium/medium-editor.js'
        ),
        'styles' => array(
                'editor/medium/medium-editor.css',
                'editor/medium/theme/agora.css'
-       ),
-       'dependencies' => array(
-               'ext.cx.entrypoint',
-               'mediawiki.jqueryMsg',
        ),
 ) + $resourcePaths;
diff --git a/modules/editor/ext.cx.editor.js b/modules/editor/ext.cx.editor.js
index 6b7e755..dada243 100644
--- a/modules/editor/ext.cx.editor.js
+++ b/modules/editor/ext.cx.editor.js
@@ -43,8 +43,9 @@
                }
                // Make the element editable
                this.$editableElement.attr( 'contenteditable', true );
-               // Initialize a WYSIWYG editor
-               this.wysiwygEditor();
+               if ( mw.config.get( 'wgContentTranslationWYSIWYGEditor' ) ) {
+                       this.wysiwygEditor();
+               }
        };
 
        /**

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9f604f53ef333a9f980aefdc628abd25fa3f4728
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to