added a .selector object to all the widgets.
--- 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
--- 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");
});