Introduce widget class
Change-Id: I949cd46c48b9176c0b013c1c65f1fba949413c8e
diff --git a/dev/js/src/plugin/widget.js b/dev/js/src/plugin/widget.js
new file mode 100644
index 0000000..4c2f09c
--- /dev/null
+++ b/dev/js/src/plugin/widget.js
@@ -0,0 +1,54 @@
+/**
+ * The plugin system is based
+ * on registered widgets (iframes) from
+ * foreign services.
+ * The widget component represents a single iframe.
+ *
+ * @author Nils Diewald
+ */
+
+define(["util"], function () {
+ "use strict";
+
+ return {
+
+ /**
+ * Create new widget
+ */
+ create : function (src, id) {
+ return Object.create(this)._init(src, id);
+ },
+
+ _init : function (src, id) {
+ this.src = src;
+ this.id = id;
+ return this;
+ },
+
+ /**
+ * The element of the widget
+ */
+ element : function () {
+
+ if (this._element)
+ return this._element;
+
+ // Spawn new iframe
+ var i = document.createElement('iframe');
+ i.setAttribute('allowTransparency',"true");
+ i.setAttribute('frameborder', 0);
+ i.setAttribute('sandbox','allow-scripts');
+ i.classList.add('widget');
+ i.setAttribute('name', this.id);
+ i.setAttribute('src', this.src);
+ this._element = i;
+
+ return i;
+ },
+
+ // Resize iframe
+ resize : function (data) {
+ this._element.style.height = data.height + 'px';
+ }
+ }
+});