2024-01-12 22:30:44 +00:00
|
|
|
const { TYPE_REFERENCE } = require( './constants.js' );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @module isReferencePreviewsEnabled
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Given the global state of the application, creates a function that gets
|
|
|
|
* whether or not the user should have Reference Previews enabled.
|
|
|
|
*
|
|
|
|
* @param {mw.user} user The `mw.user` singleton instance
|
|
|
|
* @param {Function} isPreviewTypeEnabled check whether preview has been disabled or enabled.
|
|
|
|
* @param {mw.Map} config
|
|
|
|
*
|
|
|
|
* @return {boolean|null} Null when there is no way the popup type can be enabled at run-time.
|
|
|
|
*/
|
|
|
|
function isReferencePreviewsEnabled( user, isPreviewTypeEnabled, config ) {
|
2024-04-30 09:51:38 +00:00
|
|
|
if ( !config.get( 'wgCiteReferencePreviewsActive' ) ) {
|
2024-01-12 22:30:44 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( user.isAnon() ) {
|
|
|
|
return isPreviewTypeEnabled( TYPE_REFERENCE );
|
|
|
|
}
|
|
|
|
|
2024-04-19 07:42:41 +00:00
|
|
|
return true;
|
2024-01-12 22:30:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = isReferencePreviewsEnabled;
|