From 5531844c0d8eb6ef1b8199c91ecb0f7e1d4dcf2d Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 15 Jan 2019 14:34:52 +0100 Subject: [PATCH] use correct window of includeJS and alert, also fixed in wrong order included first JS file --- api/js/jsapi/egw_files.js | 3 +++ api/js/jsapi/egw_json.js | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/api/js/jsapi/egw_files.js b/api/js/jsapi/egw_files.js index 4c83c8bcb6..78cb64767b 100644 --- a/api/js/jsapi/egw_files.js +++ b/api/js/jsapi/egw_files.js @@ -149,6 +149,9 @@ egw.extend('files', egw.MODULE_WND_LOCAL, function(_app, _wnd) */ includeJS: function(_jsFiles, _callback, _context, _prefix) { + // use egw_LAB object of correct window, not always the main window + var egw_LAB = (this.window || window).egw_LAB; + // Also allow including a single javascript file if (typeof _jsFiles === 'string') { diff --git a/api/js/jsapi/egw_json.js b/api/js/jsapi/egw_json.js index 64f2247b59..3842955b8a 100644 --- a/api/js/jsapi/egw_json.js +++ b/api/js/jsapi/egw_json.js @@ -84,7 +84,8 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd) // Function which is currently used to display alerts -- may be replaced by // some API function. this.alertHandler = function(_message, _details) { - alert(_message); + // we need to use the alert function of the window of the request, not just the main window + (this.egw ? this.egw.window : window).alert(_message); if (_details) { @@ -175,7 +176,7 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd) } // Load files first var js_files = []; - for (var i = data.response.length - 1; i > 0; --i) + for (var i = data.response.length - 1; i >= 0; --i) { var res = data.response[i]; if(res.type == 'js' && typeof res.data == 'string')