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

Change subject: Populate mw.cx with basic context of translation
......................................................................


Populate mw.cx with basic context of translation

Change-Id: Ia74f95bc283a6b218b9fa897bce82feec02400d1
---
M modules/source/ext.cx.source.js
M modules/translation/ext.cx.translation.js
2 files changed, 19 insertions(+), 21 deletions(-)

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



diff --git a/modules/source/ext.cx.source.js b/modules/source/ext.cx.source.js
index 71f8a7d..9bf7088 100644
--- a/modules/source/ext.cx.source.js
+++ b/modules/source/ext.cx.source.js
@@ -19,31 +19,30 @@
        function ContentTranslationSource( element, options ) {
                this.$container = $( element );
                this.options = $.extend( true, {}, $.fn.cxSource.defaults, 
options );
-               this.page = null;
                this.$title = null;
                this.$content = null;
                this.init();
        }
 
        ContentTranslationSource.prototype.init = function () {
-               this.page = new mw.Uri().query.page;
+               mw.cx.sourceTitle = new mw.Uri().query.page;
                this.render();
                this.load();
                this.listen();
        };
 
        ContentTranslationSource.prototype.render = function () {
-               var contentLanguage = mw.config.get( 'wgContentLanguage' );
+               mw.cx.sourceLanguage = mw.config.get( 'wgContentLanguage' );
 
                this.$container.prop( {
-                       lang: contentLanguage,
-                       dir: $.uls.data.getDir( contentLanguage )
+                       lang: mw.cx.sourceLanguage,
+                       dir: $.uls.data.getDir( mw.cx.sourceLanguage )
                } );
 
                this.$container.append(
                        $( '<h2>' )
                                .addClass( 'cx-column__title' )
-                               .text( this.page )
+                               .text( mw.cx.sourceTitle )
                );
 
                this.$container.append(
@@ -52,13 +51,13 @@
                                .append(
                                        $( '<span>' )
                                                .addClass( 
'cx-column__language-label' )
-                                               .text( $.uls.data.getAutonym( 
contentLanguage ) ),
+                                               .text( $.uls.data.getAutonym( 
mw.cx.sourceLanguage ) ),
                                        $( '<span>' )
                                                .addClass( 
'cx-column__sub-heading__view-page' )
                                                .html(
                                                        mw.message(
                                                                
'cx-source-view-page',
-                                                               mw.util.getUrl( 
this.page )
+                                                               mw.util.getUrl( 
mw.cx.sourceTitle )
                                                        ).parse()
                                                )
                                )
@@ -67,7 +66,7 @@
                this.$container.append(
                        $( '<div>' )
                                .addClass( 'cx-column__content' )
-                               .text( mw.msg( 'cx-source-loading', this.page ) 
)
+                               .text( mw.msg( 'cx-source-loading', 
mw.cx.sourceTitle ) )
                );
                this.$title = this.$container.find( '.cx-column__title' );
                this.$content = this.$container.find( '.cx-column__content' );
@@ -79,7 +78,7 @@
 
                api.get( {
                        action: 'parse',
-                       page: this.page,
+                       page: mw.cx.sourceTitle,
                        disablepp: true
                } ).done( function ( result ) {
                        cxSource.$title.html( result.parse.title );
diff --git a/modules/translation/ext.cx.translation.js 
b/modules/translation/ext.cx.translation.js
index e991cbf..d79d5b1 100644
--- a/modules/translation/ext.cx.translation.js
+++ b/modules/translation/ext.cx.translation.js
@@ -19,14 +19,13 @@
        function ContentTranslationEditor( element, options ) {
                this.$container = $( element );
                this.options = $.extend( true, {}, $.fn.cxTranslation.defaults, 
options );
-               this.language = '';
                this.$title = null;
                this.$content = null;
                this.init();
        }
 
        ContentTranslationEditor.prototype.init = function () {
-               this.language = new mw.Uri().query.lang || '';
+               mw.cx.targetLanguage = new mw.Uri().query.lang || '';
                this.render();
                this.listen();
        };
@@ -34,10 +33,10 @@
        ContentTranslationEditor.prototype.render = function () {
                var $content;
 
-               if ( this.language ) {
+               if ( mw.cx.targetLanguage ) {
                        this.$container.prop( {
-                               lang: this.language,
-                               dir: $.uls.data.getDir( this.language )
+                               lang: mw.cx.targetLanguage,
+                               dir: $.uls.data.getDir( mw.cx.targetLanguage )
                        } );
                }
 
@@ -48,10 +47,10 @@
                                .text( $( '.cx-column--source 
.cx-column__title' ).text() )
                );
 
-               if ( this.language ) {
+               if ( mw.cx.targetLanguage ) {
                        this.$container.prop( {
-                               lang: this.language,
-                               dir: $.uls.data.getDir( this.language )
+                               lang: mw.cx.targetLanguage,
+                               dir: $.uls.data.getDir( mw.cx.targetLanguage )
                        } );
 
                        this.$container.append(
@@ -60,7 +59,7 @@
                                        .append(
                                                $( '<span>' )
                                                        .addClass( 
'cx-column__language-label' )
-                                                       .text( 
$.uls.data.getAutonym( this.language ) )
+                                                       .text( 
$.uls.data.getAutonym( mw.cx.targetLanguage ) )
                                        )
                        );
                }
@@ -94,8 +93,8 @@
                var contentTranslationEditor = this;
 
                $.post( mw.config.get( 'wgContentTranslationServerURL' ), {
-                       sourcelang: this.language,
-                       targetlang: $( '.cx-column--source' ).prop( 'lang' ),
+                       sourcelang: mw.cx.sourceLanguage,
+                       targetlang: mw.cx.targetLanguage,
                        sourcetext: data
                } ).done( function ( response ) {
                        contentTranslationEditor.$content.html( response );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia74f95bc283a6b218b9fa897bce82feec02400d1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com>
Gerrit-Reviewer: Nikerabbit <niklas.laxst...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to