mediawiki-skins-MinervaNeue/resources/skins.minerva.newusers/init.js
Bartosz Dziewoński 992630c705 Remove broken remains of &campaign=leftNavSignup handling
This code could never be used under normal circumstances since
a crucial bit of it was removed from MobileFrontend in 2015:
(I65e943b6dad8bfea994020f9f555bd095da1a171)

    // Allow us to distinguish sign ups from the left nav to logins.
    // This allows us to show them an edit tutorial when they return to the page.
    if ( $query['returntoquery'] === 'welcome=yes' ) {
    	$query['returntoquery'] = 'campaign=leftNavSignup';
    }

…and honestly, that's for good, because it fails horribly
when triggered by adding &campaign=leftNavSignup to the URL
manually: clicking "Start editing" in the callout navigates
you to an article called "Undefined/leftNavSignup".

Bug: T205325
Change-Id: I0e385488be5b2eaa7d489029b91e18b336c0d133
2018-09-24 19:30:03 +00:00

60 lines
2.1 KiB
JavaScript

/* 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 ) );