mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-23 23:24:39 +00:00
Set a global when reference previews are visible.
Used for tracking baseline stats in the Cite extension. Also fixed the wireing of the Reference Preview type constant so that the settings can be tracked. Not sure where this should go best in the new code. Bug: T353798 Change-Id: I1c434f0098ae23bd62256686a658e3d5ef7f70b9
This commit is contained in:
parent
e15e2c4d14
commit
694b96a19f
|
@ -11,7 +11,6 @@ import { previewTypes } from '../../src/preview/model';
|
||||||
import scaleDownThumbnail from './scaleDownThumbnail';
|
import scaleDownThumbnail from './scaleDownThumbnail';
|
||||||
|
|
||||||
registerPreviewUI( previewTypes.TYPE_PAGE, createPagePreview );
|
registerPreviewUI( previewTypes.TYPE_PAGE, createPagePreview );
|
||||||
registerPreviewUI( previewTypes.TYPE_REFERENCE, createReferencePreview );
|
|
||||||
registerPreviewUI( previewTypes.TYPE_DISAMBIGUATION, createDisambiguationPreview );
|
registerPreviewUI( previewTypes.TYPE_DISAMBIGUATION, createDisambiguationPreview );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,8 +94,8 @@ function createPopup( model, layoutHint ) {
|
||||||
link.setAttribute( 'href', '#' );
|
link.setAttribute( 'href', '#' );
|
||||||
link.setAttribute( 'class', 'popups-storybook-link' );
|
link.setAttribute( 'class', 'popups-storybook-link' );
|
||||||
link.textContent = `Page preview ${layout.flippedX ? 'flipped-x' : ''}
|
link.textContent = `Page preview ${layout.flippedX ? 'flipped-x' : ''}
|
||||||
${layout.flippedY ? 'flipped-y' : ''}
|
${layout.flippedY ? 'flipped-y' : ''}
|
||||||
${preview.isTall ? '(landscape)' : '(portrait)'}
|
${preview.isTall ? '(landscape)' : '(portrait)'}
|
||||||
${preview.hasThumbnail ? 'with thumbnail' : ''}`;
|
${preview.hasThumbnail ? 'with thumbnail' : ''}`;
|
||||||
|
|
||||||
wrapper.appendChild( link );
|
wrapper.appendChild( link );
|
||||||
|
|
BIN
resources/dist/index.js
vendored
BIN
resources/dist/index.js
vendored
Binary file not shown.
BIN
resources/dist/index.js.map.json
vendored
BIN
resources/dist/index.js.map.json
vendored
Binary file not shown.
BIN
resources/dist/referencePreviews.js
vendored
BIN
resources/dist/referencePreviews.js
vendored
Binary file not shown.
BIN
resources/dist/referencePreviews.js.map.json
vendored
BIN
resources/dist/referencePreviews.js.map.json
vendored
Binary file not shown.
|
@ -6,9 +6,17 @@ import { TYPE_REFERENCE, FETCH_DELAY_REFERENCE_TYPE } from './constants';
|
||||||
import setUserConfigFlags from './setUserConfigFlags';
|
import setUserConfigFlags from './setUserConfigFlags';
|
||||||
|
|
||||||
setUserConfigFlags( mw.config );
|
setUserConfigFlags( mw.config );
|
||||||
const referencePreviewsState = isReferencePreviewsEnabled( mw.user, mw.popups.isEnabled, mw.config );
|
const referencePreviewsState = isReferencePreviewsEnabled(
|
||||||
|
mw.user, mw.popups.isEnabled,
|
||||||
|
mw.config
|
||||||
|
);
|
||||||
const gateway = createReferenceGateway();
|
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 );
|
||||||
|
|
||||||
window.refPreviews = referencePreviewsState !== null ? {
|
window.refPreviews = referencePreviewsState !== null ? {
|
||||||
type: TYPE_REFERENCE,
|
type: TYPE_REFERENCE,
|
||||||
selector: '#mw-content-text .reference a[ href*="#" ]',
|
selector: '#mw-content-text .reference a[ href*="#" ]',
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { previewTypes } from './preview/model';
|
import { previewTypes } from './preview/model';
|
||||||
|
import { TYPE_REFERENCE } from './ext.popups.referencePreviews/constants.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @module userSettings
|
* @module userSettings
|
||||||
|
@ -33,7 +34,7 @@ export default function createUserSettings( storage ) {
|
||||||
const isRefsDisabled = !!storage.get( REFERENCE_PREVIEWS_ENABLED_KEY );
|
const isRefsDisabled = !!storage.get( REFERENCE_PREVIEWS_ENABLED_KEY );
|
||||||
if ( isRefsDisabled ) {
|
if ( isRefsDisabled ) {
|
||||||
storage.remove( REFERENCE_PREVIEWS_ENABLED_KEY );
|
storage.remove( REFERENCE_PREVIEWS_ENABLED_KEY );
|
||||||
this.storePreviewTypeEnabled( previewTypes.TYPE_REFERENCE, false );
|
this.storePreviewTypeEnabled( TYPE_REFERENCE, false );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
@ -60,7 +61,7 @@ export default function createUserSettings( storage ) {
|
||||||
* @param {boolean} enabled
|
* @param {boolean} enabled
|
||||||
*/
|
*/
|
||||||
storePreviewTypeEnabled( previewType, enabled ) {
|
storePreviewTypeEnabled( previewType, enabled ) {
|
||||||
if ( previewType === previewTypes.TYPE_REFERENCE ) {
|
if ( previewType === TYPE_REFERENCE ) {
|
||||||
mw.track( REFERENCE_PREVIEWS_LOGGING_SCHEMA, {
|
mw.track( REFERENCE_PREVIEWS_LOGGING_SCHEMA, {
|
||||||
action: enabled ? 'anonymousEnabled' : 'anonymousDisabled'
|
action: enabled ? 'anonymousEnabled' : 'anonymousDisabled'
|
||||||
} );
|
} );
|
||||||
|
|
Loading…
Reference in a new issue