1 IriSP.AnnotationsWidget = function(Popcorn, config, Serializer) { |
1 define(["IriSP", "widgets", "util"], function() { |
2 IriSP.Widget.call(this, Popcorn, config, Serializer); |
2 IriSP.AnnotationsWidget = function(Popcorn, config, Serializer) { |
3 |
3 IriSP.Widget.call(this, Popcorn, config, Serializer); |
4 }; |
4 |
|
5 }; |
5 |
6 |
6 |
7 |
7 IriSP.AnnotationsWidget.prototype = new IriSP.Widget(); |
8 IriSP.AnnotationsWidget.prototype = new IriSP.Widget(); |
8 |
9 |
9 IriSP.AnnotationsWidget.prototype.clear = function() { |
10 IriSP.AnnotationsWidget.prototype.clear = function() { |
10 this.selector.find(".Ldt-SaTitle").text(""); |
11 this.selector.find(".Ldt-SaTitle").text(""); |
11 this.selector.find(".Ldt-SaDescription").text(""); |
12 this.selector.find(".Ldt-SaDescription").text(""); |
12 this.selector.find(".Ldt-SaKeywordText").text(""); |
13 this.selector.find(".Ldt-SaKeywordText").text(""); |
13 }; |
14 }; |
14 |
15 |
15 IriSP.AnnotationsWidget.prototype.displayAnnotation = function(annotation) { |
16 IriSP.AnnotationsWidget.prototype.displayAnnotation = function(annotation) { |
16 var title = annotation.content.title; |
17 var title = annotation.content.title; |
17 var description = annotation.content.description; |
18 var description = annotation.content.description; |
18 var keywords = "" // FIXME; |
19 var keywords = "" // FIXME; |
19 var begin = +annotation.begin; |
20 var begin = +annotation.begin; |
20 var end = +annotation.end; |
21 var end = +annotation.end; |
21 var duration = +this._serializer.currentMedia().meta["dc:duration"]; |
22 var duration = +this._serializer.currentMedia().meta["dc:duration"]; |
22 |
23 |
23 this.selector.find(".Ldt-SaTitle").text(title); |
24 this.selector.find(".Ldt-SaTitle").text(title); |
24 this.selector.find(".Ldt-SaDescription").text(description); |
25 this.selector.find(".Ldt-SaDescription").text(description); |
25 var startPourcent = parseInt(Math.round((begin*1+(end*1-begin*1)/2) / (duration*1)) / 100); |
26 var startPourcent = parseInt(Math.round((begin*1+(end*1-begin*1)/2) / (duration*1)) / 100); |
26 this.selector.find(".Ldt-Show-Arrow").animate({left:startPourcent+'%'},1000); |
27 this.selector.find(".Ldt-Show-Arrow").animate({left:startPourcent+'%'},1000); |
27 //IriSP.jQuery("#"+annotationTempo.id).animate({alpha:'100%'},1000); |
28 //IriSP.jQuery("#"+annotationTempo.id).animate({alpha:'100%'},1000); |
28 |
29 |
29 }; |
30 }; |
30 |
31 |
31 IriSP.AnnotationsWidget.prototype.clearWidget = function() { |
32 IriSP.AnnotationsWidget.prototype.clearWidget = function() { |
32 /* retract the pane between two annotations */ |
33 /* retract the pane between two annotations */ |
33 this.selector.find(".Ldt-SaTitle").text(""); |
34 this.selector.find(".Ldt-SaTitle").text(""); |
34 this.selector.find(".Ldt-SaDescription").text(""); |
35 this.selector.find(".Ldt-SaDescription").text(""); |
35 this.selector.find(".Ldt-SaKeywordText").html(""); |
36 this.selector.find(".Ldt-SaKeywordText").html(""); |
36 this.selector.find(".Ldt-ShowAnnotation").slideUp(); |
37 this.selector.find(".Ldt-ShowAnnotation").slideUp(); |
37 }; |
38 }; |
38 |
39 |
39 IriSP.AnnotationsWidget.prototype.draw = function() { |
40 IriSP.AnnotationsWidget.prototype.draw = function() { |
40 var _this = this; |
41 var _this = this; |
41 |
42 |
42 var annotationMarkup = Mustache.to_html(IriSP.annotationWidget_template, {"share_template" : IriSP.share_template}); |
43 var annotationMarkup = Mustache.to_html(IriSP.annotationWidget_template, {"share_template" : IriSP.share_template}); |
43 this.selector.append(annotationMarkup); |
44 this.selector.append(annotationMarkup); |
44 |
45 |
45 var annotations = this._serializer._data.annotations; |
46 var annotations = this._serializer._data.annotations; |
46 var i; |
47 var i; |
47 |
48 |
48 for (i in annotations) { |
49 for (i in annotations) { |
49 var annotation = annotations[i]; |
50 var annotation = annotations[i]; |
50 var begin = Math.round((+ annotation.begin) / 1000); |
51 var begin = Math.round((+ annotation.begin) / 1000); |
51 var end = Math.round((+ annotation.end) / 1000); |
52 var end = Math.round((+ annotation.end) / 1000); |
52 |
53 |
53 var conf = {start: begin, end: end, |
54 var conf = {start: begin, end: end, |
54 onStart: |
55 onStart: |
55 function(annotation) { return function() { _this.displayAnnotation(annotation); } }(annotation), |
56 function(annotation) { return function() { _this.displayAnnotation(annotation); } }(annotation), |
56 onEnd: |
57 onEnd: |
57 function() { _this.clearWidget(); }, |
58 function() { _this.clearWidget(); }, |
58 }; |
59 }; |
59 this._Popcorn = this._Popcorn.code(conf); |
60 this._Popcorn = this._Popcorn.code(conf); |
60 } |
61 } |
61 }; |
62 }; |
|
63 }); |