jenkins-bot has submitted this change and it was merged. 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(+), 24 deletions(-) Approvals: Nikerabbit: Looks good to me, approved jenkins-bot: Verified diff --git a/Resources.php b/Resources.php index 865b0bf..114c366 100644 --- a/Resources.php +++ b/Resources.php @@ -484,9 +484,9 @@ 'ext.cx.model', 'json', 'mediawiki.api.edit', - 'mediawiki.cookie', 'ext.cx.publish.dialog', 'ext.cx.sitemapper', + 'ext.cx.tours.publish.init', ), 'messages' => array( 'cx-publish-page-success', @@ -515,6 +515,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: merged Gerrit-Change-Id: I366b11168c64fa0ece6dc6bef57dc740a7b06e64 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/ContentTranslation Gerrit-Branch: master Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com> Gerrit-Reviewer: Amire80 <amir.ahar...@mail.huji.ac.il> 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