2018-09-21 03:17:02 +00:00
|
|
|
/* This code handles the editing tutorial/CTA:
|
2017-07-12 15:12:40 +00:00
|
|
|
|
|
|
|
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, $ ) {
|
2017-10-27 15:17:47 +00:00
|
|
|
var PointerOverlay = M.require( 'skins.minerva.newusers/PointerOverlay' ),
|
2017-07-12 15:12:40 +00:00
|
|
|
skin = M.require( 'skins.minerva.scripts/skin' ),
|
2017-09-07 16:55:28 +00:00
|
|
|
mainMenu = M.require( 'skins.minerva.scripts.top/mainMenu' ),
|
2017-07-12 15:12:40 +00:00
|
|
|
util = M.require( 'mobile.startup/util' ),
|
|
|
|
escapeHash = util.escapeHash,
|
|
|
|
inEditor = window.location.hash.indexOf( '#editor/' ) > -1,
|
|
|
|
hash = window.location.hash,
|
2018-09-21 03:17:02 +00:00
|
|
|
editOverlay, target;
|
2017-07-12 15:12:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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;
|
2018-09-21 03:17:02 +00:00
|
|
|
return shouldShowEditTutorial;
|
2017-07-12 15:12:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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() ) {
|
2017-10-27 15:17:47 +00:00
|
|
|
editOverlay = new PointerOverlay( {
|
2017-07-12 15:12:40 +00:00
|
|
|
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' )
|
|
|
|
} );
|
2017-09-07 16:55:28 +00:00
|
|
|
mainMenu.on( 'open', function () {
|
2017-07-12 15:12:40 +00:00
|
|
|
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 ) );
|