mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-24 14:23:53 +00:00
Add showing toast/drawer when visiting protected article with editor link
Bug: T205630 Change-Id: I0c25f491c894d12775d236ecc9250bfdad17a13b
This commit is contained in:
parent
10978e5022
commit
8f1cfa4b81
|
@ -22,7 +22,8 @@
|
|||
isNewFile = currentPage.inNamespace( 'file' ) && isNewPage,
|
||||
veConfig = mw.config.get( 'wgVisualEditorConfig' ),
|
||||
// FIXME: Should we consider default site options and user prefs?
|
||||
isVisualEditorEnabled = veConfig;
|
||||
isVisualEditorEnabled = veConfig,
|
||||
editorPath = /^\/editor\/(\d+|all)$/;
|
||||
|
||||
/**
|
||||
* Event handler for edit link clicks. Will prevent default link
|
||||
|
@ -72,7 +73,7 @@
|
|||
leadSection = page.getLeadSectionElement();
|
||||
|
||||
$allEditLinks.on( 'click', onEditLinkClick );
|
||||
overlayManager.add( /^\/editor\/(\d+|all)$/, function ( sectionId ) {
|
||||
overlayManager.add( editorPath, function ( sectionId ) {
|
||||
var
|
||||
$content = $( '#mw-content-text' ),
|
||||
preferredEditor = getPreferredEditor(),
|
||||
|
@ -214,13 +215,36 @@
|
|||
currentPage.$( '.mw-editsection' ).hide();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a drawer with log in / sign up buttons.
|
||||
* @method
|
||||
* @ignore
|
||||
*/
|
||||
function showLoginDrawer() {
|
||||
var 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();
|
||||
return drawer;
|
||||
} );
|
||||
router.route( editorPath, function () {
|
||||
drawer.show();
|
||||
} );
|
||||
router.checkRoute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the editor if the user can edit the page otherwise show a sorry toast.
|
||||
* @method
|
||||
* @ignore
|
||||
*/
|
||||
function init() {
|
||||
var isReadOnly, isEditable, editErrorMessage, drawer, editRestrictions;
|
||||
var isReadOnly, isEditable, editErrorMessage, editRestrictions;
|
||||
// see: https://www.mediawiki.org/wiki/Manual:Interface/JavaScript#Page-specific
|
||||
isReadOnly = mw.config.get( 'wgMinervaReadOnly' );
|
||||
isEditable = !isReadOnly && mw.config.get( 'wgIsProbablyEditable' );
|
||||
|
@ -232,16 +256,7 @@
|
|||
hideSectionEditIcons();
|
||||
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();
|
||||
} );
|
||||
showLoginDrawer();
|
||||
} else {
|
||||
editErrorMessage = isReadOnly ? mw.msg( 'apierror-readonly' ) : mw.msg( 'mobile-frontend-editor-disabled' );
|
||||
showSorryToast( editErrorMessage );
|
||||
|
@ -260,6 +275,10 @@
|
|||
popup.show( msg );
|
||||
ev.preventDefault();
|
||||
} );
|
||||
router.route( editorPath, function () {
|
||||
popup.show( msg );
|
||||
} );
|
||||
router.checkRoute();
|
||||
}
|
||||
|
||||
if ( contentModel !== 'wikitext' ) {
|
||||
|
|
Loading…
Reference in a new issue