diff --git a/i18n/en.json b/i18n/en.json index e81e706..d26dbdc 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -5,17 +5,12 @@ "minerva-last-modified-date": "Last edited on $1, at $2", "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-cta": "Help improve this page!", - "minerva-pointer-dismiss": "Dismiss", "mobile-frontend-editor-disabled": "This page is protected to prevent vandalism.", "mobile-frontend-editor-edit": "Edit", "minerva-download": "Download", "mobile-frontend-editor-redlink-create": "Create page", "mobile-frontend-editor-redlink-explain": "This page has not yet been created.", "mobile-frontend-editor-redlink-leave": "No, thanks.", - "mobile-frontend-editor-tutorial-cancel": "No, thanks", - "mobile-frontend-editor-tutorial-confirm": "Start editing", - "mobile-frontend-editor-tutorial-summary": "Try improving the $1 page.
Don't be scared of markup.", "mobile-frontend-editor-uploadenable": "Please upload a photo first to enable editing.", "mobile-frontend-footer-sitename": "{{SITENAME}}", "mobile-frontend-history": "View edit history of this page.", diff --git a/i18n/qqq.json b/i18n/qqq.json index afa4553..7216597 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -14,17 +14,12 @@ "minerva-last-modified-date": "Text that displays the date the page was last modified. Parameters:\n* $1 - date\n* $2 - time\n{{Related|Mobile-frontend-last-modified}}", "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-cta": "Caption for call to action when an anonymous user clicks on edit icon. (Note the mobile site currently doesn't allow anonymous editing.)\n{{Identical|Help improve this page}}", - "minerva-pointer-dismiss": "Label of button that dismisses overlay pointing at a particular new feature.", "mobile-frontend-editor-disabled": "Toast message that appears when a user is unable to edit a page and clicks edit icon.", "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}}", "mobile-frontend-editor-redlink-create": "Label for a create page button.\n{{Identical|Create page}}", "mobile-frontend-editor-redlink-explain": "Question for the user, if he want to edit a page, which link he clicked and that does not exist yet, or not.", "mobile-frontend-editor-redlink-leave": "Used as a label for a button which the user can click to avoid editing a page which does not exist yet (red link): the question/alternative button is {{msg-mw|mobile-frontend-editor-redlink-create}}\n----\n{{Identical|No thanks}}", - "mobile-frontend-editor-tutorial-cancel": "Label for button that user can click if they do not want to edit.\n{{Identical|No thanks}}", - "mobile-frontend-editor-tutorial-confirm": "Text for the button a user clicks after they have read the editing tutorial and are ready to edit the page.\n\nSee also:\n* {{msg-mw|Mobile-frontend-editor-tutorial-summary}}", - "mobile-frontend-editor-tutorial-summary": "Text for tutorial overlay presented to a user the first time they try to edit a page.\n\nParameters:\n* $1 - page title\nSee also:\n* {{msg-mw|Mobile-frontend-editor-tutorial-alt-summary}}", "mobile-frontend-editor-uploadenable": "Shown when try to edit a new file page.", "mobile-frontend-footer-sitename": "Name of site", "mobile-frontend-history": "Used as label for the link which points to the \"Edit history\" page.\n\nThis is shown on the Main Page in place of a last modified label to avoid confusion caused by transclusions.\n\nIf not the Main Page, the following message is used:\n* {{msg-mw|Mobile-frontend-last-modified-date}}", diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php index a22df2c..87f9110 100644 --- a/includes/skins/SkinMinerva.php +++ b/includes/skins/SkinMinerva.php @@ -1217,21 +1217,6 @@ class SkinMinerva extends SkinTemplate { ]; } - /** - * Checks to see if the current page is (probably) editable by the current user - * - * This is mostly the same check that sets wgIsProbablyEditable later in the page output - * process. - * - * @return bool - */ - protected function isCurrentPageEditableByUser() { - $title = $this->getTitle(); - $user = $this->getUser(); - return $title->quickUserCan( 'edit', $user ) - && ( $title->exists() || $title->quickUserCan( 'create', $user ) ); - } - /** * Checks whether the editor can handle the existing content handler type. * @@ -1314,7 +1299,6 @@ class SkinMinerva extends SkinTemplate { $modules = []; $user = $this->getUser(); $req = $this->getRequest(); - $action = $req->getVal( 'article_action' ); $title = $this->getTitle(); if ( !$title->isSpecialPage() ) { @@ -1331,12 +1315,6 @@ class SkinMinerva extends SkinTemplate { if ( $this->useEcho() ) { $modules[] = 'skins.minerva.notifications'; } - - if ( $this->isCurrentPageEditableByUser() ) { - if ( $action === 'signup-edit' ) { - $modules[] = 'skins.minerva.newusers'; - } - } } // TalkOverlay feature diff --git a/resources/skins.minerva.editor/init.js b/resources/skins.minerva.editor/init.js index 9515df3..6c63fba 100644 --- a/resources/skins.minerva.editor/init.js +++ b/resources/skins.minerva.editor/init.js @@ -1,16 +1,12 @@ ( function ( M, $ ) { var - // see: https://www.mediawiki.org/wiki/Manual:Interface/JavaScript#Page-specific - isReadOnly = mw.config.get( 'wgMinervaReadOnly' ), - isEditable = !isReadOnly && mw.config.get( 'wgIsProbablyEditable' ), router = require( 'mediawiki.router' ), issues = M.require( 'skins.minerva.scripts/pageIssues' ), overlayManager = M.require( 'skins.minerva.scripts/overlayManager' ), loader = M.require( 'mobile.startup/rlModuleLoader' ), skin = M.require( 'skins.minerva.scripts/skin' ), currentPage = M.getCurrentPage(), - editErrorMessage = isReadOnly ? mw.msg( 'apierror-readonly' ) : mw.msg( 'mobile-frontend-editor-disabled' ), // #ca-edit, .mw-editsection are standard MediaWiki elements // .edit-link comes from MobileFrontend user page creation CTA $allEditLinks = $( '#ca-edit a, .mw-editsection a, .edit-link' ), @@ -25,9 +21,7 @@ isNewFile = currentPage.inNamespace( 'file' ) && isNewPage, veConfig = mw.config.get( 'wgVisualEditorConfig' ), // FIXME: Should we consider default site options and user prefs? - isVisualEditorEnabled = veConfig, - CtaDrawer = M.require( 'mobile.startup/CtaDrawer' ), - drawer; + isVisualEditorEnabled = veConfig; /** * Event handler for edit link clicks. Will prevent default link @@ -44,42 +38,6 @@ return false; } - /** - * Make an element render a CTA when clicked - * @method - * @ignore - * @param {JQuery.Object} $el Element which will render a drawer on click - * @param {number} section number representing the section - */ - function makeCta( $el, section ) { - $el - .on( 'click', function ( ev ) { - ev.preventDefault(); - // prevent folding section when clicking Edit - ev.stopPropagation(); - // need to use toggle() because we do ev.stopPropagation() (in onEditLinkClick()) - if ( !drawer ) { - drawer = new CtaDrawer( { - queryParams: { - returnto: mw.config.get( 'wgPageName' ), - returntoquery: 'action=edit§ion=' + section, - warning: 'mobile-frontend-edit-login-action', - campaign: 'mobile_editPageActionCta' - }, - signupQueryParams: { - returntoquery: 'article_action=signup-edit', - warning: 'mobile-frontend-edit-signup-action' - }, - content: mw.msg( 'mobile-frontend-editor-cta' ) - } ); - } - drawer - .toggle(); - } ) - // needed until we use tap everywhere to prevent the link from being followed - .on( 'click', false ); - } - /** * Retrieve the user's preferred editor setting. If none is set, return the default * editor for this wiki. @@ -261,30 +219,17 @@ * @ignore */ function init() { + var isReadOnly, isEditable, editErrorMessage; + // see: https://www.mediawiki.org/wiki/Manual:Interface/JavaScript#Page-specific + isReadOnly = mw.config.get( 'wgMinervaReadOnly' ); + isEditable = !isReadOnly && mw.config.get( 'wgIsProbablyEditable' ); + if ( isEditable ) { // Edit button updated in setupEditor. setupEditor( currentPage ); } else { hideSectionEditIcons(); - showSorryToast( editErrorMessage ); - } - } - - /** - * Initialize the edit button so that it launches a login call-to-action when clicked. - * @method - * @ignore - */ - function initCta() { - // Initialize edit button links (to show Cta) only, if page is editable, - // otherwise show an error toast - if ( isEditable ) { - // Init all edit links (including lead section, if anonymous editing is enabled) - $allEditLinks.each( function () { - var section = ( new mw.Uri( this.href ) ).query.section || ''; - makeCta( $( this ), section ); - } ); - } else { + editErrorMessage = isReadOnly ? mw.msg( 'apierror-readonly' ) : mw.msg( 'mobile-frontend-editor-disabled' ); showSorryToast( editErrorMessage ); } } @@ -322,17 +267,7 @@ // Is a new file page (enable upload image only) Bug 58311 showSorryToast( mw.msg( 'mobile-frontend-editor-uploadenable' ) ); } else { - // Edit button is currently hidden. A call to init() / initCta() will update - // it as needed. - if ( user.isAnon() ) { - // Cta's will be rendered in EditorOverlay, if anonymous editing is enabled. - if ( mw.config.get( 'wgMFEditorOptions' ).anonymousEditing ) { - init(); - } else { - initCta(); - } - } else { - init(); - } + // Edit button is currently hidden. A call to init() will update it as needed. + init(); } }( mw.mobileFrontend, jQuery ) ); diff --git a/resources/skins.minerva.newusers/PointerOverlay.hogan b/resources/skins.minerva.newusers/PointerOverlay.hogan deleted file mode 100644 index 3c98b30..0000000 --- a/resources/skins.minerva.newusers/PointerOverlay.hogan +++ /dev/null @@ -1,5 +0,0 @@ -

{{{summary}}}

-
- {{#cancelMsg}}{{/cancelMsg}} - {{#confirmMsg}}{{/confirmMsg}} -
diff --git a/resources/skins.minerva.newusers/PointerOverlay.js b/resources/skins.minerva.newusers/PointerOverlay.js deleted file mode 100644 index 54a0f87..0000000 --- a/resources/skins.minerva.newusers/PointerOverlay.js +++ /dev/null @@ -1,145 +0,0 @@ -( function ( M, $ ) { - var msg = mw.msg, - template = mw.template, - Overlay = M.require( 'mobile.startup/Overlay' ); - - /** - * Page overlay prompting a user for given action - * @class PointerOverlay - */ - function PointerOverlay() { - Overlay.apply( this, arguments ); - } - - OO.mfExtend( PointerOverlay, Overlay, { - className: 'overlay pointer-overlay tutorial-overlay', - isBorderBox: false, - fullScreen: false, - closeOnContentTap: true, - template: template.get( 'skins.minerva.newusers', 'PointerOverlay.hogan' ), - /** - * @cfg {object} defaults Default options hash. - * @cfg {string} defaults.isCompact whether the pointer overlay should be compact - * @cfg {number} defaults.timeout in milliseconds. If not zero the pointer overlay will - * hide after this duration of time. - * @cfg {string} defaults.isTutorial whether the pointer overlay contains tutorial like - * instructions - * @cfg {string} defaults.summary Message describing thing being pointed to. - * @cfg {string} defaults.cancelMsg Cancel message. - * @cfg {string} defaults.appendToElement Where pointer overlay should be appended to. - * @cfg {string} defaults.target jQuery selector to point tutorial at - * @cfg {string} [defaults.alignment] Determines where the pointer should point to. Valid - * values 'left' or 'center' - * @cfg {string} [defaults.confirmMsg] Label for a confirm message. - * @memberof PointerOverlay - * @instance - */ - defaults: $.extend( {}, Overlay.prototype.defaults, { - summary: undefined, - isCompact: false, - isTutorial: false, - timeout: 0, - cancelMsg: msg( 'minerva-pointer-dismiss' ), - appendToElement: undefined, - target: undefined, - alignment: 'center', - confirmMsg: undefined - } ), - events: { - 'click .cancel': 'hide' - }, - postRender: function () { - var $target, - self = this; - - Overlay.prototype.postRender.apply( this ); - - if ( this.options.isCompact ) { - this.$el.addClass( 'pointer-overlay-compact' ); - } - if ( this.options.isTutorial ) { - this.$el.addClass( 'pointer-overlay-tutorial' ); - } - if ( this.options.timeout ) { - setTimeout( function () { - self.hide(); - }, this.options.timeout ); - } - if ( self.options.target ) { - // FIXME: this option should be a jQuery object already. Avoid use of global $. - $target = $( self.options.target ); - // Ensure we position the overlay correctly but do not show the arrow - self._position( $target ); - this.addPointerArrow( $target ); - } - }, - /** - * Refreshes the pointer arrow. - * @method - * @param {string} target jQuery selector - * @memberof PointerOverlay - * @instance - */ - refreshPointerArrow: function ( target ) { - this.$pointer.remove(); - this.addPointerArrow( $( target ) ); - }, - /** - * Position the overlay under a specified element - * @private - * @memberof PointerOverlay - * @instance - * @param {JQuery.Object} $pa An element that should be pointed at by the overlay - */ - _position: function ( $pa ) { - var left, - paOffset = $pa.offset(), - h = $pa.outerHeight( true ), - y = paOffset.top + h; - - this.$el.css( 'top', y ); - if ( this.options.autoHide ) { - left = paOffset.left; - this.$el.css( 'left', left ); - } - }, - /** - * Position overlay and add pointer arrow that points at specified element - * - * @memberof PointerOverlay - * @instance - * @param {JQuery.Object} $pa An element that should be pointed at by the overlay - */ - addPointerArrow: function ( $pa ) { - var left, - paOffset = $pa.offset(), - overlayOffset = this.$el.offset(), - center = $pa.width() / 2; - - this._position( $pa ); - // add the entire width of the pointer - left = 24; - if ( !this.options.autoHide ) { - left += paOffset.left - overlayOffset.left; - } - if ( this.alignment === 'center' ) { - left -= center; - } - - this.$pointer = $( '
' ).css( { - top: -6, - left: left - } ).appendTo( this.$el ); - - // Since the positioning of this overlay is dependent on the current viewport it makes - // sense to use a global window event so that on resizes it is correctly positioned. - M.on( - 'resize', - $.proxy( this, 'refreshPointerArrow', this.options.target ) - ); - } - } ); - - M.define( 'skins.minerva.newusers/PointerOverlay', PointerOverlay ); - -}( mw.mobileFrontend, jQuery ) ); diff --git a/resources/skins.minerva.newusers/PointerOverlay.less b/resources/skins.minerva.newusers/PointerOverlay.less deleted file mode 100644 index c3a671a..0000000 --- a/resources/skins.minerva.newusers/PointerOverlay.less +++ /dev/null @@ -1,93 +0,0 @@ -@import '../../minerva.less/minerva.variables'; - -@colorTutorial: #2e76ff; - -@media all and ( min-width: @width-breakpoint-tablet ) { - // Take into account padding in width of pointer overlay so that it - // can point to anything in the containing content area and avoid - // padding issues such as https://phabricator.wikimedia.org/F287611 - #mw-mf-page-center .pointer-overlay { - max-width: @width-breakpoint-desktop; - } -} - -.pointer-overlay { - width: auto; - position: absolute; - top: 0; - left: 0; - right: 0; - line-height: 1.4; - font-size: 0.9em; - text-align: center; - border-radius: @borderRadius; - margin-top: 10px; - color: #fff; - padding: 1em 16px; - - p { - line-height: 1.4; - margin: 0 0 1em; - text-align: left; - } - - .button { - // FIXME: without this the cloaked input seems to interfere making cancel button start upload - position: relative; - padding: 12px; - font-weight: bold; - width: auto; - } - - // Generic pointer definition - .tutorial-pointer { - position: absolute; - border-right: 6px solid transparent; - border-left: 6px solid transparent; - border-bottom: 6px solid transparent; - } - - &.pointer-overlay-tutorial { - background: @colorTutorial; - box-shadow: none; - - // Pointer color nested so it may be changed in other tutorials - .tutorial-pointer { - border-bottom-color: @colorTutorial; - } - - .button { - // use background to override gradient in other buttons - background: #fff; - border-radius: @borderRadius; - color: @colorTutorial; - padding: 6px; - } - - .cancel.inline { - background: none; - color: #fff; - } - - .button-bar { - text-align: right; - } - } - - &.pointer-overlay-compact { - background: @colorGray2; - width: auto; - /* @noflip */ - right: auto; - padding: 0.6em; - - // Pointer color nested so it may be changed in other tutorials - .tutorial-pointer { - border-bottom-color: @colorGray2; - } - - p { - margin: 0; - } - } -} diff --git a/resources/skins.minerva.newusers/init.js b/resources/skins.minerva.newusers/init.js deleted file mode 100644 index 783340d..0000000 --- a/resources/skins.minerva.newusers/init.js +++ /dev/null @@ -1,59 +0,0 @@ -/* This code handles the editing tutorial/CTA: - -EditTutorial - When an editor registers via the edit page action, upon returning to the -page, show a blue guider prompting them to continue editing. You can replicate this by -appending article_action=signup-edit to the URL of an editable page whilst logged in. -*/ -( function ( M, $ ) { - var PointerOverlay = M.require( 'skins.minerva.newusers/PointerOverlay' ), - skin = M.require( 'skins.minerva.scripts/skin' ), - mainMenu = M.require( 'skins.minerva.scripts.top/mainMenu' ), - util = M.require( 'mobile.startup/util' ), - escapeHash = util.escapeHash, - inEditor = window.location.hash.indexOf( '#editor/' ) > -1, - hash = window.location.hash, - editOverlay, target; - - /** - * If the user came from an edit button signup, show guider. - * @ignore - * @return {boolean} - */ - function shouldShowTutorial() { - var shouldShowEditTutorial = mw.util.getParamValue( 'article_action' ) === 'signup-edit' && !inEditor; - return shouldShowEditTutorial; - } - - if ( hash && hash.indexOf( '/' ) === -1 ) { - target = escapeHash( hash ) + ' ~ .edit-page'; - } else { - target = '#ca-edit .edit-page'; - } - - // Note the element might have a new ID if the wikitext was changed so check it exists - if ( $( target ).length > 0 && shouldShowTutorial() ) { - editOverlay = new PointerOverlay( { - target: target, - skin: skin, - isTutorial: true, - className: 'slide active editing', - appendToElement: '#mw-mf-page-center', - summary: mw.msg( 'mobile-frontend-editor-tutorial-summary', mw.config.get( 'wgTitle' ) ), - confirmMsg: mw.msg( 'mobile-frontend-editor-tutorial-confirm' ), - cancelMsg: mw.msg( 'mobile-frontend-editor-tutorial-cancel' ) - } ); - mainMenu.on( 'open', function () { - editOverlay.hide(); - } ); - editOverlay.show(); - $( '#ca-edit' ).on( 'mousedown', $.proxy( editOverlay, 'hide' ) ); - // Initialize the 'Start editing' button - editOverlay.$( '.actionable' ).on( 'click', function () { - // Hide the tutorial - editOverlay.hide(); - // Load the editing interface by changing the URL hash - window.location.href = $( target ).attr( 'href' ); - } ); - } - -}( mw.mobileFrontend, jQuery ) ); diff --git a/skin.json b/skin.json index 89744c1..7c3e0ea 100644 --- a/skin.json +++ b/skin.json @@ -455,33 +455,6 @@ "resources/skins.minerva.scripts.top/init.js" ] }, - "skins.minerva.newusers": { - "targets": [ - "mobile", - "desktop" - ], - "styles": [ - "resources/skins.minerva.newusers/PointerOverlay.less" - ], - "templates": { - "PointerOverlay.hogan": "resources/skins.minerva.newusers/PointerOverlay.hogan" - }, - "dependencies": [ - "skins.minerva.editor", - "mediawiki.util", - "mobile.startup" - ], - "scripts": [ - "resources/skins.minerva.newusers/PointerOverlay.js", - "resources/skins.minerva.newusers/init.js" - ], - "messages": [ - "minerva-pointer-dismiss", - "mobile-frontend-editor-tutorial-summary", - "mobile-frontend-editor-tutorial-confirm", - "mobile-frontend-editor-tutorial-cancel" - ] - }, "skins.minerva.notifications.badge": { "messages": [ "echo-badge-count" @@ -537,7 +510,6 @@ "messages": [ "mobile-frontend-editor-disabled", "mobile-frontend-editor-uploadenable", - "mobile-frontend-editor-cta", "apierror-readonly" ], "scripts": [ diff --git a/tests/browser/features/signup_edit_tutorial.feature b/tests/browser/features/signup_edit_tutorial.feature deleted file mode 100644 index 696c0ae..0000000 --- a/tests/browser/features/signup_edit_tutorial.feature +++ /dev/null @@ -1,10 +0,0 @@ -@chrome @en.m.wikipedia.beta.wmflabs.org @firefox @vagrant @login -Feature: Signup edit tutorial - - Background: - Given I have just signed up after trying to edit as anonymous - - Scenario: Signup edit tutorial shows up correctly and hides when main menu is opened - Then I should see the signup edit tutorial - When I click on the main navigation button - Then I should not see the signup edit tutorial diff --git a/tests/browser/features/step_definitions/signup_edit_tutorial.rb b/tests/browser/features/step_definitions/signup_edit_tutorial.rb deleted file mode 100644 index 49b0e27..0000000 --- a/tests/browser/features/step_definitions/signup_edit_tutorial.rb +++ /dev/null @@ -1,14 +0,0 @@ -Given(/^I have just signed up after trying to edit as anonymous$/) do - step 'I am logged into the mobile website' - api.create_page 'Selenium mobile signup edit tutorial test', 'signup edit tutorial test' - visit(ArticlePage, using_params: { article_name: 'Selenium_mobile_signup_edit_tutorial_test?article_action=signup-edit' }) - on(ArticlePage).wait_until_rl_module_ready('skins.minerva.newusers') -end - -Then(/^I should see the signup edit tutorial$/) do - expect(on(ArticlePage).signup_edit_tutorial_element).to be_visible -end - -Then(/^I should not see the signup edit tutorial$/) do - expect(on(ArticlePage).signup_edit_tutorial_element).not_to be_visible -end diff --git a/tests/browser/features/support/pages/article_page.rb b/tests/browser/features/support/pages/article_page.rb index b2d5a23..0b313b1 100644 --- a/tests/browser/features/support/pages/article_page.rb +++ b/tests/browser/features/support/pages/article_page.rb @@ -31,8 +31,6 @@ class ArticlePage end li(:upload_page_action, id: 'ca-upload') - div(:signup_edit_tutorial, class: 'pointer-overlay-tutorial') - a(:edit_link, text: 'Edit') div(:anon_editor_warning, css: '.anon-msg') div(:editor_overlay, class: 'editor-overlay')