diff --git a/admin/js/app.ts b/admin/js/app.ts index 81dd43c7f2..f685e39c63 100644 --- a/admin/js/app.ts +++ b/admin/js/app.ts @@ -1081,7 +1081,7 @@ class AdminApp extends EgwApp if(egw.app('policy')) { - egw.includeJS(egw.link('/policy/js/app.js'), function() { + import(egw.link('/policy/js/app.js?'+((new Date).valueOf()/86400|0).toString())).then(() => { if(typeof app.policy === 'undefined' || typeof app.policy.confirm === 'undefined') { app.policy = new app.classes.policy(); diff --git a/api/js/jsapi/egw_files.js b/api/js/jsapi/egw_files.js index dd40eceac7..fc9e38b960 100644 --- a/api/js/jsapi/egw_files.js +++ b/api/js/jsapi/egw_files.js @@ -141,11 +141,15 @@ egw.extend('files', egw.MODULE_WND_LOCAL, function(_app, _wnd) /** * Load and execute javascript file(s) in order * + * Deprecated because with egw composition happening in main window the used import statement happens in that context + * and NOT in the window (eg. popup or iframe) this module is instantiated for! + * * @memberOf egw * @param {string|array} _jsFiles (array of) urls to include * @param {function} _callback called after JS files are loaded and executed * @param {object} _context * @param {string} _prefix prefix for _jsFiles + * @deprecated use es6 import statement: Promise.all([].concat(_jsFiles).map((src)=>import(_prefix+src))).then(...) * @return Promise */ includeJS: function(_jsFiles, _callback, _context, _prefix) diff --git a/api/js/jsapi/egw_global.d.ts b/api/js/jsapi/egw_global.d.ts index 7f31c87821..845aade8dd 100644 --- a/api/js/jsapi/egw_global.d.ts +++ b/api/js/jsapi/egw_global.d.ts @@ -853,6 +853,7 @@ declare interface IegwWndLocal extends IegwGlobal * @param {function} _callback called after JS files are loaded and executed * @param {object} _context * @param {string} _prefix prefix for _jsFiles + * @deprecated use es6 import statement: Promise.all([].concat(_jsFiles).map((src)=>import(_prefix+src))).then(...) */ includeJS(_jsFiles : string|string[], _callback? : Function, _context? : object, _prefix? : string); /** diff --git a/api/js/jsapi/egw_jquery.js b/api/js/jsapi/egw_jquery.js deleted file mode 100644 index 2f69b74618..0000000000 --- a/api/js/jsapi/egw_jquery.js +++ /dev/null @@ -1,47 +0,0 @@ -/** - * EGroupware clientside API object - * - * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License - * @package etemplate - * @subpackage api - * @link http://www.egroupware.org - * @author Andreas Stöckel (as AT stylite.de) - * @version $Id$ - */ - -/*egw:uses - egw_core; - egw_files; - egw_ready; -*/ -import './egw_core.js'; - -/** - * NOT USED - * @param {string} _app application name object is instanciated for - * @param {object} _wnd window object is instanciated for - */ -egw.extend('jquery', egw.MODULE_WND_LOCAL, function(_app, _wnd) -{ - "use strict"; - - // Get the reference to the "files" and the "ready" module for the current - // window - var files = this.module('files', _wnd); - var ready = this.module('ready', _wnd); - - // Include the jQuery and jQuery UI library. - var token = ready.readyWaitFor(); - files.includeJS([ - this.webserverUrl + '/vendor/bower-asset/jquery/dist/jquery.min.js', - this.webserverUrl + '/vendor/bower-asset/jquery-ui/jquery-ui.js', - this.webserverUrl + '/api/js/jquery/jquery.html5_upload.js' - ], function () { - this.constant('jquery', 'jQuery', _wnd.jQuery, _wnd); - ready.readyDone(token); - }, this); - - return { - 'jQuery': null - }; -}); diff --git a/api/js/jsapi/egw_json.js b/api/js/jsapi/egw_json.js index 71286d6e42..de238e99ef 100644 --- a/api/js/jsapi/egw_json.js +++ b/api/js/jsapi/egw_json.js @@ -538,7 +538,7 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd) // check if we need a not yet included app.js object --> include it now and return a Promise else if (i == 1 && parts[0] == 'app' && typeof app.classes[parts[1]] === 'undefined') { - return this.includeJS('/'+parts[1]+'/js/app.js?'+((new Date).valueOf()/86400|0).toString(), undefined, undefined, this.webserverUrl) + return import(this.webserverUrl+'/'+parts[1]+'/js/app.js?'+((new Date).valueOf()/86400|0).toString()) .then(() => this.applyFunc(_func, args, _context), (err) => {console.error("Failure loading /"+parts[1]+'/js/app.js' + " (" + err + ")\nAborting.")}); } @@ -793,15 +793,8 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd) json.registerJSONPlugin(function(type, res, req) { if (typeof res.data == 'string') { - req.jsCount++; - req.egw.includeJS(res.data, function() { - req.jsFiles++; - if (req.jsFiles == req.jsCount && req.onLoadFinish) - { - req.onLoadFinish.call(req.sender); - } - }); - return true; + return Promise.all(res.data.map((src) => import(src))) + .then(() => req.onLoadFinish.call(req.sender)); } throw 'Invalid parameters'; }, null, 'js'); diff --git a/api/js/jsapi/egw_lang.js b/api/js/jsapi/egw_lang.js index 8b544b2647..51a9e556c5 100644 --- a/api/js/jsapi/egw_lang.js +++ b/api/js/jsapi/egw_lang.js @@ -161,7 +161,7 @@ egw.extend('lang', egw.MODULE_GLOBAL, function() this.lang_order = apps.reverse(); } - const promise = files.includeJS(jss, _callback, _context || null); + const promise = Promise.all(jss.map((src) => import(src))); return typeof _callback === 'function' ? promise.then(_callback.call(_context)) : promise; } }; diff --git a/api/js/jsapi/egw_modules.js b/api/js/jsapi/egw_modules.js index de0a689479..d588359e29 100644 --- a/api/js/jsapi/egw_modules.js +++ b/api/js/jsapi/egw_modules.js @@ -4,7 +4,6 @@ */ import "../../../vendor/bower-asset/jquery/dist/jquery.min.js"; -//import "../../../vendor/bower-asset/jquery-ui/jquery-ui.js"; import "../jquery/jquery.noconflict.js"; import "./egw.js"; diff --git a/infolog/js/app.ts b/infolog/js/app.ts index e67ae295c5..6694fea546 100644 --- a/infolog/js/app.ts +++ b/infolog/js/app.ts @@ -778,7 +778,7 @@ class InfologApp extends EgwApp if (!app.stylite) { - this.egw.includeJS('/stylite/js/app.js', undefined, undefined, egw.webserverUrl).then(() => + import(egw.webserverUrl+'/stylite/js/app.js?'+((new Date).valueOf()/86400|0).toString()).then(() => { app.stylite = new app.classes.stylite; app.stylite.et2 = this.et2; diff --git a/tsconfig.json b/tsconfig.json index 44f5234adf..c9cd29e29f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "compileOnSave": true, "compilerOptions": { "target": "es2015", - "module": "ES2015", + "module": "ES2020", "lib": ["es2020","dom"], "outDir": "", "rootDir": "./",