mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-09-23 10:21:11 +00:00
64e7bfd620
Sometimes we make choices on the users behalf if we don't have sufficient information, so this name is more applicable. If beta features is disabled and the user is anon they have not explicitly opted in. Change-Id: I5d816f569fc54f8bf74d6e5a06246b7fa7036e06
36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
( function ( mw ) {
|
|
|
|
/**
|
|
* Given the global state of the application, creates a function that gets
|
|
* whether or not the user should have Page Previews enabled.
|
|
*
|
|
* If Page Previews is configured as a beta feature (see
|
|
* `$wgPopupsBetaFeature`), the user must be logged in and have enabled the
|
|
* beta feature in order to see previews.
|
|
*
|
|
* If Page Previews is configured as a preference, then the user must either
|
|
* be logged in and have enabled the preference or be logged out and have not
|
|
* disabled previews via the settings modal.
|
|
*
|
|
* @param {mw.user} user The `mw.user` singleton instance
|
|
* @param {Object} userSettings An object returned by
|
|
* `mw.popups.createUserSettings`
|
|
* @param {mw.Map} config
|
|
*
|
|
* @return {Boolean}
|
|
*/
|
|
mw.popups.isEnabled = function ( user, userSettings, config ) {
|
|
if ( !user.isAnon() ) {
|
|
return config.get( 'wgPopupsShouldSendModuleToUser' );
|
|
}
|
|
|
|
if ( config.get( 'wgPopupsBetaFeature' ) ) {
|
|
return false;
|
|
}
|
|
|
|
return !userSettings.hasIsEnabled() ||
|
|
( userSettings.hasIsEnabled() && userSettings.getIsEnabled() );
|
|
};
|
|
|
|
}( mediaWiki ) );
|