# HG changeset patch # User hamidouk # Date 1319198789 -7200 # Node ID eda061f1aa7500ff56bde1a12d5cb6fd5cf99f80 # Parent ebfd0d17e42732fe74c3f247f2c1e03aa5f421bd added a .selector object to all the widgets. diff -r ebfd0d17e427 -r eda061f1aa75 src/js/widgets.js --- a/src/js/widgets.js Fri Oct 21 14:05:59 2011 +0200 +++ b/src/js/widgets.js Fri Oct 21 14:06:29 2011 +0200 @@ -1,9 +1,19 @@ /* the widget classes and definitions */ IriSP.Widget = function(Popcorn, config, Serializer) { + + if (config === undefined || config === null) { + config = {} + } + this._Popcorn = Popcorn; this._config = config; this._serializer = Serializer; + + if (config.hasOwnProperty("divId")) { + this._id = config.divId; + this.selector = IriSP.jQuery("#" + this._id); + } }; IriSP.Widget.prototype.draw = function() { @@ -13,8 +23,3 @@ IriSP.Widget.prototype.redraw = function() { /* implemented by "sub-classes" */ }; - -IriSP.PlayerWidget = function(Popcorn, config, Serializer) { - IriSP.Widget.call(this, Popcorn, config, Serializer); - -}; \ No newline at end of file diff -r ebfd0d17e427 -r eda061f1aa75 unittests/tests/widget.js --- a/unittests/tests/widget.js Fri Oct 21 14:05:59 2011 +0200 +++ b/unittests/tests/widget.js Fri Oct 21 14:06:29 2011 +0200 @@ -10,8 +10,10 @@ ); test("test initialisation", function() { - var wid = new IriSP.Widget(this.Popcorn, {parent: "widget-div"}, this.ser); - deepEqual(wid._config, {parent: "widget-div"}, "Check if the parent div is set correctly"); + var config = {divId: "mydiv"}; + 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"); });