24 return; |
24 return; |
25 } |
25 } |
26 |
26 |
27 /* Setting all the configuration options */ |
27 /* Setting all the configuration options */ |
28 var _type = config.type, |
28 var _type = config.type, |
29 _config = IriSP._.defaults({}, config, player.config.gui.default_options, this.defaults), |
29 _config = IriSP._.defaults({}, config, player.config.default_options, this.defaults), |
30 _this = this; |
30 _this = this; |
31 |
31 |
32 IriSP._(_config).forEach(function(_value, _key) { |
32 IriSP._(_config).forEach(function(_value, _key) { |
33 _this[_key] = _value; |
33 _this[_key] = _value; |
34 }); |
34 }); |
35 |
35 |
36 if (typeof this.width === "undefined") { |
36 if (typeof this.width === "undefined") { |
37 this.width = player.config.gui.width; |
37 this.width = player.config.width; |
38 } |
38 } |
39 |
39 |
40 /* Setting this.player at the end in case it's been overriden |
40 /* Setting this.player at the end in case it's been overriden |
41 * by a configuration option of the same name :-( |
41 * by a configuration option of the same name :-( |
42 */ |
42 */ |
45 /* Getting metadata */ |
45 /* Getting metadata */ |
46 this.source = player.loadMetadata(this.metadata); |
46 this.source = player.loadMetadata(this.metadata); |
47 |
47 |
48 /* Call draw when loaded */ |
48 /* Call draw when loaded */ |
49 this.source.onLoad(function() { |
49 this.source.onLoad(function() { |
|
50 if (_this.media_id) { |
|
51 _this.media = this.getElement(_this.media_id); |
|
52 } else { |
|
53 var _mediaopts = { |
|
54 is_mashup: _this.is_mashup || false |
|
55 } |
|
56 _this.media = this.getCurrentMedia(_mediaopts); |
|
57 } |
|
58 |
50 _this.draw(); |
59 _this.draw(); |
51 }); |
60 }); |
52 |
61 |
53 /* Adding classes and html attributes */ |
62 /* Adding classes and html attributes */ |
54 this.$ = IriSP.jQuery('#' + this.container); |
63 this.$ = IriSP.jQuery('#' + this.container); |
86 if (typeof _function !== "undefined") { |
95 if (typeof _function !== "undefined") { |
87 return function() { |
96 return function() { |
88 return _function.apply(_this, Array.prototype.slice.call(arguments, 0)); |
97 return _function.apply(_this, Array.prototype.slice.call(arguments, 0)); |
89 } |
98 } |
90 } else { |
99 } else { |
91 console.log("Error, Unknown function IriSP." + this.type + "." + _name) |
100 console.log("Error, Unknown function IriSP.Widgets" + this.type + "." + _name) |
92 } |
101 } |
93 } |
102 } |
94 |
103 |
95 IriSP.Widgets.Widget.prototype.bindPopcorn = function(_popcornEvent, _functionName) { |
104 IriSP.Widgets.Widget.prototype.getFunctionOrName = function(_functionOrName) { |
96 this.player.popcorn.listen(_popcornEvent, this.functionWrapper(_functionName)) |
105 switch (typeof _functionOrName) { |
|
106 case "function": |
|
107 return _functionOrName; |
|
108 case "string": |
|
109 return this.functionWrapper(_functionOrName); |
|
110 default: |
|
111 return undefined; |
|
112 } |
|
113 } |
|
114 |
|
115 IriSP.Widgets.Widget.prototype.onMdpEvent = function(_eventName, _functionOrName) { |
|
116 this.player.on(_eventName, this.getFunctionOrName(_functionOrName)); |
|
117 } |
|
118 |
|
119 IriSP.Widgets.Widget.prototype.onMediaEvent = function(_eventName, _functionOrName) { |
|
120 this.media.on(_eventName, this.getFunctionOrName(_functionOrName)); |
97 } |
121 } |
98 |
122 |
99 IriSP.Widgets.Widget.prototype.getWidgetAnnotations = function() { |
123 IriSP.Widgets.Widget.prototype.getWidgetAnnotations = function() { |
100 var _curmedia = this.source.currentMedia; |
124 return typeof this.annotation_type !== "undefined" && this.annotation_type ? this.media.getAnnotationsByTypeTitle(this.annotation_type) : this.media.getAnnotations(); |
101 return typeof this.annotation_type !== "undefined" && this.annotation_type ? _curmedia.getAnnotationsByTypeTitle(this.annotation_type) : _curmedia.getAnnotations(); |
|
102 } |
125 } |
103 |
126 |
104 IriSP.Widgets.Widget.prototype.getWidgetAnnotationsAtTime = function() { |
127 IriSP.Widgets.Widget.prototype.getWidgetAnnotationsAtTime = function() { |
105 var _time = Math.floor(this.player.popcorn.currentTime() * 1000); |
128 var _time = this.media.getCurrentTime(); |
106 return this.getWidgetAnnotations().filter(function(_annotation) { |
129 return this.getWidgetAnnotations().filter(function(_annotation) { |
107 return _annotation.begin <= _time && _annotation.end > _time; |
130 return _annotation.begin <= _time && _annotation.end > _time; |
108 }); |
131 }); |
109 } |
132 } |
110 |
133 |
111 IriSP.Widgets.Widget.prototype.insertSubwidget = function(_selector, _propname, _widgetoptions) { |
134 IriSP.Widgets.Widget.prototype.insertSubwidget = function(_selector, _widgetoptions, _propname) { |
112 var _id = _selector.attr("id"), |
135 var _id = _selector.attr("id"), |
113 _this = this, |
136 _this = this, |
114 _type = _widgetoptions.type, |
137 _type = _widgetoptions.type, |
115 $L = $LAB; |
138 $L = $LAB; |
116 if (typeof _id == "undefined") { |
139 if (typeof _id == "undefined") { |