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