| author | hamidouk |
| Wed, 26 Oct 2011 12:40:24 +0200 | |
| branch | popcorn-port |
| changeset 148 | 5e877acd85ca |
| parent 139 | ba2b3c15bd47 |
| child 152 | 5950ab2855a8 |
| permissions | -rw-r--r-- |
| 100 | 1 |
IriSP.SegmentsWidget = function(Popcorn, config, Serializer) { |
2 |
IriSP.Widget.call(this, Popcorn, config, Serializer); |
|
3 |
}; |
|
4 |
||
| 139 | 5 |
IriSP.SegmentsWidget.prototype = new IriSP.Widget(); |
| 100 | 6 |
|
7 |
IriSP.SegmentsWidget.prototype.draw = function() { |
|
8 |
||
| 148 | 9 |
var self = this; |
| 100 | 10 |
var annotations = this._serializer._data.annotations; |
11 |
|
|
| 104 | 12 |
var i = 0; |
13 |
for (i = 0; i < annotations.length; i++) { |
|
| 100 | 14 |
var annotation = annotations[i]; |
| 104 | 15 |
|
| 100 | 16 |
var begin = Math.round((+ annotation.begin) / 1000); |
17 |
var end = Math.round((+ annotation.end) / 1000); |
|
| 104 | 18 |
var duration = this._serializer.currentMedia().meta["dc:duration"] / 1000; |
| 100 | 19 |
var id = annotation.id; |
20 |
var startPourcent = IriSP.timeToPourcent(begin, duration); |
|
21 |
var endPourcent = IriSP.timeToPourcent(end, duration) - startPourcent; |
|
22 |
var divTitle = annotation.content.title.substr(0,55); |
|
23 |
var color = annotation.content.color |
|
| 104 | 24 |
|
25 |
|
|
| 100 | 26 |
var annotationTemplate = Mustache.to_html(IriSP.annotation_template, |
27 |
{"divTitle" : divTitle, "id" : id, "startPourcent" : startPourcent, |
|
28 |
"endPourcent" : endPourcent, "hexa_color" : IriSP.DEC_HEXA_COLOR(color), |
|
29 |
"seekPlace" : Math.round(begin/1000)}); |
|
30 |
|
|
| 104 | 31 |
|
| 100 | 32 |
var toolTipTemplate = Mustache.to_html(IriSP.tooltip_template, |
33 |
{"title" : divTitle, "begin" : begin, "end" : end, |
|
34 |
"description": annotation.content.description}); |
|
35 |
|
|
|
121
607f481ef4c3
some refactoring to use this.selector instead of directly using jquery.
hamidouk
parents:
108
diff
changeset
|
36 |
IriSP.jQuery("#Ldt-Annotations").append(annotationTemplate); |
| 100 | 37 |
|
38 |
IriSP.jQuery("#" + id).tooltip({ effect: 'slide'}); |
|
39 |
|
|
40 |
IriSP.jQuery("#" + id).fadeTo(0,0.3); |
|
| 104 | 41 |
|
| 100 | 42 |
IriSP.jQuery("#" + id).mouseover(function() { |
43 |
IriSP.jQuery("#" + id).animate({opacity: 0.6}, 5); |
|
44 |
}).mouseout(function(){ |
|
45 |
IriSP.jQuery("#" + id).animate({opacity: 0.3}, 5); |
|
| 104 | 46 |
}); |
47 |
|
|
48 |
IriSP.jQuery("#" + id).click(function(_this, annotation) { |
|
49 |
return function() { _this.clickHandler(annotation)}; |
|
50 |
}(this, annotation)); |
|
| 126 | 51 |
|
52 |
// also add an handler to move the arrow. |
|
53 |
// FIXME: make it work - the arrow swings wildly atm. |
|
54 |
var middle = IriSP.timeToPourcent(begin + (end - begin)/ 2, duration); |
|
55 |
var arrow_div_width = IriSP.jQuery("#Ldt-Show-Arrow").width(); |
|
56 |
|
|
57 |
var real_middle = middle - (middle * (1 - this.width/arrow_div_width)); |
|
58 |
var conf = {start: begin, end: end, |
|
59 |
onStart: |
|
60 |
function(middle) { |
|
61 |
return function() { |
|
62 |
IriSP.jQuery("#Ldt-Show-Arrow").animate({left: real_middle + '%'}, 1000); }}(middle) |
|
63 |
}; |
|
64 |
this._Popcorn = this._Popcorn.code(conf); |
|
| 100 | 65 |
} |
| 148 | 66 |
|
67 |
this._Popcorn.listen("IriSP.search", function(searchWord) { self.searchHandler.call(self, searchWord); }); |
|
| 104 | 68 |
}; |
69 |
||
70 |
IriSP.SegmentsWidget.prototype.clickHandler = function(annotation) { |
|
71 |
var begin = Math.round((+ annotation.begin) / 1000); |
|
72 |
this._Popcorn.currentTime(begin) |
|
|
108
62da43e72e30
broke the serializers across multiple files. added a newline to the end of
hamidouk
parents:
104
diff
changeset
|
73 |
}; |
| 148 | 74 |
|
75 |
IriSP.SegmentsWidget.prototype.searchHandler = function(searchWord) { |
|
76 |
console.log("received" + searchWord); |
|
77 |
}; |