From 91dc1f9df9e2af072b19eb5da03795f44213c9b9 Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Tue, 9 Apr 2013 14:39:56 +0000 Subject: [PATCH] allow for objectified egw functions like app.APPLICATION. --- phpgwapi/js/egw_json.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/phpgwapi/js/egw_json.js b/phpgwapi/js/egw_json.js index 093d480882..7b640504a9 100644 --- a/phpgwapi/js/egw_json.js +++ b/phpgwapi/js/egw_json.js @@ -472,6 +472,25 @@ egw_json_request.prototype.handleResponse = function(data, textStatus, XMLHttpRe _egw_json_debug_log(e, {'Function': res.data.func, 'Parameters': res.data.parms}); } 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) + { + _egw_json_debug_log(e, {'Function': res.data.func, 'Parameters': res.data.parms}); + } + } + hasResponse = true; + } else throw 'Invalid parameters'; break;