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

Change subject: Disable and enable the publish button according to translation
......................................................................


Disable and enable the publish button according to translation

Change-Id: Icb975cb646844e3d65d9749e134ca45ef78cfc8d
---
M modules/header/ext.cx.header.js
M modules/translation/ext.cx.translation.js
2 files changed, 17 insertions(+), 0 deletions(-)

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



diff --git a/modules/header/ext.cx.header.js b/modules/header/ext.cx.header.js
index 3ffbeae..78709e6 100644
--- a/modules/header/ext.cx.header.js
+++ b/modules/header/ext.cx.header.js
@@ -63,11 +63,23 @@
                );
        };
 
+       ContentTranslationHeader.prototype.setPublishButtonState = function () {
+               var translationText = $( '.cx-column--translation 
.cx-column__content' ).text();
+
+               // Disable the publish button if it has any non-space characters
+               this.$container.find( '.cx-header__publish' ).prop( {
+                       disabled: !translationText.match( /\S/ )
+               } );
+       };
+
        ContentTranslationHeader.prototype.listen = function () {
                this.$container.find( '.publish' ).on( 'click', function () {
                        mw.hook( 'mw.cx.publish' ).fire();
                } );
+
+               mw.hook( 'mw.cx.changeTranslation' ).add( $.proxy( 
this.setPublishButtonState, this ) );
        };
+
        $.fn.cxHeader = function ( options ) {
                return this.each( function () {
                        var $this = $( this ),
diff --git a/modules/translation/ext.cx.translation.js 
b/modules/translation/ext.cx.translation.js
index 3150d43..39c8551 100644
--- a/modules/translation/ext.cx.translation.js
+++ b/modules/translation/ext.cx.translation.js
@@ -70,17 +70,22 @@
                        .addClass( 'cx-column__content' );
 
                this.$container.append( $content );
+               mw.hook( 'mw.cx.changeTranslation' ).fire();
                this.$title = this.$container.find( '.cx-column__title' );
                this.$content = this.$container.find( '.cx-column__content' );
        };
 
        ContentTranslationEditor.prototype.listen = function () {
                mw.hook(  'mw.cx.translation.add' ).add( $.proxy( this.update, 
this ) );
+               this.$container.find( '.cx-column__content' ).on( 'input', 
function () {
+                       mw.hook( 'mw.cx.changeTranslation' ).fire();
+               } );
        };
 
        ContentTranslationEditor.prototype.update = function ( data ) {
                this.$content.html( data );
                mw.hook( 'mw.cx.progress' ).fire( 100 );
+               mw.hook( 'mw.cx.changeTranslation' ).fire();
        };
 
        $.fn.cxTranslation = function ( options ) {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Icb975cb646844e3d65d9749e134ca45ef78cfc8d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Amire80 <amir.ahar...@mail.huji.ac.il>
Gerrit-Reviewer: KartikMistry <kartik.mis...@gmail.com>
Gerrit-Reviewer: Santhosh <santhosh.thottin...@gmail.com>
Gerrit-Reviewer: SuchetaG <sucheta.ghos...@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