mediawiki-extensions-Popups/resources/ext.popups/wait.js
joakin 550b68cab5 Hygiene: Correct return value type on mw.popups.wait
Change-Id: I0c5c5c1291f413241e855471b71b0e88f6de01c7
2016-11-30 13:50:13 +01:00

27 lines
487 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.Promise}
*/
mw.popups.wait = function ( delay ) {
var result = $.Deferred();
setTimeout( function () {
result.resolve();
}, delay );
return result.promise();
};
}( mediaWiki, jQuery ) );