mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-27 16:30:12 +00:00
Remove global for if previews are shown
This global was needed to communicate the actual state of the previews from Popups to Cite. Now this setting can be retrieved in a more direct way. Change-Id: I592761bb0121abcf7e8ab279b7385d6920cce37e
This commit is contained in:
parent
b21dbff0cc
commit
afdbf2d46d
|
@ -13,11 +13,6 @@ const referencePreviewsState = isReferencePreviewsEnabled(
|
|||
);
|
||||
const gateway = createReferenceGateway();
|
||||
|
||||
// For tracking baseline stats in the Cite extension https://phabricator.wikimedia.org/T353798
|
||||
// FIXME: This might be obsolete when the code moves to the Cite extension and the tracking there
|
||||
// can check that state differently.
|
||||
mw.config.set( 'wgPopupsReferencePreviewsVisible', !!referencePreviewsState );
|
||||
|
||||
mw.trackSubscribe( 'Popups.SettingChange', ( data ) => {
|
||||
if ( data.previewType === TYPE_REFERENCE ) {
|
||||
mw.track( LOGGING_SCHEMA, data );
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
* @see https://meta.wikimedia.org/wiki/Schema:ReferencePreviewsCite
|
||||
*/
|
||||
|
||||
const isReferencePreviewsEnabled =
|
||||
require( './ext.cite.referencePreviews/isReferencePreviewsEnabled.js' );
|
||||
|
||||
const CITE_BASELINE_LOGGING_SCHEMA = 'ext.cite.baseline';
|
||||
// Same as in the Popups extension
|
||||
// FIXME: Could be an extension wide constant when Reference Previews is merged into this code base
|
||||
const REFERENCE_PREVIEWS_LOGGING_SCHEMA = 'event.ReferencePreviewsPopups';
|
||||
|
||||
// EventLogging may not be installed
|
||||
mw.loader.using( 'ext.eventLogging' ).then( function () {
|
||||
|
@ -25,28 +25,24 @@ mw.loader.using( 'ext.eventLogging' ).then( function () {
|
|||
return;
|
||||
}
|
||||
|
||||
// FIXME: This might be obsolete when the code moves to the this extension
|
||||
mw.trackSubscribe( REFERENCE_PREVIEWS_LOGGING_SCHEMA, function ( type, data ) {
|
||||
if ( data.action.indexOf( 'anonymous' ) !== -1 ) {
|
||||
mw.config.set( 'wgPopupsReferencePreviewsVisible', data.action === 'anonymousEnabled' );
|
||||
}
|
||||
} );
|
||||
|
||||
// eslint-disable-next-line no-jquery/no-global-selector
|
||||
$( '#mw-content-text' ).on(
|
||||
'click',
|
||||
// Footnote links, references block in VisualEditor, and reference content links.
|
||||
'.reference a[ href*="#" ], .mw-reference-text a, .reference-text a',
|
||||
function () {
|
||||
const referencePreviewsState = isReferencePreviewsEnabled(
|
||||
mw.user,
|
||||
mw.popups.isEnabled,
|
||||
mw.config
|
||||
);
|
||||
const isInReferenceBlock = $( this ).parents( '.references' ).length > 0;
|
||||
mw.eventLog.dispatch( CITE_BASELINE_LOGGING_SCHEMA, {
|
||||
action: ( isInReferenceBlock ?
|
||||
'clickedReferenceContentLink' :
|
||||
'clickedFootnote' ),
|
||||
// FIXME: This might be obsolete when the code moves to the this extension and
|
||||
// we get state directly.
|
||||
// eslint-disable-next-line camelcase
|
||||
with_ref_previews: mw.config.get( 'wgPopupsReferencePreviewsVisible' )
|
||||
with_ref_previews: referencePreviewsState
|
||||
} );
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue