diff --git a/i18n/en.json b/i18n/en.json index cbc5bed..4bfe0bc 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -6,6 +6,7 @@ "minerva-talk-add-topic": "Add discussion", "mobile-frontend-cookies-required": "Cookies are required to switch view modes. Please enable them and try again.", "mobile-frontend-editor-disabled": "This page is protected to prevent vandalism.", + "mobile-frontend-editor-disabled-anon": "You need to log in to edit this page.", "mobile-frontend-editor-edit": "Edit", "minerva-download": "Download", "skin-minerva-share": "Share", diff --git a/i18n/qqq.json b/i18n/qqq.json index bf792a0..e2f6fd0 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -15,6 +15,7 @@ "minerva-talk-add-topic": "Label for button which shows at bottom of talk pages in mobile view prompting addition of topic", "mobile-frontend-cookies-required": "Error message shown when user attempts to switch site modes and cookies are not enabled.", "mobile-frontend-editor-disabled": "Toast message that appears when a user is unable to edit a page and clicks edit icon.", + "mobile-frontend-editor-disabled-anon": "Message that appears in a drawer when a user is not logged in and anonymous edits are disabled.", "mobile-frontend-editor-edit": "Caption for the link showing edit form. (In the imperative mood)\n{{Identical|Edit}}", "minerva-download": "Caption for the download button (in the imperative mood).\n{{Identical|Download}}", "skin-minerva-share": "Caption for the share button (in the imperative mood).\n{{Identical|Share}}", diff --git a/resources/skins.minerva.editor/init.js b/resources/skins.minerva.editor/init.js index 6c63fba..55f6052 100644 --- a/resources/skins.minerva.editor/init.js +++ b/resources/skins.minerva.editor/init.js @@ -12,6 +12,7 @@ $allEditLinks = $( '#ca-edit a, .mw-editsection a, .edit-link' ), user = M.require( 'mobile.startup/user' ), popup = M.require( 'mobile.startup/toast' ), + CtaDrawer = M.require( 'mobile.startup/CtaDrawer' ), // FIXME: Disable on IE < 10 for time being blacklisted = /MSIE \d\./.test( navigator.userAgent ), contentModel = mw.config.get( 'wgPageContentModel' ), @@ -219,7 +220,7 @@ * @ignore */ function init() { - var isReadOnly, isEditable, editErrorMessage; + var isReadOnly, isEditable, editErrorMessage, drawer, editRestrictions; // see: https://www.mediawiki.org/wiki/Manual:Interface/JavaScript#Page-specific isReadOnly = mw.config.get( 'wgMinervaReadOnly' ); isEditable = !isReadOnly && mw.config.get( 'wgIsProbablyEditable' ); @@ -229,8 +230,22 @@ setupEditor( currentPage ); } else { hideSectionEditIcons(); - editErrorMessage = isReadOnly ? mw.msg( 'apierror-readonly' ) : mw.msg( 'mobile-frontend-editor-disabled' ); - showSorryToast( editErrorMessage ); + editRestrictions = mw.config.get( 'wgRestrictionEdit' ); + if ( mw.user.isAnon() && Array.isArray( editRestrictions ) && editRestrictions.indexOf( '*' ) !== -1 ) { + drawer = new CtaDrawer( { + content: mw.msg( 'mobile-frontend-editor-disabled-anon' ), + signupQueryParams: { + warning: 'mobile-frontend-watchlist-signup-action' + } + } ); + $allEditLinks.on( 'click', function ( ev ) { + drawer.show(); + ev.preventDefault(); + } ); + } else { + editErrorMessage = isReadOnly ? mw.msg( 'apierror-readonly' ) : mw.msg( 'mobile-frontend-editor-disabled' ); + showSorryToast( editErrorMessage ); + } } } diff --git a/skin.json b/skin.json index 2f7d59d..de786bb 100644 --- a/skin.json +++ b/skin.json @@ -513,6 +513,7 @@ ], "messages": [ "mobile-frontend-editor-disabled", + "mobile-frontend-editor-disabled-anon", "mobile-frontend-editor-uploadenable", "apierror-readonly" ],