2016-11-08 11:06:19 +00:00
|
|
|
( function ( mw, Redux, ReduxThunk ) {
|
2016-11-09 11:57:24 +00:00
|
|
|
var BLACKLISTED_LINKS = [
|
|
|
|
'.extiw',
|
|
|
|
'.image',
|
|
|
|
'.new',
|
|
|
|
'.internal',
|
|
|
|
'.external',
|
|
|
|
'.oo-ui-buttonedElement-button',
|
|
|
|
'.cancelLink a'
|
|
|
|
];
|
2016-11-08 10:05:40 +00:00
|
|
|
|
|
|
|
/**
|
2016-11-08 11:06:19 +00:00
|
|
|
* A [null](https://en.wikipedia.org/wiki/Null_Object_pattern) reducer.
|
2016-11-08 10:05:40 +00:00
|
|
|
*
|
2016-11-08 11:06:19 +00:00
|
|
|
* @param {Object} state The current state
|
|
|
|
* @param {Object} action The action that was dispatched against the store
|
|
|
|
* @return {Object} The new state
|
2016-11-08 10:05:40 +00:00
|
|
|
*/
|
|
|
|
function rootReducer( state, action ) {
|
|
|
|
/* jshint unused: false */
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2016-11-09 11:57:24 +00:00
|
|
|
/**
|
|
|
|
* Return whether the user is in the experiment group
|
|
|
|
*
|
|
|
|
* @return {Boolean}
|
|
|
|
*/
|
|
|
|
function isUserInCondition() {
|
|
|
|
var userSettings = mw.popups.createUserSettings( mw.storage, mw.user );
|
|
|
|
|
|
|
|
return mw.popups.createExperiment(
|
|
|
|
mw.config,
|
|
|
|
mw.user,
|
|
|
|
userSettings
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-11-08 10:05:40 +00:00
|
|
|
mw.requestIdleCallback( function () {
|
2016-11-08 19:42:21 +00:00
|
|
|
var compose = Redux.compose,
|
|
|
|
store,
|
2016-11-09 11:57:24 +00:00
|
|
|
actions;
|
2016-11-08 11:06:19 +00:00
|
|
|
|
|
|
|
// If debug mode is enabled, then enable Redux DevTools.
|
|
|
|
if ( mw.config.get( 'debug' ) === true ) {
|
|
|
|
compose = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
|
|
|
|
}
|
|
|
|
|
2016-11-08 19:42:21 +00:00
|
|
|
store = Redux.createStore(
|
2016-11-08 10:05:40 +00:00
|
|
|
rootReducer,
|
2016-11-08 11:06:19 +00:00
|
|
|
compose( Redux.applyMiddleware(
|
|
|
|
ReduxThunk.default
|
|
|
|
) )
|
2016-11-08 10:05:40 +00:00
|
|
|
);
|
2016-11-09 11:57:24 +00:00
|
|
|
actions = mw.popups.createActions( store );
|
2016-11-08 19:42:21 +00:00
|
|
|
|
2016-11-09 11:57:24 +00:00
|
|
|
actions.boot( isUserInCondition() );
|
|
|
|
|
|
|
|
mw.hook( 'wikipage.content' ).add( function ( $container ) {
|
|
|
|
var previewLinks =
|
|
|
|
mw.popups.processLinks(
|
|
|
|
$container,
|
|
|
|
BLACKLISTED_LINKS
|
|
|
|
);
|
2016-11-08 19:42:21 +00:00
|
|
|
|
2016-11-09 11:57:24 +00:00
|
|
|
previewLinks
|
|
|
|
.on( 'mouseover focus', function () {
|
|
|
|
actions.linkDwell( this );
|
|
|
|
} )
|
|
|
|
.on( 'mouseout blur', function () {
|
|
|
|
actions.linkAbandon( this );
|
2016-11-10 12:05:38 +00:00
|
|
|
} )
|
|
|
|
.on( 'click', function () {
|
|
|
|
actions.linkClick( this );
|
2016-11-09 11:57:24 +00:00
|
|
|
} );
|
2016-11-10 12:05:38 +00:00
|
|
|
|
2016-11-09 11:57:24 +00:00
|
|
|
} );
|
2016-11-08 10:05:40 +00:00
|
|
|
} );
|
|
|
|
|
2016-11-08 11:06:19 +00:00
|
|
|
}( mediaWiki, Redux, ReduxThunk ) );
|