diff --git a/api/js/jsapi/egw.js b/api/js/jsapi/egw.js index 86951e5d54..76984ad4f3 100644 --- a/api/js/jsapi/egw.js +++ b/api/js/jsapi/egw.js @@ -471,14 +471,12 @@ var exports = {}; /** * Call a function specified by it's name (possibly dot separated, eg. "app.myapp.myfunc") * - * @param {string} _func dot-separated function name + * @param {string|Function} _func dot-separated function name * @param {mixed} ...args variable number of arguments * @returns {Mixed|Promise} - * @deprecated use egw.call(_func, ...) or egw.apply(_func, args) + * @deprecated use egw.callFunc(_func, ...) or egw.applyFunc(_func, args) */ function et2_call(_func) { - let args = [].slice.call(arguments); // convert arguments to array - let func = args.shift(); - return egw.apply(func, args, window); + return egw.applyFunc(_func, [].slice.call(arguments, 1), this); } diff --git a/api/js/jsapi/egw_global.d.ts b/api/js/jsapi/egw_global.d.ts index 7a3ec78573..e565e57a67 100644 --- a/api/js/jsapi/egw_global.d.ts +++ b/api/js/jsapi/egw_global.d.ts @@ -795,20 +795,20 @@ declare interface IegwWndLocal extends IegwGlobal /** * Call a function specified by it's name (possibly dot separated, eg. "app.myapp.myfunc") * - * @param {string} _func dot-separated function name + * @param {string|Function} _func dot-separated function name or function * @param {mixed} ...args variable number of arguments * @returns {mixed|Promise} */ - call(_func : string|Function, ...args : any) : Promise|any + callFunc(_func : string|Function, ...args : any) : Promise|any /** * Call a function specified by it's name (possibly dot separated, eg. "app.myapp.myfunc") * - * @param {string} _func dot-separated function name + * @param {string|Function} _func dot-separated function name or function * @param {array} args arguments * @param {object} _context * @returns {mixed|Promise} */ - apply(_func : string|Function, args : Array, _context : Object) : Promise|any + applyFunc(_func : string|Function, args : Array, _context : Object) : Promise|any /** * Registers a new handler plugin. diff --git a/api/js/jsapi/egw_json.js b/api/js/jsapi/egw_json.js index 2a7e441b08..ff13ade1b3 100644 --- a/api/js/jsapi/egw_json.js +++ b/api/js/jsapi/egw_json.js @@ -484,30 +484,27 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd) /** * Call a function specified by it's name (possibly dot separated, eg. "app.myapp.myfunc") * - * @param {string} _func dot-separated function name + * @param {string|Function} _func dot-separated function name or function * @param {mixed} ...args variable number of arguments * @returns {mixed|Promise} */ - call: function(_func) + callFunc: function(_func) { - let args = [].slice.call(arguments); // convert arguments to array - let func = args.shift(); - - return this.apply(func, args); + return this.applyFunc(_func, [].slice.call(arguments, 1)); }, /** * Call a function specified by it's name (possibly dot separated, eg. "app.myapp.myfunc") * - * @param {string} _func dot-separated function name + * @param {string|Function} _func dot-separated function name or function * @param {array} args arguments * @param {object} _context * @returns {mixed|Promise} */ - apply: function(_func, args, _context) + applyFunc: function(_func, args, _context) { let parent = _context || window; - let func; + let func = _func; if (typeof _func === 'string') { @@ -713,7 +710,7 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd) json.registerJSONPlugin(function(type, res, req) { if (typeof res.data.func == 'string') { - req.egw.apply(res.data.func, res.data.parms, req.egw.window); + req.egw.applyFunc(res.data.func, res.data.parms, req.egw.window); return true; } throw 'Invalid parameters';