blob: cb4a33d51d7412727188722814fdbb09e6d28497 [file] [log] [blame]
Akrona6c32b92018-07-02 18:39:42 +02001/**
2 * The plugin system is based
3 * on registered widgets (iframes) from
4 * foreign services.
5 * The widget component represents a single iframe.
6 *
7 * @author Nils Diewald
8 */
9
10define(["util"], function () {
11 "use strict";
12
13 return {
14
15 /**
16 * Create new widget
17 */
18 create : function (src, id) {
19 return Object.create(this)._init(src, id);
20 },
21
22 _init : function (src, id) {
23 this.src = src;
24 this.id = id;
25 return this;
26 },
27
28 /**
29 * The element of the widget
30 */
31 element : function () {
32
33 if (this._element)
34 return this._element;
35
36 // Spawn new iframe
37 var i = document.createElement('iframe');
38 i.setAttribute('allowTransparency',"true");
39 i.setAttribute('frameborder', 0);
40 i.setAttribute('sandbox','allow-scripts');
41 i.classList.add('widget');
42 i.setAttribute('name', this.id);
43 i.setAttribute('src', this.src);
44 this._element = i;
45
46 return i;
47 },
48
49 // Resize iframe
50 resize : function (data) {
51 this._element.style.height = data.height + 'px';
Akrona99315e2018-07-03 22:56:45 +020052 },
53
54 // Shutdown suspicious iframe
55 shutdown : function () {
56 KorAP.log(0, 'Suspicious action from ' + this.src);
57 this._element.parentNode.removeChild(this._element);
Akrona6c32b92018-07-02 18:39:42 +020058 }
59 }
60});