Santhosh has uploaded a new change for review.

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

Change subject: Refactor the guided tour initialization out of publish module
......................................................................

Refactor the guided tour initialization out of publish module

Move that code to modules/tours/ext.cx.tours.publish.init.js

Change-Id: I366b11168c64fa0ece6dc6bef57dc740a7b06e64
---
M Resources.php
M modules/publish/ext.cx.publish.js
A modules/tours/ext.cx.tours.publish.init.js
3 files changed, 46 insertions(+), 23 deletions(-)


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

diff --git a/Resources.php b/Resources.php
index 865b0bf..ffa260b 100644
--- a/Resources.php
+++ b/Resources.php
@@ -487,6 +487,7 @@
                'mediawiki.cookie',
                'ext.cx.publish.dialog',
                'ext.cx.sitemapper',
+               'ext.cx.tours.publish.init',
        ),
        'messages' => array(
                'cx-publish-page-success',
@@ -515,6 +516,15 @@
        ),
 ) + $resourcePaths;
 
+$wgResourceModules['ext.cx.tours.publish.init'] = array(
+       'scripts' => array(
+               'tours/ext.cx.tours.publish.init.js',
+       ),
+       'dependencies' => array(
+               'mediawiki.cookie',
+       ),
+) + $resourcePaths;
+
 $wgResourceModules['ext.cx.eventlogging'] = array(
        'scripts' => 'eventlogging/ext.cx.eventlogging.js',
        'dependencies' => array(
diff --git a/modules/publish/ext.cx.publish.js 
b/modules/publish/ext.cx.publish.js
index d937a54..c6a6c75 100644
--- a/modules/publish/ext.cx.publish.js
+++ b/modules/publish/ext.cx.publish.js
@@ -209,7 +209,8 @@
                                                        ) );
                                                mw.hook( 
'mw.cx.translation.published' ).fire(
                                                        mw.cx.sourceLanguage,
-                                                       mw.cx.targetLanguage
+                                                       mw.cx.targetLanguage,
+                                                       targetTitle
                                                );
                                                mw.cx.dirty = false;
                                        } ).fail( function ( code, details ) {
@@ -239,8 +240,6 @@
                                        $publishButton.cxPublishingDialog();
                                }
                        } );
-
-               initGuidedTour( targetTitle );
        }
 
        /**
@@ -267,26 +266,6 @@
                } );
 
                return $content.html();
-       }
-
-       /**
-        * If GuidedTour is available, set cookies to start a tour.
-        * @param {string} translatedTitle
-        */
-       function initGuidedTour( translatedTitle ) {
-               if ( !mw.guidedTour ) {
-                       return;
-               }
-
-               mw.cookie.set(
-                       '-cx-published',
-                       JSON.stringify( {
-                               translatedTitle: translatedTitle,
-                               username: mw.user.getName()
-                       } )
-               );
-
-               mw.guidedTour.setTourCookie( 'cxpublish', 'suggestmovestart' );
        }
 
        // Expose the CXPublish
diff --git a/modules/tours/ext.cx.tours.publish.init.js 
b/modules/tours/ext.cx.tours.publish.init.js
new file mode 100644
index 0000000..a789f8d
--- /dev/null
+++ b/modules/tours/ext.cx.tours.publish.init.js
@@ -0,0 +1,34 @@
+/*
+ * Guided Tour for ContentTranslation publishing - Initialization module.
+ *
+ * @file
+ * @ingroup Extensions
+ * @copyright See AUTHORS.txt
+ * @license GPL-2.0+
+ */
+( function ( $, mw ) {
+       'use strict';
+       /**
+        * If GuidedTour is available, set cookies to start a tour.
+        * @param {string} translatedTitle
+        */
+       function initGuidedTourAfterPublish( translatedTitle ) {
+               if ( !mw.guidedTour ) {
+                       return;
+               }
+
+               mw.cookie.set(
+                       '-cx-published',
+                       JSON.stringify( {
+                               translatedTitle: translatedTitle,
+                               username: mw.user.getName()
+                       } )
+               );
+
+               mw.guidedTour.setTourCookie( 'cxpublish', 'suggestmovestart' );
+       }
+
+       mw.hook( 'mw.cx.translation.published' ).add( function ( 
sourceLanguage, targetLanguage, title ) {
+               initGuidedTourAfterPublish( title );
+       } );
+}( jQuery, mediaWiki ) );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I366b11168c64fa0ece6dc6bef57dc740a7b06e64
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