mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-08-17 12:01:20 +02:00
Convert et2_widget_script to TS
This commit is contained in:
@ -1,3 +1,4 @@
|
|||||||
|
"use strict";
|
||||||
/**
|
/**
|
||||||
* EGroupware eTemplate2 - JS widget class containing javascript
|
* EGroupware eTemplate2 - JS widget class containing javascript
|
||||||
*
|
*
|
||||||
@ -6,14 +7,26 @@
|
|||||||
* @subpackage api
|
* @subpackage api
|
||||||
* @link http://www.egroupware.org
|
* @link http://www.egroupware.org
|
||||||
* @author Ralf Becker
|
* @author Ralf Becker
|
||||||
* @copyright Stylite 2015
|
|
||||||
* @version $Id$
|
|
||||||
*/
|
*/
|
||||||
|
var __extends = (this && this.__extends) || (function () {
|
||||||
|
var extendStatics = function (d, b) {
|
||||||
|
extendStatics = Object.setPrototypeOf ||
|
||||||
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||||
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||||
|
return extendStatics(d, b);
|
||||||
|
};
|
||||||
|
return function (d, b) {
|
||||||
|
extendStatics(d, b);
|
||||||
|
function __() { this.constructor = d; }
|
||||||
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
/*egw:uses
|
/*egw:uses
|
||||||
et2_core_widget;
|
et2_core_widget;
|
||||||
*/
|
*/
|
||||||
|
var et2_core_widget_1 = require("./et2_core_widget");
|
||||||
|
var et2_core_widget_2 = require("./et2_core_widget");
|
||||||
/**
|
/**
|
||||||
* Function which executes the encapsulated script data.
|
* Function which executes the encapsulated script data.
|
||||||
*
|
*
|
||||||
@ -31,37 +44,30 @@
|
|||||||
*
|
*
|
||||||
* @augments et2_widget
|
* @augments et2_widget
|
||||||
*/
|
*/
|
||||||
var et2_script = (function(){ "use strict"; return et2_widget.extend(
|
var et2_script = /** @class */ (function (_super) {
|
||||||
{
|
__extends(et2_script, _super);
|
||||||
/**
|
function et2_script(_parent, _attrs, _child) {
|
||||||
* Constructor
|
var _this = _super.call(this) || this;
|
||||||
*
|
|
||||||
* @memberOf et2_script
|
|
||||||
*/
|
|
||||||
init: function()
|
|
||||||
{
|
|
||||||
this._super.apply(this, arguments);
|
|
||||||
|
|
||||||
// Allow no child widgets
|
// Allow no child widgets
|
||||||
this.supportedWidgetClasses = [];
|
_this.supportedWidgetClasses = [];
|
||||||
},
|
return _this;
|
||||||
|
}
|
||||||
|
;
|
||||||
/**
|
/**
|
||||||
* We can NOT create a script tag containing the content, as this violoates our CSP policy!
|
* We can NOT create a script tag containing the content, as this violoates our CSP policy!
|
||||||
*
|
*
|
||||||
* @param {string} _content
|
* @param {string} _content
|
||||||
*/
|
*/
|
||||||
loadContent: function(_content)
|
et2_script.prototype.loadContent = function (_content) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
var func = new Function(_content);
|
var func = new Function(_content);
|
||||||
func.call(window);
|
func.call(window);
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e) {
|
||||||
{
|
|
||||||
this.egw.debug('error', 'Error while executing script: ', _content, e);
|
this.egw.debug('error', 'Error while executing script: ', _content, e);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
});}).call(this);
|
return et2_script;
|
||||||
et2_register_widget(et2_script, ["script"]);
|
}(et2_core_widget_2.et2_widget));
|
||||||
|
et2_core_widget_1.et2_register_widget(et2_script, ["script"]);
|
||||||
|
//# sourceMappingURL=et2_widget_script.js.map
|
63
api/js/etemplate/et2_widget_script.ts
Normal file
63
api/js/etemplate/et2_widget_script.ts
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/**
|
||||||
|
* EGroupware eTemplate2 - JS widget class containing javascript
|
||||||
|
*
|
||||||
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||||
|
* @package etemplate
|
||||||
|
* @subpackage api
|
||||||
|
* @link http://www.egroupware.org
|
||||||
|
* @author Ralf Becker
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*egw:uses
|
||||||
|
et2_core_widget;
|
||||||
|
*/
|
||||||
|
|
||||||
|
import {et2_register_widget, WidgetConfig} from "./et2_core_widget";
|
||||||
|
import {et2_widget} from "./et2_core_widget";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function which executes the encapsulated script data.
|
||||||
|
*
|
||||||
|
* This should only be used for customization and NOT for regular EGroupware code!
|
||||||
|
*
|
||||||
|
* We can NOT create a script tag containing the content, as this violoates our CSP policy!
|
||||||
|
*
|
||||||
|
* We use new Function(_content) instead. Therefore you have to use window to address global context:
|
||||||
|
*
|
||||||
|
* window.some_func = function() {...}
|
||||||
|
*
|
||||||
|
* instead of not working
|
||||||
|
*
|
||||||
|
* function some_funct() {...}
|
||||||
|
*
|
||||||
|
* @augments et2_widget
|
||||||
|
*/
|
||||||
|
class et2_script extends et2_widget
|
||||||
|
{
|
||||||
|
constructor(_parent?, _attrs? : WidgetConfig, _child? : object)
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
// Allow no child widgets
|
||||||
|
this.supportedWidgetClasses = [];
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We can NOT create a script tag containing the content, as this violoates our CSP policy!
|
||||||
|
*
|
||||||
|
* @param {string} _content
|
||||||
|
*/
|
||||||
|
loadContent(_content)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var func = new Function(_content);
|
||||||
|
func.call(window);
|
||||||
|
}
|
||||||
|
catch (e)
|
||||||
|
{
|
||||||
|
this.egw.debug('error', 'Error while executing script: ',_content,e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
et2_register_widget(et2_script, ["script"]);
|
||||||
|
|
Reference in New Issue
Block a user