From d4880a3351d2c0dd2f8cc5e7defed9ae268681ab Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Sat, 20 Jul 2013 13:42:23 +0000 Subject: [PATCH] Load & parse etemplate2 if set in egw.js object's data-attributes --- phpgwapi/js/jsapi/egw.js | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/phpgwapi/js/jsapi/egw.js b/phpgwapi/js/jsapi/egw.js index 16e7832c67..86854c1f13 100644 --- a/phpgwapi/js/jsapi/egw.js +++ b/phpgwapi/js/jsapi/egw.js @@ -102,13 +102,34 @@ } } window.egw_LAB.script(include).wait(function(){ - var data = egw_script.getAttribute('data-preferences'); + var data = egw_script.getAttribute('data-etemplate'); if (data) { data = JSON.parse(data) || {}; - for(var app in data) + // Initialize application js + var callback = null; + // Only initialize once + if(typeof app[window.egw_appName] == "function") { - window.egw.set_preferences(data[app], app); + (function() { new app[window.egw_appName]();}).call(); + } + else + { + egw.debug("warn", "Did not load '%s' JS object",window.egw_appName); + } + if(typeof app[window.egw_appName] == "object") + { + callback = function(et2) {app["'.$app.'"].et2_ready(et2)}; + } + var node = document.getElementById(data.DOMNodeID); + if(!node) + { + egw.debug("error", "Could not find target node %s", data.DOMNodeID); + } + else + { + var et2 = new etemplate2(node, "etemplate::ajax_process_content"); + et2.load(data.name,data.url,data.data,callback); } } if (data = egw_script.getAttribute('data-user'))