Florianschmidtwelzow has uploaded a new change for review.

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

Change subject: Add intermediate screen for anonymous editors
......................................................................

Add intermediate screen for anonymous editors

Show anonedit warning for anonymous users when they try to edit.

Follow up: I7662c204f906bf214369fdd93f92a4a5d4e4081a

Bug: 59937
Change-Id: I8ec64e0255b93195289ec7a76a6df4ce166f6f8d
---
M includes/Resources.php
M includes/skins/SkinMinervaAlpha.php
M javascripts/modules/editor/EditorOverlay.js
M javascripts/modules/editor/editor.js
M templates/modules/editor/EditorOverlay.hogan
5 files changed, 43 insertions(+), 6 deletions(-)


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

diff --git a/includes/Resources.php b/includes/Resources.php
index 84c62c0..58e88b1 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -300,6 +300,7 @@
                        'mobile-frontend-editor-visual-editor',
                        'mobile-frontend-editor-source-editor',
                        'mobile-frontend-editor-switch-editor',
+                       'anoneditwarning'
                ),
        ),
 
diff --git a/includes/skins/SkinMinervaAlpha.php 
b/includes/skins/SkinMinervaAlpha.php
index 4612611..19feac2 100644
--- a/includes/skins/SkinMinervaAlpha.php
+++ b/includes/skins/SkinMinervaAlpha.php
@@ -33,6 +33,16 @@
        }
 
        /**
+        * Get various skin specific configuration.
+        * @return array
+        */
+       public function getSkinConfigVariables() {              
+               $vars = parent::getSkinConfigVariables();               
+               $vars['wgMFAnonymousEditing'] = true;           
+               return $vars;           
+       }
+
+       /**
         * Add the talk page link for logged in alpha users to template
         * @param BaseTemplate $tpl an instance of BaseTemplate
         * @return QuickTemplate
diff --git a/javascripts/modules/editor/EditorOverlay.js 
b/javascripts/modules/editor/EditorOverlay.js
index 762cd76..e74c95f 100644
--- a/javascripts/modules/editor/EditorOverlay.js
+++ b/javascripts/modules/editor/EditorOverlay.js
@@ -54,7 +54,12 @@
                                        self.api.setContent( 
self.$content.val() );
                                        self.$( '.continue, .submit' ).prop( 
'disabled', false );
                                } );
-                       this.$( '.continue' ).on( M.tapEvent( 'click' ), 
$.proxy( this, '_prepareForSave' ) );
+                       if ( options.anon ) {
+                               this.$anonWarning = this.$( '.anonwarning' );
+                               this._showAnonWarning();
+                       } else {
+                               this.$( '.continue' ).on( M.tapEvent( 'click' 
), $.proxy( this, '_prepareForSave' ) );
+                       }
                        this.$( '.back' ).on( M.tapEvent( 'click' ), $.proxy( 
this, '_hidePreview' ) );
                        this.$( '.submit' ).on( M.tapEvent( 'click' ), $.proxy( 
this, '_save' ) );
                        // make license links open in separate tabs
@@ -81,6 +86,25 @@
                                this.$content.prop( 'readonly', true );
                        }
 
+                       if ( !options.anon ) {
+                               this._loadContent();
+                       }
+               },
+
+               _showAnonWarning: function() {
+                       this.$content.hide();
+                       this.showSpinner();
+                       this.$anonWarning.html( mw.msg( 'anoneditwarning' ) 
).show();
+                       this.$( '.continue' ).on( M.tapEvent( 'click' ), 
$.proxy( this, '_showEditorafterWarning' ) );
+                       this.$( '.continue' ).prop( 'disabled', false );
+                       this.clearSpinner();
+               },
+
+               _showEditorafterWarning: function() {
+                       this.showSpinner();
+                       this.$anonWarning.hide();
+                       this.$( '.continue' ).on( M.tapEvent( 'click' ), 
$.proxy( this, '_prepareForSave' ) );
+                       this.$( '.continue' ).prop( 'disabled', true );
                        this._loadContent();
                },
 
diff --git a/javascripts/modules/editor/editor.js 
b/javascripts/modules/editor/editor.js
index b9b7b50..0a94d45 100644
--- a/javascripts/modules/editor/editor.js
+++ b/javascripts/modules/editor/editor.js
@@ -78,7 +78,7 @@
         *
         * @param {Page} page The page to edit.
         */
-       function setupEditor( page ) {
+       function setupEditor( page, anonymous ) {
                var isNewPage = page.options.id === 0;
                if ( M.query.undo ) {
                        window.alert( mw.msg( 
'mobile-frontend-editor-undo-unsupported' ) );
@@ -91,6 +91,7 @@
                                preferredEditor = getPreferredEditor(),
                                editorOptions = {
                                        title: page.title,
+                                       anon: anonymous,
                                        isNewPage: isNewPage,
                                        isNewEditor: user.getEditCount() === 0,
                                        oldId: M.query.oldid,
@@ -157,10 +158,10 @@
                } );
        }
 
-       function init( page ) {
+       function init( page, anonymous ) {
                page.isEditable( user ).done( function( isEditable ) {
                        if ( isEditable ) {
-                               setupEditor( page );
+                               setupEditor( page, anonymous );
                        } else {
                                showSorryToast( 
'mobile-frontend-editor-disabled' );
                        }
@@ -174,7 +175,7 @@
        function initCta( allowAnonymous ) {
                if ( allowAnonymous ) {
                        // init the editor
-                       init( M.getCurrentPage() );
+                       init( M.getCurrentPage(), true );
                } else {
                        // FIXME: change when micro.tap.js in stable
                        $( '#ca-edit' ).addClass( 'enabled' ).on( M.tapEvent( 
'click' ), function() {
@@ -221,7 +222,7 @@
                                // User is blocked. Both anonymous and logged 
in users can be blocked.
                                showSorryToast( 
'mobile-frontend-editor-blocked' );
                        } else {
-                               init( M.getCurrentPage() );
+                               init( M.getCurrentPage(), false );
                                M.on( 'page-loaded', init );
                        }
                }
diff --git a/templates/modules/editor/EditorOverlay.hogan 
b/templates/modules/editor/EditorOverlay.hogan
index 62f8e22..bd4ff48 100644
--- a/templates/modules/editor/EditorOverlay.hogan
+++ b/templates/modules/editor/EditorOverlay.hogan
@@ -1,2 +1,3 @@
 <textarea class="wikitext-editor" cols="40" rows="10" 
placeholder="{{placeholder}}"></textarea>
 <div class="preview content"></div>
+<div class="anonwarning content"></div>

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8ec64e0255b93195289ec7a76a6df4ce166f6f8d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow <[email protected]>

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

Reply via email to