mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-08-17 20:11:23 +02:00
move global et2_call function to egw.call and egw.apply methods, ensuring app.js is loaded, if not yet loaded, also using that as apply plugin for egw.json
This commit is contained in:
@@ -472,39 +472,13 @@ var exports = {};
|
||||
* Call a function specified by it's name (possibly dot separated, eg. "app.myapp.myfunc")
|
||||
*
|
||||
* @param {string} _func dot-separated function name
|
||||
* variable number of arguments
|
||||
* @returns {Boolean}
|
||||
* @param {mixed} ...args variable number of arguments
|
||||
* @returns {Mixed|Promise}
|
||||
* @deprecated use egw.call(_func, ...) or egw.apply(_func, args)
|
||||
*/
|
||||
function et2_call(_func)
|
||||
{
|
||||
var args = [].slice.call(arguments); // convert arguments to array
|
||||
var func = args.shift();
|
||||
var parent = window;
|
||||
|
||||
if (typeof _func == 'string')
|
||||
{
|
||||
var parts = _func.split('.');
|
||||
func = parts.pop();
|
||||
for(var i=0; i < parts.length; ++i)
|
||||
{
|
||||
if (typeof parent[parts[i]] != 'undefined')
|
||||
{
|
||||
parent = parent[parts[i]];
|
||||
}
|
||||
// check if we need a not yet instanciated app.js object --> instanciate it now
|
||||
else if (i == 1 && parts[0] == 'app' && typeof app.classes[parts[1]] == 'function')
|
||||
{
|
||||
parent = parent[parts[1]] = new app.classes[parts[1]]();
|
||||
}
|
||||
}
|
||||
if (typeof parent[func] == 'function')
|
||||
{
|
||||
func = parent[func];
|
||||
}
|
||||
}
|
||||
if (typeof func != 'function')
|
||||
{
|
||||
throw _func+" is not a function!";
|
||||
}
|
||||
return func.apply(parent, args);
|
||||
let args = [].slice.call(arguments); // convert arguments to array
|
||||
let func = args.shift();
|
||||
return egw.apply(func, args, window);
|
||||
}
|
||||
|
Reference in New Issue
Block a user