blob: c1d29e8995a13066237b306ad4514cdbbc15c01a [file] [log] [blame]
Akron22598cd2019-12-09 14:59:03 +01001define(function () {
2 "use strict";
3 return {
4 create : function (name, src, id) {
5 return Object.create(this)._init(name, src, id);
6 },
7
8 // Initialize service
9 _init : function (name, src, id) {
10 if (!name || !src || !id)
11 throw Error("Service not well defined");
12 this.name = name;
13 this.src = src;
14 this.id = id;
15
16 // There is no close method defined yet
17 if (!this.close) {
18 this.close = function () {
19 this._closeIframe();
20 }
21 }
22
23 return this;
24 },
25
26 /**
27 * The element of the service as embedded in the panel
28 */
29 load : function () {
30 if (this._load)
31 return this._load;
32
33 // Spawn new iframe
34 let e = document.createElement('iframe');
35 e.setAttribute('allowTransparency',"true");
36 e.setAttribute('frameborder', 0);
hebasta78913242020-03-30 13:39:20 +020037 // Allow forms in Plugins
38 e.setAttribute('sandbox','allow-scripts allow-forms');
Akron22598cd2019-12-09 14:59:03 +010039 e.style.height = '0px';
40 e.setAttribute('name', this.id);
41 e.setAttribute('src', this.src);
42
43 this._load = e;
44 return e;
45 },
46
47 // onClose : function () {},
48
49 /**
50 * Close the service iframe.
51 */
52 _closeIframe : function () {
53 var e = this._load;
54 if (e && e.parentNode) {
55 e.parentNode.removeChild(e);
56 };
57 this._load = null;
58 }
59 };
60});