6 |
6 |
7 IriSP.SegmentsWidget.prototype.draw = function() { |
7 IriSP.SegmentsWidget.prototype.draw = function() { |
8 |
8 |
9 var annotations = this._serializer._data.annotations; |
9 var annotations = this._serializer._data.annotations; |
10 |
10 |
11 for (i in annotations) { |
11 var i = 0; |
|
12 for (i = 0; i < annotations.length; i++) { |
12 var annotation = annotations[i]; |
13 var annotation = annotations[i]; |
13 console.log(annotation); |
14 |
14 var begin = Math.round((+ annotation.begin) / 1000); |
15 var begin = Math.round((+ annotation.begin) / 1000); |
15 var end = Math.round((+ annotation.end) / 1000); |
16 var end = Math.round((+ annotation.end) / 1000); |
16 var duration = (annotation.end - annotation.begin); |
17 var duration = this._serializer.currentMedia().meta["dc:duration"] / 1000; |
17 var id = annotation.id; |
18 var id = annotation.id; |
18 var startPourcent = IriSP.timeToPourcent(begin, duration); |
19 var startPourcent = IriSP.timeToPourcent(begin, duration); |
19 var endPourcent = IriSP.timeToPourcent(end, duration) - startPourcent; |
20 var endPourcent = IriSP.timeToPourcent(end, duration) - startPourcent; |
20 var divTitle = annotation.content.title.substr(0,55); |
21 var divTitle = annotation.content.title.substr(0,55); |
21 var color = annotation.content.color |
22 var color = annotation.content.color |
22 |
23 |
|
24 |
23 var annotationTemplate = Mustache.to_html(IriSP.annotation_template, |
25 var annotationTemplate = Mustache.to_html(IriSP.annotation_template, |
24 {"divTitle" : divTitle, "id" : id, "startPourcent" : startPourcent, |
26 {"divTitle" : divTitle, "id" : id, "startPourcent" : startPourcent, |
25 "endPourcent" : endPourcent, "hexa_color" : IriSP.DEC_HEXA_COLOR(color), |
27 "endPourcent" : endPourcent, "hexa_color" : IriSP.DEC_HEXA_COLOR(color), |
26 "seekPlace" : Math.round(begin/1000)}); |
28 "seekPlace" : Math.round(begin/1000)}); |
27 |
29 |
|
30 |
28 var toolTipTemplate = Mustache.to_html(IriSP.tooltip_template, |
31 var toolTipTemplate = Mustache.to_html(IriSP.tooltip_template, |
29 {"title" : divTitle, "begin" : begin, "end" : end, |
32 {"title" : divTitle, "begin" : begin, "end" : end, |
30 "description": annotation.content.description}); |
33 "description": annotation.content.description}); |
31 |
34 |
32 |
35 |
33 IriSP.jQuery("<div>" + annotationTemplate + "</div>").appendTo("#Ldt-Annotations"); |
36 IriSP.jQuery(annotationTemplate).appendTo("#Ldt-Annotations"); |
34 // TOOLTIP BUG ! |
37 // TOOLTIP BUG ! |
35 |
38 |
36 IriSP.jQuery("#" + id).tooltip({ effect: 'slide'}); |
39 IriSP.jQuery("#" + id).tooltip({ effect: 'slide'}); |
37 |
40 |
38 IriSP.jQuery("#" + id).fadeTo(0,0.3); |
41 IriSP.jQuery("#" + id).fadeTo(0,0.3); |
|
42 |
39 IriSP.jQuery("#" + id).mouseover(function() { |
43 IriSP.jQuery("#" + id).mouseover(function() { |
40 IriSP.jQuery("#" + id).animate({opacity: 0.6}, 5); |
44 IriSP.jQuery("#" + id).animate({opacity: 0.6}, 5); |
41 }).mouseout(function(){ |
45 }).mouseout(function(){ |
42 IriSP.jQuery("#" + id).animate({opacity: 0.3}, 5); |
46 IriSP.jQuery("#" + id).animate({opacity: 0.3}, 5); |
43 }); |
47 }); |
|
48 |
|
49 IriSP.jQuery("#" + id).click(function(_this, annotation) { |
|
50 return function() { _this.clickHandler(annotation)}; |
|
51 }(this, annotation)); |
44 } |
52 } |
45 }; |
53 }; |
|
54 |
|
55 IriSP.SegmentsWidget.prototype.clickHandler = function(annotation) { |
|
56 var begin = Math.round((+ annotation.begin) / 1000); |
|
57 this._Popcorn.currentTime(begin) |
|
58 } |