# HG changeset patch # User hamidouk # Date 1319452935 -7200 # Node ID 2758dfb208b23056436d352c54c6b8581243d251 # Parent 58bb8ccea9a8b36e63d3dc906ed17b85113b4c66 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. diff -r 58bb8ccea9a8 -r 2758dfb208b2 src/js/widgets.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() { diff -r 58bb8ccea9a8 -r 2758dfb208b2 unittests/tests/widget.js --- 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");