Mattflaschen has uploaded a new change for review.

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


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, 32 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GuidedTour 
refs/changes/70/92670/1

diff --git a/modules/ext.guidedTour.lib.js b/modules/ext.guidedTour.lib.js
index 9d8e142..5b49d9f 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,10 +776,11 @@
         *
         * @private
         */
-       function setupSkipThenUpdateDisplayListeners() {
-               var mwHooks, i;
+       function setupStepTransitionListeners() {
+               var generalSkipHooks, i;
 
-               function skip() {
+               // hookName parameter allows easier debugging.
+               function skip( hookName ) {
                        // I found this necessary when testing, probably to 
give the
                        // browser queue a chance to do pending DOM rendering.
                        setTimeout( function () {
@@ -783,13 +788,30 @@
                        }, 0 );
                }
 
-               mwHooks = [
-                       've.activationComplete',
+               function addSkipHandler( hookName ) {
+                       mw.hook( hookName ).add( function () {
+                               skip( hookName );
+                       } );
+               }
+
+               // The next two are handled differently since they also require
+               // settings an internal boolean.
+               mw.hook( 'postEdit' ).add( function () {
+                       isPostEdit = true;
+                       skip( 'postEdit' );
+               } );
+
+               mw.hook( 've.activationComplete' ).add( function () {
+                       isPostEdit = false;
+                       skip( 've.activationComplete' );
+               } );
+
+               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++ ) {
+                       addSkipHandler( generalSkipHooks[i] );
                }
        }
 
@@ -828,7 +850,7 @@
 
                $( document ).ready( function () {
                        setupRepositionListeners();
-                       setupSkipThenUpdateDisplayListeners();
+                       setupStepTransitionListeners();
                        setupGuiderListeners();
                } );
        }
@@ -1241,7 +1263,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: newchange
Gerrit-Change-Id: Ib0e82866ed7306cbd8491a9719bbcfc7f0299773
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GuidedTour
Gerrit-Branch: master
Gerrit-Owner: Mattflaschen <[email protected]>

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

Reply via email to