support for non-global func eg. "app.someapp.func" need to be in both egw_json objects (until we fix it so one calls the other)

This commit is contained in:
Ralf Becker
2013-04-12 16:03:45 +00:00
parent 99797c3639
commit 34a2f8c6e0
2 changed files with 30 additions and 27 deletions

View File

@ -283,19 +283,28 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd) {
// Register the "apply" plugin
json.registerJSONPlugin(function(type, res, req) {
if (typeof res.data.func == 'string' &&
typeof window[res.data.func] == 'function')
if (typeof res.data.func == 'string')
{
try
var parts = res.data.func.split('.');
var func = parts.pop();
var parent = window;
for(var i=0; i < parts.length && typeof parent[parts[i]] != 'undefined'; ++i)
{
window[res.data.func].apply(window, res.data.parms);
parent = parent[parts[i]];
}
catch (e)
if (typeof parent[func] == 'function')
{
req.egw.debug('error', 'Function', res.data.func,
'Parameters', res.data.parms);
try
{
parent[func].apply(parent, res.data.parms);
}
catch (e)
{
req.egw.debug('error', 'Function', res.data.func,
'Parameters', res.data.parms);
}
return true;
}
return true;
}
throw 'Invalid parameters';
}, null, 'apply');