mediawiki-extensions-Popups/resources/ext.popups.referencePreviews/setUserConfigFlags.js
Jon Robson 7172aae082 Reference previews should no longer use Webpack
As a precursor to moving this code to the Cite extension move it off
of webpack and switch to using require rather than import

Bug: T355194
Change-Id: Ib6486ad38b79a3b67a9744b716b1a2f5d3779795
2024-02-02 10:52:30 -08:00

30 lines
667 B
JavaScript

/**
* @module setUserConfigFlags
*/
/**
* Same as in includes/PopupsContext.php
*/
const REF_TOOLTIPS_ENABLED = 2,
REFERENCE_PREVIEWS_ENABLED = 4;
/**
* Decodes the bitmask that represents preferences to the related config options.
*
* @param {mw.Map} config
*/
module.exports = function setUserConfigFlags( config ) {
const popupsFlags = parseInt( config.get( 'wgPopupsFlags' ), 10 );
/* eslint-disable no-bitwise */
config.set(
'wgPopupsConflictsWithRefTooltipsGadget',
!!( popupsFlags & REF_TOOLTIPS_ENABLED )
);
config.set(
'wgPopupsReferencePreviews',
!!( popupsFlags & REFERENCE_PREVIEWS_ENABLED )
);
/* eslint-enable no-bitwise */
}