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

Change subject: MT: Do not show source text till the result of MT is known.
......................................................................


MT: Do not show source text till the result of MT is known.

* Using css opacity to block the display of source text.
* Avoid the flash of text in translation section.
* Once MT is ready, show the MT card

Change-Id: I80539fe3e935635d32f09c0910e9962223c4fb50
---
M modules/tools/ext.cx.tools.mt.js
1 file changed, 11 insertions(+), 3 deletions(-)

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



diff --git a/modules/tools/ext.cx.tools.mt.js b/modules/tools/ext.cx.tools.mt.js
index 4e96c49..5cb6fd1 100644
--- a/modules/tools/ext.cx.tools.mt.js
+++ b/modules/tools/ext.cx.tools.mt.js
@@ -70,13 +70,17 @@
        $.fn.machineTranslate = function () {
                var $section = $( this );
 
+               // Hide the translation section till we get response from MT.
+               // Using opacity here because we don't want to disturb the 
alignment by
+               // hiding using display: none.
+               $section.css( 'opacity', 0 );
                getProviders( mw.cx.sourceLanguage, mw.cx.targetLanguage 
).then( function () {
                        var sourceContent;
 
                        if ( MTControlCard.provider === disableMT ) {
                                mw.hook( 'mw.cx.translation.postMT' ).fire( 
$section );
 
-                               return;
+                               return this;
                        }
 
                        sourceContent = $section[ 0 ].outerHTML;
@@ -85,9 +89,13 @@
                                        if ( translation ) {
                                                $section.html( $( translation 
).children().html() );
                                        }
-                               } ).always( function () {
-                                       $section.data( 'cx-mt', true );
+                               } )
+                               .always( function () {
+                                       $section
+                                               .css( 'opacity', 1 )
+                                               .data( 'cx-mt', true );
                                        mw.hook( 'mw.cx.translation.change' 
).fire( $section );
+                                       mw.hook( 'mw.cx.translation.focus' 
).fire( $section );
                                        mw.hook( 'mw.cx.translation.postMT' 
).fire( $section );
                                } );
                } );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I80539fe3e935635d32f09c0910e9962223c4fb50
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <[email protected]>
Gerrit-Reviewer: Amire80 <[email protected]>
Gerrit-Reviewer: Divec <[email protected]>
Gerrit-Reviewer: Pginer <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to