mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-08 09:04:53 +01:00
Add not implemented js function type. It understands app.appname.function style arguments
This commit is contained in:
parent
a4395a8000
commit
4239b83bd0
@ -209,6 +209,40 @@ function et2_checkType(_val, _type, _attr, _cname)
|
||||
return _err();
|
||||
}
|
||||
|
||||
// Javascript
|
||||
if (_type == "js")
|
||||
{
|
||||
if (typeof _val == "function")
|
||||
{
|
||||
return _val;
|
||||
}
|
||||
|
||||
// Check to see if it's a string in app.appname.function format, and wrap it in
|
||||
// a closure to make sure context is preserved
|
||||
if(typeof _val == "string" && _val.substr(0,4) == "app." && window.app)
|
||||
{
|
||||
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
|
||||
{
|
||||
return jQuery.proxy(parent,parent[func]);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
req.egw.debug('error', 'Function', _val);
|
||||
return _err();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We should never come here
|
||||
throw("Invalid type identifier '" + _attr + ": " + _type + "' supplied by '" + _cname + "'");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user