mediawiki-extensions-Popups/resources/ext.popups/actions.js
Sam Smith 9611d3b2db Add LINK_DWELL and LINK_ABANDON actions
Supporting changes:
* Add mw.popups.processLinks.
* Extract the existing unit tests for mw.popups.selectPopupElements and
  mw.popups.getTitle.
* Fix Grunt QUnit timeout.

Change-Id: I325bcb15abc6e0b745d78b7308a346a034ab2988
2016-11-10 11:47:55 +00:00

57 lines
1.2 KiB
JavaScript

( function ( mw, Redux ) {
var actions = {};
/**
* @param {Function} isUserInCondition See `mw.popups.createExperiment`
*/
actions.boot = function ( isUserInCondition ) {
return {
type: 'BOOT',
isUserInCondition: isUserInCondition()
};
};
/**
* Represents the user dwelling on a link, either by hovering over it with
* their mouse or by focussing it using their keyboard or an assistive device.
*
* @param {jQuery} $el
* @return {Object}
*/
actions.linkDwell = function ( $el ) {
return {
type: 'LINK_DWELL',
el: $el
};
};
/**
* Represents the user abandoning a link, either by moving their mouse away
* from it or by shifting focus to another UI element using their keyboard or
* an assistive device.
*
* @param {jQuery} $el
* @return {Object}
*/
actions.linkAbandon = function ( $el ) {
return {
type: 'LINK_ABANDON',
el: $el
};
};
/**
* Creates an object whose methods encapsulate all actions that can be
* dispatched to the given
* [store](http://redux.js.org/docs/api/Store.html#store).
*
* @param {Store} store
* @return {Object}
*/
mw.popups.createActions = function ( store ) {
return Redux.bindActionCreators( actions, store.dispatch );
};
}( mediaWiki, Redux ) );