changed widget.js to add some properties to the widget. Widgets now only get the popcorn-port
authorhamidouk
Mon, 24 Oct 2011 12:42:15 +0200
branchpopcorn-port
changeset 124 2758dfb208b2
parent 123 58bb8ccea9a8
child 125 960ce0b9f9f0
changed widget.js to add some properties to the widget. Widgets now only get the gui options as a parameter instead of the whole configuration.
src/js/widgets.js
unittests/tests/widget.js
--- a/src/js/widgets.js	Fri Oct 21 17:27:04 2011 +0200
+++ b/src/js/widgets.js	Mon Oct 24 12:42:15 2011 +0200
@@ -10,10 +10,22 @@
   this._config = config;  
   this._serializer = Serializer;
   
-  if (config.hasOwnProperty("gui") && config.gui.hasOwnProperty("container")) {
-     this._id = config.gui.container;
+  if (config.hasOwnProperty("container")) {
+     this._id = config.container;
      this.selector = IriSP.jQuery("#" + this._id);
-  }  
+  }
+
+  if (config.hasOwnProperty("width")) {
+     // this.width and not this._width because we consider it public.
+     this.width = config.width;     
+  }
+  
+  if (config.hasOwnProperty("height")) {
+     // this.width and not this._width because we consider it public.
+     this.height = config.height;     
+  }
+  
+  
 };
 
 IriSP.Widget.prototype.draw = function() {
--- a/unittests/tests/widget.js	Fri Oct 21 17:27:04 2011 +0200
+++ b/unittests/tests/widget.js	Mon Oct 24 12:42:15 2011 +0200
@@ -10,7 +10,7 @@
   );
   
   test("test initialisation", function() {
-    var config = { gui : { container: "mydiv"} };
+    var config = { container: "mydiv", width: 640, height: 480};
     var wid = new IriSP.Widget(this.Popcorn, config, this.ser);
     deepEqual(wid._config, config, "Check if the parent div is set correctly");
     ok(wid.selector, "Check if the jquery selector is set");