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

Change subject: Implement support for post-edit with VisualEditor.
......................................................................


Implement support for post-edit with VisualEditor.

This preserves the existing API by introducing a private post-edit
variable that is set from the 'postEdit' hook.  That hook is used
for listening to both wikitext and VisualEditor.

Change-Id: Ib0e82866ed7306cbd8491a9719bbcfc7f0299773
---
M modules/ext.guidedTour.lib.js
1 file changed, 24 insertions(+), 9 deletions(-)

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



diff --git a/modules/ext.guidedTour.lib.js b/modules/ext.guidedTour.lib.js
index 9d8e142..9a2958f 100644
--- a/modules/ext.guidedTour.lib.js
+++ b/modules/ext.guidedTour.lib.js
@@ -36,7 +36,11 @@
                userId = mw.config.get( 'wgUserId' ),
                // Key is tour name, value is tour spec (specification).  A 
tour spec is
                // exactly what is passed in to defineTour.
-               definedTours = {};
+               definedTours = {},
+               // Initialized to false at page load
+               // Will be set true any time postEdit fires, including right 
after
+               // legacy wgPostEdit variable is set to true.
+               isPostEdit = false;
 
        /**
         * Setup default values for logging, unless they're logged out.  This 
doesn't mean
@@ -772,8 +776,8 @@
         *
         * @private
         */
-       function setupSkipThenUpdateDisplayListeners() {
-               var mwHooks, i;
+       function setupStepTransitionListeners() {
+               var generalSkipHooks, i;
 
                function skip() {
                        // I found this necessary when testing, probably to 
give the
@@ -783,13 +787,24 @@
                        }, 0 );
                }
 
-               mwHooks = [
-                       've.activationComplete',
+               // The next two are handled differently since they also require
+               // settings an internal boolean.
+               mw.hook( 'postEdit' ).add( function () {
+                       isPostEdit = true;
+                       skip();
+               } );
+
+               mw.hook( 've.activationComplete' ).add( function () {
+                       isPostEdit = false;
+                       skip();
+               } );
+
+               generalSkipHooks = [
                        've.deactivationComplete',
                        've.saveDialog.stateChanged'
                ];
-               for ( i = 0; i < mwHooks.length; i++ ) {
-                       mw.hook( mwHooks[i] ).add( skip );
+               for ( i = 0; i < generalSkipHooks.length; i++ ) {
+                       mw.hook( generalSkipHooks[i] ).add( skip );
                }
        }
 
@@ -828,7 +843,7 @@
 
                $( document ).ready( function () {
                        setupRepositionListeners();
-                       setupSkipThenUpdateDisplayListeners();
+                       setupStepTransitionListeners();
                        setupGuiderListeners();
                } );
        }
@@ -1241,7 +1256,7 @@
                 * @return {boolean} true if they just saved an edit, false 
otherwise
                 */
                isPostEdit: function () {
-                       return mw.config.get( 'wgPostEdit' );
+                       return isPostEdit;
                },
 
                // End shouldSkip bindings section

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib0e82866ed7306cbd8491a9719bbcfc7f0299773
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/GuidedTour
Gerrit-Branch: master
Gerrit-Owner: Mattflaschen <[email protected]>
Gerrit-Reviewer: MarkTraceur <[email protected]>
Gerrit-Reviewer: Mattflaschen <[email protected]>
Gerrit-Reviewer: Swalling <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to