mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-06-25 04:11:49 +02:00
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:
parent
99797c3639
commit
34a2f8c6e0
@ -461,37 +461,31 @@ egw_json_request.prototype.handleResponse = function(data, textStatus, XMLHttpRe
|
|||||||
throw 'Invalid parameters';
|
throw 'Invalid parameters';
|
||||||
break;
|
break;
|
||||||
case 'apply':
|
case 'apply':
|
||||||
if (typeof res.data.func == 'string' && typeof window[res.data.func] == 'function')
|
if (typeof res.data.func == 'string')
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
parent = parent[parts[i]];
|
||||||
|
}
|
||||||
|
if (typeof parent[func] == 'function')
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
window[res.data.func].apply(window, res.data.parms);
|
parent[func].apply(parent, res.data.parms);
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
_egw_json_debug_log(e, {'Function': res.data.func, 'Parameters': res.data.parms});
|
_egw_json_debug_log(e, {'Function': res.data.func, 'Parameters': res.data.parms});
|
||||||
}
|
}
|
||||||
hasResponse = true;
|
hasResponse = true;
|
||||||
} else if (typeof res.data.func == "string" &&
|
|
||||||
res.data.func.substr(0,4) == "app." && window.app)
|
|
||||||
{
|
|
||||||
|
|
||||||
var parts = res.data.func.split(".");
|
|
||||||
if(parts.length == 3 && typeof window.app[parts[1]] == "object" &&
|
|
||||||
typeof window.app[parts[1]][parts[2]] == "function")
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
this.context = window.app[parts[1]][parts[2]].apply(window.app[parts[1]], res.data.parms);
|
|
||||||
}
|
}
|
||||||
catch (e)
|
else
|
||||||
{
|
throw 'Invalid parameters';
|
||||||
_egw_json_debug_log(e, {'Function': res.data.func, 'Parameters': res.data.parms});
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
hasResponse = true;
|
|
||||||
|
|
||||||
} else
|
|
||||||
throw 'Invalid parameters';
|
throw 'Invalid parameters';
|
||||||
break;
|
break;
|
||||||
case 'jquery':
|
case 'jquery':
|
||||||
|
@ -283,12 +283,20 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd) {
|
|||||||
|
|
||||||
// Register the "apply" plugin
|
// Register the "apply" plugin
|
||||||
json.registerJSONPlugin(function(type, res, req) {
|
json.registerJSONPlugin(function(type, res, req) {
|
||||||
if (typeof res.data.func == 'string' &&
|
if (typeof res.data.func == 'string')
|
||||||
typeof window[res.data.func] == 'function')
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
parent = parent[parts[i]];
|
||||||
|
}
|
||||||
|
if (typeof parent[func] == 'function')
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
window[res.data.func].apply(window, res.data.parms);
|
parent[func].apply(parent, res.data.parms);
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
@ -297,6 +305,7 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd) {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
throw 'Invalid parameters';
|
throw 'Invalid parameters';
|
||||||
}, null, 'apply');
|
}, null, 'apply');
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user