49 } |
49 } |
50 |
50 |
51 IriSP.Widgets.Annotation.prototype.draw = function() { |
51 IriSP.Widgets.Annotation.prototype.draw = function() { |
52 this.renderTemplate(); |
52 this.renderTemplate(); |
53 this.insertSubwidget(this.$.find(".Ldt-Annotation-Social"), "socialWidget", { type: "Social" }); |
53 this.insertSubwidget(this.$.find(".Ldt-Annotation-Social"), "socialWidget", { type: "Social" }); |
54 this.bindPopcorn("timeupdate","onTimeupdate"); |
54 this.onMediaEvent("timeupdate","onTimeupdate"); |
55 this.bindPopcorn("IriSP.Annotation.hide","hide"); |
55 this.onMdpEvent("Annotation.hide","hide"); |
56 this.bindPopcorn("IriSP.Annotation.show","show"); |
56 this.onMdpEvent("Annotation.show","show"); |
57 this.bindPopcorn("IriSP.Annotation.minimize","minimize"); |
57 this.onMdpEvent("Annotation.minimize","minimize"); |
58 this.bindPopcorn("IriSP.Annotation.maximize","maximize"); |
58 this.onMdpEvent("Annotation.maximize","maximize"); |
59 this.bindPopcorn("IriSP.Annotation.getBounds","sendBounds"); |
59 this.onMdpEvent("Annotation.getBounds","sendBounds"); |
60 this.$.find(".Ldt-Annotation-MaxMinButton").click(this.functionWrapper("toggleSize")); |
60 this.$.find(".Ldt-Annotation-MaxMinButton").click(this.functionWrapper("toggleSize")); |
61 this.onTimeupdate(); |
61 this.onTimeupdate(); |
62 } |
62 } |
63 |
63 |
64 IriSP.Widgets.Annotation.prototype.onTimeupdate = function() { |
64 IriSP.Widgets.Annotation.prototype.onTimeupdate = function(_time) { |
65 var _time = Math.floor(this.player.popcorn.currentTime() * 1000), |
65 var _list = this.getWidgetAnnotationsAtTime(); |
66 _list = this.getWidgetAnnotationsAtTime(); |
|
67 if (_list.length) { |
66 if (_list.length) { |
68 if (_list[0].id !== this.lastAnnotation) { |
67 if (_list[0].id !== this.lastAnnotation) { |
69 this.drawAnnotation(_list[0]); |
68 this.drawAnnotation(_list[0]); |
70 this.bounds = [ _list[0].begin.valueOf(), _list[0].end.valueOf() ]; |
69 this.bounds = [ _list[0].begin.valueOf(), _list[0].end.valueOf() ]; |
71 } |
70 } |
72 this.player.popcorn.trigger("IriSP.Arrow.updatePosition",{widget: this.type, time: ( _list[0].begin + _list[0].end ) / 2}); |
71 this.player.trigger("Arrow.updatePosition",{widget: this.type, time: ( _list[0].begin + _list[0].end ) / 2}); |
73 } |
72 } |
74 else { |
73 else { |
75 this.lastAnnotation = false; |
74 this.lastAnnotation = false; |
76 this.$.find(".Ldt-Annotation-Inner").addClass("Ldt-Annotation-Empty"); |
75 this.$.find(".Ldt-Annotation-Inner").addClass("Ldt-Annotation-Empty"); |
77 this.player.popcorn.trigger("IriSP.Arrow.updatePosition",{widget: this.type, time: _time}); |
76 this.player.trigger("Arrow.updatePosition",{widget: this.type, time: _time}); |
78 this.bounds = [ _time, _time ]; |
77 this.bounds = [ _time, _time ]; |
79 } |
78 } |
80 this.sendBounds(); |
79 this.sendBounds(); |
81 } |
80 } |
82 |
81 |
83 IriSP.Widgets.Annotation.prototype.sendBounds = function() { |
82 IriSP.Widgets.Annotation.prototype.sendBounds = function() { |
84 this.player.popcorn.trigger("IriSP.Annotation.boundsChanged",this.bounds); |
83 this.player.trigger("Annotation.boundsChanged",this.bounds); |
85 } |
84 } |
86 |
85 |
87 IriSP.Widgets.Annotation.prototype.drawAnnotation = function(_annotation) { |
86 IriSP.Widgets.Annotation.prototype.drawAnnotation = function(_annotation) { |
88 this.lastAnnotation = _annotation.id; |
87 this.lastAnnotation = _annotation.id; |
89 var _url = (typeof _annotation.url !== "undefined" |
88 var _url = (typeof _annotation.url !== "undefined" |