Author: ralfbecker
New Revision: 55413
URL: http://svn.stylite.de/viewvc/egroupware?rev=55413&view=rev
Log:
fix situation where multiple app.js objects are used, eg. InfoLog and CRM view in Addressbook:
- etemplate2 creates a private app object instead of using window.app with just prototypes, if template is not from current app
- fixed all cases where window.app was used to use just app, to use evtl. private object
- app_base no longer assigns itself to window.app (window.app[this.appname] = this), as that breaks private app objects
- et2_compileLegacyJS replaces app.appname with widget.getInstanceManager().app_obj.appname
- etemplate2 stores either private or global app object in app_obj attribute
Modified:
trunk/etemplate/js/et2_core_common.js
trunk/etemplate/js/et2_core_legacyJSFunctions.js
trunk/etemplate/js/et2_extension_nextmatch.js
trunk/etemplate/js/etemplate2.js
trunk/infolog/js/app.js
trunk/phpgwapi/js/egw_action/egw_action_common.js
trunk/phpgwapi/js/egw_json.js
trunk/phpgwapi/js/framework/fw_browser.js
trunk/phpgwapi/js/jsapi/app_base.js
trunk/phpgwapi/js/jsapi/egw.js
— trunk/etemplate/js/et2_core_common.js (original)
+++ trunk/etemplate/js/et2_core_common.js Thu Mar 17 19:12:36 2016
@@ -237,7 +237,7 @@
// 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
— trunk/etemplate/js/et2_core_legacyJSFunctions.js (original)
+++ trunk/etemplate/js/et2_core_legacyJSFunctions.js Thu Mar 17 19:12:36 2016
@@ -28,8 +28,8 @@
* - window.open() replaces it with egw_openWindowCentered2()
* - xajax_doXMLHTTP('etemplate. replace ajax calls in widgets with special handler not requiring etemplate run rights
*
-
-
@param string _val onclick, onchange, … action
-
-
@param string _cname name-prefix / name-space
-
-
@param {string} _val onclick, onchange, … action
-
-
@param {et2_widget} widget
-
@ToDo replace xajax_doXMLHTTP with egw.json()
-
@ToDo replace (common) cases of confirm with new dialog, idea: calling function supplys function to call after confirm
-
@ToDo template::styles(name) inserts the styles of a named template
@@ -131,6 +131,9 @@
{
_code += ‘(ev,widget)’;
}
-
// use app object from etemplate2, which might be private and not just window.app
-
_code = _code.replace(/(window\.)?app\./, 'widget.getInstanceManager().app_obj.');
-
var func = new Function('ev', 'widget', _code);
} catch(e) {
_widget.egw().debug('error', 'Error while compiling JS code ', _code);
— trunk/etemplate/js/et2_extension_nextmatch.js (original)
+++ trunk/etemplate/js/et2_extension_nextmatch.js Thu Mar 17 19:12:36 2016
@@ -544,10 +544,10 @@
// Highlight matching favorite in sidebox
if(this.getInstanceManager().app)
{
— trunk/etemplate/js/etemplate2.js (original)
+++ trunk/etemplate/js/etemplate2.js Thu Mar 17 19:12:36 2016
@@ -353,6 +353,12 @@
egw().debug("info", "Loaded data", _data);
var currentapp = this.app = _data.currentapp || egw().app_name();
-
var appname = _name.split(’.’)[0];
-
// if no app object provided and template app is not currentapp (eg. infolog CRM view)
-
// create private app object / closure with just classes / prototypes
-
if (!_app && appname && appname != currentapp) app = { classes: window.app.classes };
-
// remember used app object, to eg. use: onchange=“widget.getInstanceMgr().app_object[app].callback()”
-
this.app_obj = app;
// extract $content[‘msg’] and call egw.message() with it
var msg = _data.content.msg;
@@ -390,10 +396,6 @@
if (!$j.isArray(_data.langRequire)) _data.langRequire = [];
egw(currentapp, window).langRequire(window, _data.langRequire, function()
{
-
// Appname should be first part of the template name
-
var split = _name.split('.');
-
var appname = split[0];
-
// Initialize application js
var app_callback = null;
// Only initialize once
@@ -407,7 +409,7 @@
{
(function() { new appappname;}).call();
}
@@ -531,11 +533,11 @@
{
app_callback.call(window,this,_name);
}
— trunk/infolog/js/app.js (original)
+++ trunk/infolog/js/app.js Thu Mar 17 19:12:36 2016
@@ -75,7 +75,7 @@
}
else
{
@@ -766,6 +766,9 @@
*/
_get_stylite: function(callback,attrs)
{
-
// use app object from etemplate2, which might be private and not just window.app
-
var app = this.et2.getInstanceManager().app_obj;
-
if (!app.stylite)
{
var self = this;
— trunk/phpgwapi/js/egw_action/egw_action_common.js (original)
+++ trunk/phpgwapi/js/egw_action/egw_action_common.js Thu Mar 17 19:12:36 2016
@@ -236,7 +236,7 @@
var key = "";
- // _id must be a string and evaluate to true - if this is not
- // _id must be a string and evaluate to true - if this is not
// generate an unique key.
if (typeof _id != “string” || !_id)
{
@@ -366,10 +366,10 @@
{
this.fnct = _value;
}
- // Global function (on window)
else if (typeof _value == “string” &&
- // egw application specific function
else if (typeof _value == “string” &&
— trunk/phpgwapi/js/egw_json.js (original)
+++ trunk/phpgwapi/js/egw_json.js Thu Mar 17 19:12:36 2016
@@ -481,22 +481,22 @@
}
hasResponse = true;
} else if (typeof res.data.func == “string” &&
-
if (parts.length == 3 && typeof window.app[parts[1]] == 'undefined' &&
-
typeof window.app.classes[parts[1]] == 'function')
-
{
-
window.app[parts[1]] = new window.app.classes[parts[1]]();
-
}
-
if(parts.length == 3 && typeof window.app[parts[1]] == "object" &&
-
typeof window.app[parts[1]][parts[2]] == "function")
-
if (parts.length == 3 && typeof app[parts[1]] == 'undefined' &&
-
typeof app.classes[parts[1]] == 'function')
-
{
-
app[parts[1]] = new app.classes[parts[1]]();
-
}
-
if(parts.length == 3 && typeof app[parts[1]] == "object" &&
-
typeof app[parts[1]][parts[2]] == "function")
{
try
{
— trunk/phpgwapi/js/framework/fw_browser.js (original)
+++ trunk/phpgwapi/js/framework/fw_browser.js Thu Mar 17 19:12:36 2016
@@ -130,10 +130,10 @@
browse: function(_url)
{
// check if app has its own linkHandler and it accepts the link (returns true), or returns different url instead
-
if (typeof window.app == 'object' && typeof window.app[this.app.appName] == 'object' &&
-
typeof window.app[this.app.appName].linkHandler == 'function')
-
{
-
var ret = window.app[this.app.appName].linkHandler.call(window.app[this.app.appName], _url);
-
if (typeof app == 'object' && typeof app[this.app.appName] == 'object' &&
-
typeof app[this.app.appName].linkHandler == 'function')
-
{
-
var ret = app[this.app.appName].linkHandler.call(app[this.app.appName], _url);
{
if (ret === true) return this.loadingDeferred.promise();
if (typeof ret === 'string')
@@ -195,9 +195,9 @@
}
// Destroy application js
-
if(app[this.app.appName] && app[this.app.appName].destroy)
-
{
-
app[this.app.appName].destroy();
}
// Unload etemplate2, if there
— trunk/phpgwapi/js/jsapi/app_base.js (original)
+++ trunk/phpgwapi/js/jsapi/app_base.js Thu Mar 17 19:12:36 2016
@@ -117,8 +117,6 @@
* is not yet ready.
*/
init: function() {
-
window.app[this.appname] = this;
-
this.egw = egw(this.appname, window);
// Initialize sidebox for non-popups.
@@ -132,7 +130,7 @@
sidebox= $j(’#favorite_sidebox_’+this.appname,egw_fw.sidemenuDiv);
}
// Make sure we’re running in the top window when we init sidebox
@@ -145,14 +143,14 @@
/**
* Clean up any created objects & references
-
-
@param {pbject} _app local app object
-
-
@param {object} _app local app object
*/
destroy: function(_app) {
delete this.et2;
if (this.sidebox)
this.sidebox.off();
delete this.sidebox;
-
-
@param {function} callback function to run after et2 is loaded
-
-
@param {function} et2_callback function to run after et2 is loaded
*/
viewEntry: function(_action, _senders, _noEdit, et2_callback)
{
@@ -1156,6 +1154,8 @@
-
]
-
}
-
}
-
-
-
@param {DOMNode} div
*/
egwTutorial_init: function(div)
{
@@ -1536,23 +1536,22 @@
var dialog = function(_content, _callback)
{
return et2_createWidget(“dialog”, {
-
callback: function(_button_id, _value) {
-
if (typeof _callback == "function")
-
{
-
_callback.call(this, _button_id, _value.value);
-
}
-
},
-
title: egw.lang('PGP Encryption Installation'),
-
buttons: buttons,
-
dialog_type: 'info',
-
value: {
-
content: _content
-
},
-
template: egw.webserverUrl+'/etemplate/templates/default/pgp_installation.xet',
-
class: "pgp_installation",
-
modal: true,
-
//resizable:false,
-
-
callback: function(_button_id, _value) {
-
if (typeof _callback == "function")
-
{
-
_callback.call(this, _button_id, _value.value);
-
}
-
},
-
title: egw.lang('PGP Encryption Installation'),
-
buttons: buttons,
-
dialog_type: 'info',
-
value: {
-
content: _content
-
},
-
template: egw.webserverUrl+'/etemplate/templates/default/pgp_installation.xet',
-
class: "pgp_installation",
-
modal: true
-
//resizable:false,
});
};
var content = [
— trunk/phpgwapi/js/jsapi/egw.js (original)
+++ trunk/phpgwapi/js/jsapi/egw.js Thu Mar 17 19:12:36 2016
@@ -227,9 +227,9 @@
// instanciate app object
var appname = window.egw_appName;
@@ -392,9 +392,9 @@
parent = parent[parts[i]];
}
// check if we need a not yet instanciated app.js object --> instanciate it now
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
eGroupWare-cvs mailing list
eGroupWare-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/egroupware-cvs