Jdlrobson has uploaded a new change for review.

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


Change subject: Make KeepGoing run when editing using VE
......................................................................

Make KeepGoing run when editing using VE

Bug: 59932
Change-Id: I9373c163eefa925b41350967205c62a50c7807e8
---
M javascripts/modules/editorNew/EditorOverlay.js
M javascripts/modules/editorNew/EditorOverlayBase.js
2 files changed, 57 insertions(+), 54 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/90/108990/1

diff --git a/javascripts/modules/editorNew/EditorOverlay.js 
b/javascripts/modules/editorNew/EditorOverlay.js
index e4c31d3..218279a 100644
--- a/javascripts/modules/editorNew/EditorOverlay.js
+++ b/javascripts/modules/editorNew/EditorOverlay.js
@@ -3,8 +3,6 @@
        var EditorOverlayBase = M.require( 
'modules/editorNew/EditorOverlayBase' ),
                user = M.require( 'user' ),
                popup = M.require( 'toast' ),
-               inBetaOrAlpha = M.isBetaGroupMember(),
-               inKeepGoingCampaign = M.query.campaign === 'mobile-keepgoing',
                inNavSignupCampaign = M.query.campaign === 'leftNavSignup',
                Section = M.require( 'Section' ),
                EditorApi = M.require( 'modules/editor/EditorApi' ),
@@ -45,8 +43,6 @@
                                isNew: options.isNew
                        } );
                        this.sectionId = options.sectionId;
-                       this.isNewEditor = options.isNewEditor;
-                       this.editCount = user.getEditCount();
                        this.readOnly = options.oldId ? true : false; // If old 
revision, readOnly mode
                        this.funnel = options.funnel;
                        this._super( options );
@@ -83,17 +79,6 @@
                        self.log( 'attempt' );
                },
 
-               _shouldShowKeepGoingOverlay: function() {
-                       if ( inBetaOrAlpha &&
-                               mw.config.get( 'wgMFKeepGoing' ) &&
-                               ( this.editCount === 0  || inKeepGoingCampaign )
-                       ) {
-                               return true;
-                       } else {
-                               return false;
-                       }
-               },
-
                _showPreview: function() {
                        var self = this, params = { text: this.$content.val() };
 
@@ -104,12 +89,6 @@
                        this.scrollTop = $( 'body' ).scrollTop();
                        this.$content.hide();
                        this.$spinner.show();
-
-                       // pre-fetch keep going with expectation user will go 
on to save
-                       if ( this._shouldShowKeepGoingOverlay() ) {
-                               this._keepgoing = true;
-                               mw.loader.using( 'mobile.keepgoing' );
-                       }
 
                        if ( mw.config.get( 'wgIsMainPage' ) ) {
                                params.mainpage = 1; // Setting it to 0 will 
have the same effect
@@ -160,11 +139,6 @@
                                } );
                },
 
-               _updateEditCount: function() {
-                       this.editCount += 1;
-                       mw.config.set( 'wgUserEditCount', this.editCount );
-               },
-
                _showAbuseFilter: function( type, message ) {
                        var self = this, msg;
 
@@ -187,9 +161,8 @@
                },
 
                _save: function() {
-                       var self = this, className = 'toast landmark',
-                               options = { summary: this.$( '.summary' ).val() 
},
-                               msg;
+                       var self = this,
+                               options = { summary: this.$( '.summary' ).val() 
};
 
                        if ( this.captchaId ) {
                                options.captchaId = this.captchaId;
@@ -222,30 +195,6 @@
                                        }
                                        self.onSave();
                                        self.hide();
-                                       if ( self.isNewEditor ) {
-                                               msg = 
'mobile-frontend-editor-success-landmark-1';
-                                       } else {
-                                               className = 'toast';
-                                               msg = 
'mobile-frontend-editor-success';
-                                       }
-                                       self._updateEditCount();
-                                       // Set a cookie for 30 days indicating 
that this user has edited from
-                                       // the mobile interface.
-                                       $.cookie( 'mobileEditor', 'true', { 
expires: 30 } );
-                                       // double check it was successfully 
pre-fetched during preview phase
-                                       if ( self._keepgoing ) {
-                                               // Show KeepGoing overlay at 
step 1 (ask)
-                                               mw.loader.using( 
'mobile.keepgoing', function() {
-                                                       var KeepGoingOverlay = 
M.require( 'modules/keepgoing/KeepGoingOverlay' );
-                                                       new KeepGoingOverlay( { 
step: 1 } ).show();
-                                               } );
-                                               self._keepgoing = false;
-                                       } else {
-                                               // just show a toast
-                                               popup.show( mw.msg( msg ), 
className );
-                                       }
-                                       // update after 
_shouldShowKeepGoingOverlay test
-                                       self._updateEditCount();
                                } ).
                                fail( function( data ) {
                                        var msg;
diff --git a/javascripts/modules/editorNew/EditorOverlayBase.js 
b/javascripts/modules/editorNew/EditorOverlayBase.js
index c92e936..c08cfba 100644
--- a/javascripts/modules/editorNew/EditorOverlayBase.js
+++ b/javascripts/modules/editorNew/EditorOverlayBase.js
@@ -1,6 +1,9 @@
 ( function( M, $ ) {
        var OverlayNew = M.require( 'OverlayNew' ),
                Page = M.require( 'Page' ),
+               inKeepGoingCampaign = M.query.campaign === 'mobile-keepgoing',
+               user = M.require( 'user' ),
+               toast = M.require( 'toast' ),
                EditorOverlayBase;
 
        EditorOverlayBase = OverlayNew.extend( {
@@ -20,12 +23,55 @@
                template: M.template.get( 'modules/editorNew/EditorOverlayBase' 
),
                className: 'overlay editor-overlay',
 
+               _updateEditCount: function() {
+                       this.editCount += 1;
+                       mw.config.set( 'wgUserEditCount', this.editCount );
+               },
+               _shouldShowKeepGoingOverlay: function() {
+                       if ( M.isBetaGroupMember() &&
+                               mw.config.get( 'wgMFKeepGoing' ) &&
+                               ( this.editCount === 0  || inKeepGoingCampaign )
+                       ) {
+                               return true;
+                       } else {
+                               console.log( 'NO!', this.editCount, 
inKeepGoingCampaign );
+                               return false;
+                       }
+               },
                onSave: function() {
-                       var title = this.options.title;
+                       var title = this.options.title,
+                               className = 'toast landmark', msg;
+
                        // FIXME: use generic method for following 3 lines
                        M.pageApi.invalidatePage( title );
                        new Page( { title: title, el: $( '#content_wrapper' ) } 
).on( 'ready', M.reloadPage );
                        M.router.navigate( '' );
+
+                       if ( this.isNewEditor ) {
+                               msg = 
'mobile-frontend-editor-success-landmark-1';
+                       } else {
+                               className = 'toast';
+                               msg = 'mobile-frontend-editor-success';
+                       }
+
+                       if ( this._shouldShowKeepGoingOverlay() ) {
+                               console.log( 'do it!' );
+                               // Show KeepGoing overlay at step 1 (ask)
+                               mw.loader.using( 'mobile.keepgoing', function() 
{
+                                       var KeepGoingOverlay = M.require( 
'modules/keepgoing/KeepGoingOverlay' );
+                                       new KeepGoingOverlay( { step: 1 } 
).show();
+                               } );
+                       } else {
+                               // just show a toast
+                               toast.show( mw.msg( msg ), className );
+                       }
+
+                       // Set a cookie for 30 days indicating that this user 
has edited from
+                       // the mobile interface.
+                       $.cookie( 'mobileEditor', 'true', { expires: 30 } );
+
+                       // update after _shouldShowKeepGoingOverlay test
+                       this._updateEditCount();
                },
                initialize: function( options ) {
                        if ( this.readOnly ) {
@@ -35,6 +81,14 @@
                                options.editingMsg = mw.msg( 
'mobile-frontend-editor-editing-page', options.title );
                        }
                        options.previewingMsg = mw.msg( 
'mobile-frontend-editor-previewing-page', options.title );
+                       this.editCount = user.getEditCount();
+                       this.isNewEditor = options.isNewEditor;
+
+                       // pre-fetch keep going with expectation user will go 
on to save
+                       if ( this._shouldShowKeepGoingOverlay() ) {
+                               mw.loader.using( 'mobile.keepgoing' );
+                       }
+
                        this._super( options );
                },
                postRender: function( options ) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9373c163eefa925b41350967205c62a50c7807e8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to