mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 06:30:59 +01:00
deprecated egw.includeJS() in favor of es6 import statement
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!
This commit is contained in:
parent
4f95ebb510
commit
a5ad691757
@ -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();
|
||||
|
@ -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)
|
||||
|
1
api/js/jsapi/egw_global.d.ts
vendored
1
api/js/jsapi/egw_global.d.ts
vendored
@ -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);
|
||||
/**
|
||||
|
@ -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
|
||||
};
|
||||
});
|
@ -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');
|
||||
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
@ -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";
|
||||
|
@ -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;
|
||||
|
@ -2,7 +2,7 @@
|
||||
"compileOnSave": true,
|
||||
"compilerOptions": {
|
||||
"target": "es2015",
|
||||
"module": "ES2015",
|
||||
"module": "ES2020",
|
||||
"lib": ["es2020","dom"],
|
||||
"outDir": "",
|
||||
"rootDir": "./",
|
||||
|
Loading…
Reference in New Issue
Block a user