15 * @param config - configuration options for the widget |
15 * @param config - configuration options for the widget |
16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 IriSP.Widgets.Widget = function(player, config) { |
19 IriSP.Widgets.Widget = function(player, config) { |
20 |
20 |
21 if( typeof player === "undefined") { |
21 if( typeof player === "undefined") { |
22 /* Probably an abstract call of the class when |
22 /* Probably an abstract call of the class when |
23 * individual widgets set their prototype */ |
23 * individual widgets set their prototype */ |
24 return; |
24 return; |
25 } |
25 } |
|
26 |
|
27 this.__subwidgets = []; |
26 |
28 |
27 /* Setting all the configuration options */ |
29 /* Setting all the configuration options */ |
28 var _type = config.type, |
30 var _type = config.type, |
29 _config = IriSP._.defaults({}, config, player.config.default_options, this.defaults), |
31 _config = IriSP._.defaults({}, config, player.config.default_options, this.defaults), |
30 _this = this; |
32 _this = this; |
55 } |
57 } |
56 _this.media = this.getCurrentMedia(_mediaopts); |
58 _this.media = this.getCurrentMedia(_mediaopts); |
57 } |
59 } |
58 |
60 |
59 _this.draw(); |
61 _this.draw(); |
|
62 player.trigger("widget-loaded"); |
60 }); |
63 }); |
61 |
64 |
62 /* Adding classes and html attributes */ |
65 /* Adding classes and html attributes */ |
63 this.$ = IriSP.jQuery('#' + this.container); |
66 this.$ = IriSP.jQuery('#' + this.container); |
64 this.$.addClass("Ldt-TraceMe Ldt-Widget").attr("widget-type", _type); |
67 this.$.addClass("Ldt-TraceMe Ldt-Widget").attr("widget-type", _type); |
135 return this.getWidgetAnnotations().filter(function(_annotation) { |
138 return this.getWidgetAnnotations().filter(function(_annotation) { |
136 return _annotation.begin <= _time && _annotation.end > _time; |
139 return _annotation.begin <= _time && _annotation.end > _time; |
137 }); |
140 }); |
138 } |
141 } |
139 |
142 |
|
143 IriSP.Widgets.Widget.prototype.isLoaded = function() { |
|
144 var isloaded = !IriSP._(this.__subwidgets).any(function(w) { |
|
145 return !(w && w.isLoaded()); |
|
146 }); |
|
147 return isloaded; |
|
148 } |
|
149 |
140 IriSP.Widgets.Widget.prototype.insertSubwidget = function(_selector, _widgetoptions, _propname) { |
150 IriSP.Widgets.Widget.prototype.insertSubwidget = function(_selector, _widgetoptions, _propname) { |
141 var _id = _selector.attr("id"), |
151 var _id = _selector.attr("id"), |
142 _this = this, |
152 _this = this, |
143 _type = _widgetoptions.type, |
153 _type = _widgetoptions.type, |
144 $L = $LAB; |
154 $L = $LAB, |
|
155 key = this.__subwidgets.length; |
|
156 this.__subwidgets.push(null); |
145 if (typeof _id == "undefined") { |
157 if (typeof _id == "undefined") { |
146 _id = IriSP._.uniqueId(this.container + '_sub_widget_' + _widgetoptions.type); |
158 _id = IriSP._.uniqueId(this.container + '_sub_widget_' + _widgetoptions.type); |
147 _selector.attr("id", _id); |
159 _selector.attr("id", _id); |
148 } |
160 } |
149 _widgetoptions.container = _id; |
161 _widgetoptions.container = _id; |