mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-15 03:34:03 +00:00
5e2d8ae8d4
Extract core rendering functionality from the mw.popups.renderer and mw.popups.renderer.article objects. For now, render and show the preview when the user dwells on and abandons a link respectively. Supporting changes: * Add mw.popups.wait, which is sugar around window.setTimeout. * action.response -> action.result in the FETCH_END case of the preview reducer. Change-Id: I14b437e7c2f55b988837fcb2800dd61a23c29a01
27 lines
488 B
JavaScript
27 lines
488 B
JavaScript
( function ( mw, $ ) {
|
|
|
|
/**
|
|
* Sugar around `window.setTimeout`.
|
|
*
|
|
* @example
|
|
* function continueProcessing() {
|
|
* // ...
|
|
* }
|
|
*
|
|
* mw.popups.wait( 150 ).then( continueProcessing );
|
|
*
|
|
* @param {Number} delay The number of milliseconds to wait
|
|
* @return {jQuery.Deferred}
|
|
*/
|
|
mw.popups.wait = function ( delay ) {
|
|
var result = $.Deferred();
|
|
|
|
setTimeout( function () {
|
|
result.resolve();
|
|
}, delay );
|
|
|
|
return result.promise();
|
|
};
|
|
|
|
}( mediaWiki, jQuery ) );
|