mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-17 03:08:12 +00:00
5170e69d3c
When $wgReadOnly = true; in LocalSettings.php the edit icons appear locked and when clicked should show a warning. This also addresses deprecation warnings in the code and tidies up the ES6 code. Note to reviewer: Please use git diff HEAD^ -w when reviewing this diff. Mostly whitespace changes. Change-Id: I3fa83cc1dc4da62260fd0ef50ac14805c3e1282b
80 lines
2.3 KiB
JavaScript
80 lines
2.3 KiB
JavaScript
const
|
|
mobile = require( 'mobile.startup' ),
|
|
ToggleList = require( '../../includes/Skins/ToggleList/ToggleList.js' ),
|
|
page = mobile.currentPage(),
|
|
/** The top level menu. */
|
|
selector = '.page-actions-menu',
|
|
/** The secondary overflow submenu component container. */
|
|
overflowSubmenuSelector = '#page-actions-overflow',
|
|
overflowListSelector = '.toggle-list__list';
|
|
|
|
/**
|
|
* @param {Window} window
|
|
* @param {Element} toolbar
|
|
*/
|
|
function bind( window, toolbar ) {
|
|
const overflowSubmenu = toolbar.querySelector( overflowSubmenuSelector );
|
|
if ( overflowSubmenu ) {
|
|
ToggleList.bind( window, overflowSubmenu );
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param {Window} window
|
|
* @param {Element} toolbar
|
|
*/
|
|
function render( window, toolbar ) {
|
|
const overflowList = toolbar.querySelector( overflowListSelector );
|
|
checkForReadOnlyMode();
|
|
renderDownloadButton( window, overflowList );
|
|
}
|
|
|
|
/**
|
|
* Initialize page edit action link (#ca-edit) for read only mode.
|
|
* (e.g. when $wgReadOnly is set in LocalSettings.php)
|
|
*
|
|
* Mark the edit link as disabled if the user is not actually able to edit the page for some
|
|
* reason (e.g. page is protected or user is blocked).
|
|
*
|
|
* Note that the link is still clickable, but clicking it will probably open a view-source
|
|
* form or display an error message, rather than open an edit form.
|
|
*
|
|
* This check occurs in JavaScript as anonymous page views are cached
|
|
* in Varnish.
|
|
*
|
|
* @ignore
|
|
*/
|
|
function checkForReadOnlyMode() {
|
|
if ( mw.config.get( 'wgMinervaReadOnly' ) ) {
|
|
document.body.classList.add( 'minerva-read-only' );
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Initialize and inject the download button
|
|
*
|
|
* There are many restrictions when we can show the download button, this function should handle
|
|
* all device/os/operating system related checks and if device supports printing it will inject
|
|
* the Download icon
|
|
*
|
|
* @param {Window} window
|
|
* @param {Element|null} overflowList
|
|
*/
|
|
function renderDownloadButton( window, overflowList ) {
|
|
const downloadPageAction = require( './downloadPageAction.js' ).downloadPageAction,
|
|
$downloadAction = downloadPageAction( page,
|
|
mw.config.get( 'wgMinervaDownloadNamespaces', [] ), window, !!overflowList );
|
|
|
|
if ( $downloadAction ) {
|
|
mw.track( 'minerva.downloadAsPDF', {
|
|
action: 'buttonVisible'
|
|
} );
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
selector,
|
|
bind,
|
|
render
|
|
};
|