mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-24 07:34:11 +00:00
Avoid shadowed variables in javascript
The rule no-shadow gets enabled in the version eslint-config-wikimedia 0.17.0. In prepration for the automatic update with libup this needs to be done in a separate patch set due to T262450 Change-Id: I66d405aef6d2b777e9a7f63734f2b5a5649d2080
This commit is contained in:
parent
8b6e85dd7c
commit
23b6332a5b
|
@ -67,7 +67,7 @@
|
||||||
"bundlesize": [
|
"bundlesize": [
|
||||||
{
|
{
|
||||||
"path": "resources/dist/index.js",
|
"path": "resources/dist/index.js",
|
||||||
"maxSize": "13.64kB"
|
"maxSize": "13.7kB"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
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.
|
@ -149,12 +149,12 @@ export function fetch( gateway, title, el, token, type ) {
|
||||||
} )
|
} )
|
||||||
.catch( ( err, data ) => {
|
.catch( ( err, data ) => {
|
||||||
const exception = new Error( err );
|
const exception = new Error( err );
|
||||||
const type = data && data.textStatus && data.textStatus === 'abort' ?
|
const fetchType = data && data.textStatus && data.textStatus === 'abort' ?
|
||||||
types.FETCH_ABORTED : types.FETCH_FAILED;
|
types.FETCH_ABORTED : types.FETCH_FAILED;
|
||||||
|
|
||||||
exception.data = data;
|
exception.data = data;
|
||||||
dispatch( {
|
dispatch( {
|
||||||
type,
|
type: fetchType,
|
||||||
el,
|
el,
|
||||||
token
|
token
|
||||||
} );
|
} );
|
||||||
|
|
|
@ -19,8 +19,8 @@ export default function eventLogging(
|
||||||
boundActions, eventLoggingTracker, getCurrentTimestamp
|
boundActions, eventLoggingTracker, getCurrentTimestamp
|
||||||
) {
|
) {
|
||||||
return ( _, state ) => {
|
return ( _, state ) => {
|
||||||
const eventLogging = state.eventLogging;
|
const eventLoggingObj = state.eventLogging;
|
||||||
let event = eventLogging.event;
|
let event = eventLoggingObj.event;
|
||||||
|
|
||||||
if ( !event ) {
|
if ( !event ) {
|
||||||
return;
|
return;
|
||||||
|
@ -33,7 +33,7 @@ export default function eventLogging(
|
||||||
// Rightly or wrongly, it's left as an exercise for the analyst to
|
// Rightly or wrongly, it's left as an exercise for the analyst to
|
||||||
// calculate the time at which the interaction started as part of their
|
// calculate the time at which the interaction started as part of their
|
||||||
// analyses, e.g. https://phabricator.wikimedia.org/T186016#4002923.
|
// analyses, e.g. https://phabricator.wikimedia.org/T186016#4002923.
|
||||||
event = $.extend( true, {}, eventLogging.baseData, event, {
|
event = $.extend( true, {}, eventLoggingObj.baseData, event, {
|
||||||
timestamp: getCurrentTimestamp()
|
timestamp: getCurrentTimestamp()
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* @return {ext.popups.ChangeListener}
|
* @return {ext.popups.ChangeListener}
|
||||||
*/
|
*/
|
||||||
export default function settings( boundActions, render ) {
|
export default function settings( boundActions, render ) {
|
||||||
let settings;
|
let settingsObj;
|
||||||
|
|
||||||
return ( prevState, state ) => {
|
return ( prevState, state ) => {
|
||||||
if ( !prevState ) {
|
if ( !prevState ) {
|
||||||
|
@ -20,25 +20,25 @@ export default function settings( boundActions, render ) {
|
||||||
state.settings.shouldShow === true
|
state.settings.shouldShow === true
|
||||||
) {
|
) {
|
||||||
// Lazily instantiate the settings UI
|
// Lazily instantiate the settings UI
|
||||||
if ( !settings ) {
|
if ( !settingsObj ) {
|
||||||
settings = render( boundActions );
|
settingsObj = render( boundActions );
|
||||||
settings.appendTo( document.body );
|
settingsObj.appendTo( document.body );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the UI settings with the current settings
|
// Update the UI settings with the current settings
|
||||||
settings.setEnabled( state.preview.enabled );
|
settingsObj.setEnabled( state.preview.enabled );
|
||||||
|
|
||||||
settings.show();
|
settingsObj.show();
|
||||||
} else if (
|
} else if (
|
||||||
prevState.settings.shouldShow === true &&
|
prevState.settings.shouldShow === true &&
|
||||||
state.settings.shouldShow === false
|
state.settings.shouldShow === false
|
||||||
) {
|
) {
|
||||||
settings.hide();
|
settingsObj.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update help visibility
|
// Update help visibility
|
||||||
if ( prevState.settings.showHelp !== state.settings.showHelp ) {
|
if ( prevState.settings.showHelp !== state.settings.showHelp ) {
|
||||||
settings.toggleHelp( state.settings.showHelp );
|
settingsObj.toggleHelp( state.settings.showHelp );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,10 +12,10 @@
|
||||||
*/
|
*/
|
||||||
export default function statsv( boundActions, track ) {
|
export default function statsv( boundActions, track ) {
|
||||||
return ( _, state ) => {
|
return ( _, state ) => {
|
||||||
const statsv = state.statsv;
|
const statsvObj = state.statsv;
|
||||||
|
|
||||||
if ( statsv.action ) {
|
if ( statsvObj.action ) {
|
||||||
track( statsv.action, statsv.data );
|
track( statsvObj.action, statsvObj.data );
|
||||||
|
|
||||||
boundActions.statsvLogged();
|
boundActions.statsvLogged();
|
||||||
}
|
}
|
||||||
|
|
16
src/index.js
16
src/index.js
|
@ -115,36 +115,36 @@ function getCurrentTimestamp() {
|
||||||
* [store](http://redux.js.org/docs/api/Store.html#store).
|
* [store](http://redux.js.org/docs/api/Store.html#store).
|
||||||
*
|
*
|
||||||
* @param {Redux.Store} store
|
* @param {Redux.Store} store
|
||||||
* @param {Object} actions
|
* @param {Object} registerActions
|
||||||
* @param {UserSettings} userSettings
|
* @param {UserSettings} userSettings
|
||||||
* @param {Function} settingsDialog
|
* @param {Function} settingsDialog
|
||||||
* @param {PreviewBehavior} previewBehavior
|
* @param {PreviewBehavior} previewBehavior
|
||||||
* @param {EventTracker} statsvTracker
|
* @param {EventTracker} statsvTracker
|
||||||
* @param {EventTracker} eventLoggingTracker
|
* @param {EventTracker} eventLoggingTracker
|
||||||
* @param {EventTracker} pageviewTracker
|
* @param {EventTracker} pageviewTracker
|
||||||
* @param {Function} getCurrentTimestamp
|
* @param {Function} callbackCurrentTimestamp
|
||||||
* @return {void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
function registerChangeListeners(
|
function registerChangeListeners(
|
||||||
store, actions, userSettings, settingsDialog, previewBehavior,
|
store, registerActions, userSettings, settingsDialog, previewBehavior,
|
||||||
statsvTracker, eventLoggingTracker, pageviewTracker, getCurrentTimestamp
|
statsvTracker, eventLoggingTracker, pageviewTracker, callbackCurrentTimestamp
|
||||||
) {
|
) {
|
||||||
registerChangeListener( store, changeListeners.footerLink( actions ) );
|
registerChangeListener( store, changeListeners.footerLink( actions ) );
|
||||||
registerChangeListener( store, changeListeners.linkTitle() );
|
registerChangeListener( store, changeListeners.linkTitle() );
|
||||||
registerChangeListener( store, changeListeners.render( previewBehavior ) );
|
registerChangeListener( store, changeListeners.render( previewBehavior ) );
|
||||||
registerChangeListener(
|
registerChangeListener(
|
||||||
store, changeListeners.statsv( actions, statsvTracker ) );
|
store, changeListeners.statsv( registerActions, statsvTracker ) );
|
||||||
registerChangeListener(
|
registerChangeListener(
|
||||||
store, changeListeners.syncUserSettings( userSettings ) );
|
store, changeListeners.syncUserSettings( userSettings ) );
|
||||||
registerChangeListener(
|
registerChangeListener(
|
||||||
store, changeListeners.settings( actions, settingsDialog ) );
|
store, changeListeners.settings( registerActions, settingsDialog ) );
|
||||||
registerChangeListener(
|
registerChangeListener(
|
||||||
store,
|
store,
|
||||||
changeListeners.eventLogging(
|
changeListeners.eventLogging(
|
||||||
actions, eventLoggingTracker, getCurrentTimestamp
|
registerActions, eventLoggingTracker, callbackCurrentTimestamp
|
||||||
) );
|
) );
|
||||||
registerChangeListener( store,
|
registerChangeListener( store,
|
||||||
changeListeners.pageviews( actions, pageviewTracker )
|
changeListeners.pageviews( registerActions, pageviewTracker )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -360,12 +360,12 @@ export function hide( preview ) {
|
||||||
* @param {number} windowData.scrollTop
|
* @param {number} windowData.scrollTop
|
||||||
* @param {number} windowData.width
|
* @param {number} windowData.width
|
||||||
* @param {number} windowData.height
|
* @param {number} windowData.height
|
||||||
* @param {number} pointerSize Space reserved for the pointer
|
* @param {number} pointerSpaceSize Space reserved for the pointer
|
||||||
* @param {string} dir 'ltr' if left-to-right, 'rtl' if right-to-left.
|
* @param {string} dir 'ltr' if left-to-right, 'rtl' if right-to-left.
|
||||||
* @return {ext.popups.PreviewLayout}
|
* @return {ext.popups.PreviewLayout}
|
||||||
*/
|
*/
|
||||||
export function createLayout(
|
export function createLayout(
|
||||||
isPreviewTall, eventData, linkData, windowData, pointerSize, dir
|
isPreviewTall, eventData, linkData, windowData, pointerSpaceSize, dir
|
||||||
) {
|
) {
|
||||||
let flippedX = false,
|
let flippedX = false,
|
||||||
flippedY = false,
|
flippedY = false,
|
||||||
|
@ -377,7 +377,7 @@ export function createLayout(
|
||||||
eventData.pageY - windowData.scrollTop,
|
eventData.pageY - windowData.scrollTop,
|
||||||
linkData.clientRects,
|
linkData.clientRects,
|
||||||
false
|
false
|
||||||
) + windowData.scrollTop + pointerSize :
|
) + windowData.scrollTop + pointerSpaceSize :
|
||||||
// Position according to link position or size
|
// Position according to link position or size
|
||||||
linkData.offset.top + linkData.height + pointerSize,
|
linkData.offset.top + linkData.height + pointerSize,
|
||||||
offsetLeft;
|
offsetLeft;
|
||||||
|
@ -430,7 +430,7 @@ export function createLayout(
|
||||||
) + windowData.scrollTop;
|
) + windowData.scrollTop;
|
||||||
}
|
}
|
||||||
|
|
||||||
offsetTop -= pointerSize;
|
offsetTop -= pointerSpaceSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -498,11 +498,11 @@ export function getClasses( preview, layout ) {
|
||||||
* @param {ext.popups.PreviewLayout} layout
|
* @param {ext.popups.PreviewLayout} layout
|
||||||
* @param {string[]} classes class names used for layout out the preview
|
* @param {string[]} classes class names used for layout out the preview
|
||||||
* @param {number} predefinedLandscapeImageHeight landscape image height
|
* @param {number} predefinedLandscapeImageHeight landscape image height
|
||||||
* @param {number} pointerSize
|
* @param {number} pointerSpaceSize
|
||||||
* @return {void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
export function layoutPreview(
|
export function layoutPreview(
|
||||||
preview, layout, classes, predefinedLandscapeImageHeight, pointerSize
|
preview, layout, classes, predefinedLandscapeImageHeight, pointerSpaceSize
|
||||||
) {
|
) {
|
||||||
const popup = preview.el,
|
const popup = preview.el,
|
||||||
isTall = preview.isTall,
|
isTall = preview.isTall,
|
||||||
|
@ -517,7 +517,7 @@ export function layoutPreview(
|
||||||
) {
|
) {
|
||||||
popup.find( '.mwe-popups-extract' ).css(
|
popup.find( '.mwe-popups-extract' ).css(
|
||||||
'margin-top',
|
'margin-top',
|
||||||
thumbnail.height - pointerSize
|
thumbnail.height - pointerSpaceSize
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import * as stubs from './stubs';
|
import * as stubs from './stubs';
|
||||||
import isEnabled from '../../src/isEnabled';
|
import isEnabled from '../../src/isEnabled';
|
||||||
|
|
||||||
function createStubUserSettings( isEnabled ) {
|
function createStubUserSettings( expectEnabled ) {
|
||||||
return {
|
return {
|
||||||
hasIsEnabled() {
|
hasIsEnabled() {
|
||||||
return isEnabled !== undefined;
|
return expectEnabled !== undefined;
|
||||||
},
|
},
|
||||||
getIsEnabled() {
|
getIsEnabled() {
|
||||||
return Boolean( isEnabled );
|
return Boolean( expectEnabled );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue