Florianschmidtwelzow has uploaded a new change for review.

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

Change subject: Proposal: Merge CtaDrawer with EditorOverlay Anonwarning
......................................................................

Proposal: Merge CtaDrawer with EditorOverlay Anonwarning

If anonymous editing is enabled, minimize the clicks for the user to
see the editor:
- Remove CtaDrawer not logged in users
- Merge contents from CtaDrawer into EditorOverlay (login, signup and
edit w/o login link)

All required elements (editor anon warning and Cta for login/signup) are
still present.

Bug: 72852
Change-Id: I8b42650df239c6fffde6a1bca0d2b152972d3141
---
M i18n/en.json
M i18n/qqq.json
M includes/Resources.php
M javascripts/CtaDrawer.js
M javascripts/modules/editor/EditorOverlay.js
M javascripts/modules/editor/editor.js
M less/modules/editor/editor.less
M templates/ctaDrawer.hogan
A templates/modules/editor/EditorOverlayAnonWarning.hogan
9 files changed, 51 insertions(+), 48 deletions(-)


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

diff --git a/i18n/en.json b/i18n/en.json
index f2c3f5c1..d9b5231 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -51,7 +51,7 @@
        "mobile-frontend-editor-abusefilter-read-more": "Read more",
        "mobile-frontend-editor-abusefilter-warning": "Warning: Are you sure 
you want to save this edit? There may be an issue with it.",
        "mobile-frontend-editor-anon": "Edit without logging in",
-       "mobile-frontend-editor-anoneditwarning": "<b>Warning:</b> You are not 
logged in. Your IP address will be publicly visible if you make any edits. If 
you <b>[$1 log in]</b> or <b>[$2 create an account]</b>, your edits will be 
attributed to your username, along with other benefits.",
+       "mobile-frontend-editor-anoneditwarning": "<b>Warning:</b> You are not 
logged in. Your IP address will be publicly visible if you make any edits. If 
you <b>log in</b> or <b>create an account</b>, your edits will be attributed to 
your username, along with other benefits.",
        "mobile-frontend-editor-blocked": "Your account is blocked from 
editing.",
        "mobile-frontend-editor-cancel": "Cancel",
        "mobile-frontend-editor-cancel-confirm": "Do you really want to abandon 
your edit?",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 5af3b9b..3d1606c 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -78,7 +78,7 @@
        "mobile-frontend-editor-abusefilter-read-more": "A caption for the 
button allowing the user to read more about the problems with their 
edit.\n{{Identical|Read more}}",
        "mobile-frontend-editor-abusefilter-warning": "A message telling the 
user that their edit triggered an AbuseFilter warning.",
        "mobile-frontend-editor-anon": "Title for link to edit a page without 
logging in.",
-       "mobile-frontend-editor-anoneditwarning": "Warning message, when user 
want to edit without logging in.\nParameters:\n* $1 - A link to the login 
page\n* $2 - A link to the signup page",
+       "mobile-frontend-editor-anoneditwarning": "Warning message, when user 
want to edit without logging in.",
        "mobile-frontend-editor-blocked": "Toast message that appears when a 
user is unable to edit a page due to being blocked and clicks edit icon.",
        "mobile-frontend-editor-cancel": "Caption for cancel button on edit 
form.\n{{Identical|Cancel}}",
        "mobile-frontend-editor-cancel-confirm": "Question asking user if they 
are positive about abandoning unsaved edit.",
diff --git a/includes/Resources.php b/includes/Resources.php
index c087987..2bce50c 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -267,6 +267,7 @@
                'templates' => array(
                        'switcher.hogan' => 
'templates/modules/editor/switcher.hogan',
                        'EditorOverlayBase.hogan' => 
'templates/modules/editor/EditorOverlayBase.hogan',
+                       'EditorOverlayAnonWarning.hogan' => 
'templates/modules/editor/EditorOverlayAnonWarning.hogan',
                ),
                'messages' => array(
                        // modules/editor/EditorOverlay.js
diff --git a/javascripts/CtaDrawer.js b/javascripts/CtaDrawer.js
index 639515c..d845edb 100644
--- a/javascripts/CtaDrawer.js
+++ b/javascripts/CtaDrawer.js
@@ -27,15 +27,6 @@
 
                        options.loginUrl = mw.util.getUrl( 'Special:UserLogin', 
params );
                        options.signupUrl = mw.util.getUrl( 
'Special:UserLogin', $.extend( params, signupParams ) );
-               },
-
-               // redefine from Drawer to allow to close drawer after user 
clicks edit-anon link
-               postRender: function () {
-                       var self = this;
-                       if ( self.$( '.edit-anon' ) ) {
-                               self.$( '.edit-anon' ).click( $.proxy( self, 
'hide' ) );
-                       }
-                       Drawer.prototype.postRender.apply( self, arguments );
                }
        } );
 
diff --git a/javascripts/modules/editor/EditorOverlay.js 
b/javascripts/modules/editor/EditorOverlay.js
index 3007b09..5e09a9e 100644
--- a/javascripts/modules/editor/EditorOverlay.js
+++ b/javascripts/modules/editor/EditorOverlay.js
@@ -106,27 +106,43 @@
                                // use wgPageName as this includes the 
namespace if outside Main
                                returnto: options.returnTo || mw.config.get( 
'wgPageName' )
                        }, options.queryParams ),
-                       signupParams = $.extend( { type: 'signup' }, 
options.signupQueryParams );
+                       signupParams = $.extend( { type: 'signup' }, 
options.signupQueryParams ),
+                       // params for Cta-actions after the anonymous warning 
text
+                       args = {
+                               loginCaption: mw.msg( 
'mobile-frontend-watchlist-cta-button-login' ),
+                               signupCaption: mw.msg( 
'mobile-frontend-watchlist-cta-button-signup' ),
+                               loginUrl: mw.util.getUrl( 'Special:UserLogin', 
params ),
+                               signupUrl: mw.util.getUrl( 'Special:UserLogin', 
$.extend( params, signupParams ) ),
+                               anonLabel: mw.msg( 
'mobile-frontend-editor-anon' ),
+                               anonSelector: 'continue-edit',
+                       }, self = this, template;
 
                        this.$content.hide();
                        this.showSpinner();
+
+                       // load and render the template
+                       template = mw.template.get( 'mobile.editor.common', 
'EditorOverlayAnonWarning.hogan' );
                        this.$anonWarning.html(
-                               mw.message(
-                                       
'mobile-frontend-editor-anoneditwarning',
-                                       mw.util.getUrl( 'Special:UserLogin', 
params ),
-                                       mw.util.getUrl( 'Special:UserLogin', 
$.extend( params, signupParams ) )
-                               ).parse()
+                               template.render( args )
                        ).show();
-                       this.$( '.continue' ).prop( 'disabled', false ).on( 
'click', $.proxy( this, '_showEditorafterWarning' )
-                       );
+                       // anonymessage contains plain html and can not be 
rendered through template.render()
+                       this.$( '.anonMsg' ).html( mw.message( 
'mobile-frontend-editor-anoneditwarning' ).parse() );
+                       // the user has to click login, signup or edit without 
login, disable "Next" button on top right
+                       this.$( '.continue' ).hide();
+                       // handle the click on "Edit without logging in"
+                       this.$( '.continue-edit').on( 'click', function( ev ) {
+                               ev.stopPropagation();
+                               ev.preventDefault();
+                               self._showEditorafterWarning();
+                       } );
                        this.clearSpinner();
                },
 
                _showEditorafterWarning: function () {
                        this.showSpinner();
                        this.$anonWarning.hide();
-                       this.$( '.continue' ).prop( 'disabled', true ).on( 
'click', $.proxy( this, '_prepareForSave' )
-                       );
+                       // reenable "Next" button and handle click
+                       this.$( '.continue' ).show().on( 'click', $.proxy( 
this, '_prepareForSave' ) );
                        this._loadContent();
                },
 
diff --git a/javascripts/modules/editor/editor.js 
b/javascripts/modules/editor/editor.js
index 7485990..07d43ae 100644
--- a/javascripts/modules/editor/editor.js
+++ b/javascripts/modules/editor/editor.js
@@ -11,7 +11,6 @@
                popup = M.require( 'toast' ),
                // FIXME: Disable on IE < 10 for time being
                blacklisted = /MSIE \d\./.test( navigator.userAgent ),
-               allowAnonymous = false,
                isEditingSupported = M.router.isSupported() && !blacklisted,
                isNewPage = M.getCurrentPage().options.id === 0,
                isNewFile = M.inNamespace( 'file' ) && isNewPage,
@@ -42,16 +41,12 @@
                        .prependTo( container );
        }
 
-       function makeCta( $el, section, allowAnonymous ) {
+       function makeCta( $el, section ) {
                var options = { queryParams: {
                        returnto: mw.config.get( 'wgPageName' ),
                        returntoquery: 'action=edit&section=' + section
                } };
 
-               if ( allowAnonymous ) {
-                       options.links = [ { label: mw.msg( 
'mobile-frontend-editor-anon' ),
-                               href: $el[0].href, selector: 'edit-anon 
mw-ui-progressive' } ];
-               }
                $el
                        .on( 'click', function ( ev ) {
                                ev.preventDefault();
@@ -180,24 +175,14 @@
 
        /*
         * Initialize the edit button so that it launches a login 
call-to-action when clicked.
-        * @param {boolean} allowAnonymous Whether the drawer has to include an 
edit anonymously link
         */
-       function initCta( allowAnonymous ) {
-               // If anonymous editing is allowed, init the editor now to be 
useable for the "Edit w/o login" link in cta drawer
-               if ( allowAnonymous ) {
-                       // init the editor
-                       init( M.getCurrentPage() );
-               }
-
+       function initCta() {
                // Initialize edit button links (to show Cta) only, if page is 
editable, otherwise show an error toast
                M.getCurrentPage().isEditable( user ).done( function ( 
isEditable ) {
                        if ( isEditable ) {
                                $( '#ca-edit' ).addClass( enabledClass 
).removeClass( disabledClass );
-                               // Init #ca-edit only, if anonymous editing is 
disabled, if enabled, there is a link with .edit-page inside
-                               if ( !allowAnonymous ) {
-                                       // Init lead section edit button
-                                       makeCta( $( '#ca-edit' ), 0, 
allowAnonymous );
-                               }
+                               // Init lead section edit button
+                               makeCta( $( '#ca-edit' ), 0 );
 
                                // Init all edit links (including lead section, 
if anonymous editing is enabled)
                                $( '.edit-page' ).each( function () {
@@ -205,7 +190,7 @@
                                        if ( $( this ).data( 'section' ) !== 
undefined ) {
                                                section = $( this ).data( 
'section' );
                                        }
-                                       makeCta( $a, section, allowAnonymous );
+                                       makeCta( $a, section );
                                } );
                        } else {
                                showSorryToast( 
'mobile-frontend-editor-disabled' );
@@ -233,11 +218,12 @@
                showSorryToast( 'mobile-frontend-editor-uploadenable' );
        } else  {
                if ( user.isAnon() ) {
-                       // Set edit button to launch login CTA
+                       // Cta's will be rendered in EditorOverlay, if 
anonymous editing is enabled.
                        if ( mw.config.get( 'wgMFAnonymousEditing' ) ) {
-                               allowAnonymous = true;
+                               init( M.getCurrentPage() );
+                       } else {
+                               initCta();
                        }
-                       initCta( allowAnonymous );
                } else {
                        if ( mw.config.get( 'wgMFIsLoggedInUserBlocked' ) ) {
                                // User is blocked. Both anonymous and logged 
in users can be blocked.
diff --git a/less/modules/editor/editor.less b/less/modules/editor/editor.less
index 8393538..bc5949a 100644
--- a/less/modules/editor/editor.less
+++ b/less/modules/editor/editor.less
@@ -105,6 +105,12 @@
                        }
                }
        }
+
+       .anonwarning  {
+               a {
+                       margin-bottom: 1em;
+               }
+       }
 }
 
 .abusefilter-overlay {
diff --git a/templates/ctaDrawer.hogan b/templates/ctaDrawer.hogan
index a25d6dc..7a867f4 100644
--- a/templates/ctaDrawer.hogan
+++ b/templates/ctaDrawer.hogan
@@ -1,9 +1,6 @@
 {{{collapseButton}}}
-<p>{{content}}</p>
+<p class="drawerContent">{{content}}</p>
 <div class="mw-ui-button-group">
        <a class="mw-ui-button mw-ui-block mw-ui-progressive" 
href="{{loginUrl}}">{{loginCaption}}</a>
        <a class="mw-ui-progressive mw-ui-anchor mw-ui-block" 
href="{{signupUrl}}">{{signupCaption}}</a>
-       {{#links}}
-       <a class="mw-ui-anchor mw-ui-block {{selector}}" 
href="{{href}}">{{label}}</a>
-       {{/links}}
 </div>
diff --git a/templates/modules/editor/EditorOverlayAnonWarning.hogan 
b/templates/modules/editor/EditorOverlayAnonWarning.hogan
new file mode 100644
index 0000000..ed6fb07
--- /dev/null
+++ b/templates/modules/editor/EditorOverlayAnonWarning.hogan
@@ -0,0 +1,6 @@
+<p class="anonMsg"></p>
+<div class="actions">
+       <a class="mw-ui-button mw-ui-block mw-ui-progressive" 
href="{{loginUrl}}">{{loginCaption}}</a>
+       <a class="mw-ui-button mw-ui-block mw-ui-neutral" 
href="{{signupUrl}}">{{signupCaption}}</a>
+       <a class="mw-ui-button mw-ui-block mw-ui-neutral 
{{anonSelector}}">{{anonLabel}}</a>
+</div>

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8b42650df239c6fffde6a1bca0d2b152972d3141
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