2023-10-30 22:41:43 +00:00
|
|
|
const
|
|
|
|
mobile = require( 'mobile.startup' ),
|
|
|
|
ToggleList = require( '../../includes/Skins/ToggleList/ToggleList.js' ),
|
|
|
|
page = mobile.currentPage(),
|
2024-06-26 13:23:40 +00:00
|
|
|
// The top level menu.
|
2023-10-30 22:41:43 +00:00
|
|
|
selector = '.page-actions-menu',
|
2024-06-26 13:23:40 +00:00
|
|
|
// The secondary overflow submenu component container.
|
2023-10-30 22:41:43 +00:00
|
|
|
overflowSubmenuSelector = '#page-actions-overflow',
|
|
|
|
overflowListSelector = '.toggle-list__list';
|
2019-04-04 21:20:39 +00:00
|
|
|
|
2023-10-30 22:41:43 +00:00
|
|
|
/**
|
|
|
|
* @param {Window} window
|
|
|
|
* @param {Element} toolbar
|
2024-06-26 13:23:40 +00:00
|
|
|
* @ignore
|
2023-10-30 22:41:43 +00:00
|
|
|
*/
|
|
|
|
function bind( window, toolbar ) {
|
|
|
|
const overflowSubmenu = toolbar.querySelector( overflowSubmenuSelector );
|
|
|
|
if ( overflowSubmenu ) {
|
|
|
|
ToggleList.bind( window, overflowSubmenu );
|
2019-04-04 21:20:39 +00:00
|
|
|
}
|
2023-10-30 22:41:43 +00:00
|
|
|
}
|
2019-04-04 21:20:39 +00:00
|
|
|
|
2023-10-30 22:41:43 +00:00
|
|
|
/**
|
|
|
|
* @param {Window} window
|
|
|
|
* @param {Element} toolbar
|
2024-06-26 13:23:40 +00:00
|
|
|
* @ignore
|
2023-10-30 22:41:43 +00:00
|
|
|
*/
|
|
|
|
function render( window, toolbar ) {
|
|
|
|
const overflowList = toolbar.querySelector( overflowListSelector );
|
|
|
|
checkForReadOnlyMode();
|
|
|
|
renderDownloadButton( window, overflowList );
|
|
|
|
}
|
2019-04-04 21:20:39 +00:00
|
|
|
|
2023-10-30 22:41:43 +00:00
|
|
|
/**
|
|
|
|
* 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' );
|
2019-04-04 21:20:39 +00:00
|
|
|
}
|
2023-10-30 22:41:43 +00:00
|
|
|
}
|
2019-04-04 21:20:39 +00:00
|
|
|
|
2023-10-30 22:41:43 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*
|
2024-06-26 13:23:40 +00:00
|
|
|
* @ignore
|
2023-10-30 22:41:43 +00:00
|
|
|
* @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 );
|
2019-04-04 21:20:39 +00:00
|
|
|
|
2023-10-30 22:41:43 +00:00
|
|
|
if ( $downloadAction ) {
|
|
|
|
mw.track( 'minerva.downloadAsPDF', {
|
|
|
|
action: 'buttonVisible'
|
|
|
|
} );
|
2019-04-04 21:20:39 +00:00
|
|
|
}
|
2023-10-30 22:41:43 +00:00
|
|
|
}
|
2019-04-04 21:20:39 +00:00
|
|
|
|
2023-10-30 22:41:43 +00:00
|
|
|
module.exports = {
|
|
|
|
selector,
|
|
|
|
bind,
|
|
|
|
render
|
|
|
|
};
|