mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 14:41:29 +01:00
improve egw.langRequire to return a Promise, if no callback specified
This commit is contained in:
parent
d185a53f8e
commit
eefd8ed972
@ -133,6 +133,7 @@ egw.extend('lang', egw.MODULE_GLOBAL, function()
|
|||||||
* }
|
* }
|
||||||
* @param {function} _callback called after loading, if not given ready event will be postponed instead
|
* @param {function} _callback called after loading, if not given ready event will be postponed instead
|
||||||
* @param {object} _context for callback
|
* @param {object} _context for callback
|
||||||
|
* @return Promise if no _callback specified
|
||||||
*/
|
*/
|
||||||
langRequire: function(_window, _apps, _callback, _context) {
|
langRequire: function(_window, _apps, _callback, _context) {
|
||||||
// Get the ready and the files module for the given window
|
// Get the ready and the files module for the given window
|
||||||
@ -171,10 +172,14 @@ egw.extend('lang', egw.MODULE_GLOBAL, function()
|
|||||||
// Require a "ready postpone token"
|
// Require a "ready postpone token"
|
||||||
var token = ready.readyWaitFor();
|
var token = ready.readyWaitFor();
|
||||||
|
|
||||||
|
return new Promise(function(resolve)
|
||||||
|
{
|
||||||
// Call "readyDone" once all js files have been included.
|
// Call "readyDone" once all js files have been included.
|
||||||
files.includeJS(jss, function () {
|
files.includeJS(jss, function () {
|
||||||
ready.readyDone(token);
|
ready.readyDone(token);
|
||||||
|
resolve();
|
||||||
}, this);
|
}, this);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (typeof _callback == 'function')
|
else if (typeof _callback == 'function')
|
||||||
|
Loading…
Reference in New Issue
Block a user