| author | hamidouk |
| Wed, 23 Nov 2011 12:24:27 +0100 | |
| branch | popcorn-port |
| changeset 309 | 49c2b9e63591 |
| parent 264 | 9fb001b19dd2 |
| child 312 | 228b27fd2a7c |
| permissions | -rw-r--r-- |
| 98 | 1 |
IriSP.AnnotationsWidget = function(Popcorn, config, Serializer) { |
2 |
IriSP.Widget.call(this, Popcorn, config, Serializer); |
|
3 |
|
|
4 |
}; |
|
5 |
||
6 |
||
| 139 | 7 |
IriSP.AnnotationsWidget.prototype = new IriSP.Widget(); |
| 98 | 8 |
|
9 |
IriSP.AnnotationsWidget.prototype.clear = function() { |
|
| 162 | 10 |
this.selector.find(".Ldt-SaTitle").text(""); |
11 |
this.selector.find(".Ldt-SaDescription").text(""); |
|
12 |
this.selector.find(".Ldt-SaKeywordText").text(""); |
|
| 98 | 13 |
}; |
14 |
||
15 |
IriSP.AnnotationsWidget.prototype.displayAnnotation = function(annotation) { |
|
| 264 | 16 |
|
| 98 | 17 |
var title = annotation.content.title; |
18 |
var description = annotation.content.description; |
|
19 |
var keywords = "" // FIXME; |
|
|
309
49c2b9e63591
added segment duration display to the annotationsWidget
hamidouk
parents:
264
diff
changeset
|
20 |
var begin = +annotation.begin / 1000; |
|
49c2b9e63591
added segment duration display to the annotationsWidget
hamidouk
parents:
264
diff
changeset
|
21 |
var end = +annotation.end / 1000; |
| 98 | 22 |
var duration = +this._serializer.currentMedia().meta["dc:duration"]; |
23 |
||
|
309
49c2b9e63591
added segment duration display to the annotationsWidget
hamidouk
parents:
264
diff
changeset
|
24 |
var title_templ = "{{title}} - ( {{begin}} - {{end}} )"; |
|
49c2b9e63591
added segment duration display to the annotationsWidget
hamidouk
parents:
264
diff
changeset
|
25 |
var endstr = Mustache.to_html(title_templ, {title: title, begin: IriSP.secondsToTime(begin), end: IriSP.secondsToTime(end)}); |
|
49c2b9e63591
added segment duration display to the annotationsWidget
hamidouk
parents:
264
diff
changeset
|
26 |
|
|
49c2b9e63591
added segment duration display to the annotationsWidget
hamidouk
parents:
264
diff
changeset
|
27 |
this.selector.find(".Ldt-SaTitle").text(endstr); |
| 162 | 28 |
this.selector.find(".Ldt-SaDescription").text(description); |
|
309
49c2b9e63591
added segment duration display to the annotationsWidget
hamidouk
parents:
264
diff
changeset
|
29 |
//var startPourcent = parseInt(Math.round((begin*1+(end*1-begin*1)/2) / (duration*1)) / 100); |
| 98 | 30 |
|
31 |
}; |
|
32 |
||
| 125 | 33 |
IriSP.AnnotationsWidget.prototype.clearWidget = function() { |
| 264 | 34 |
|
35 |
|
|
| 125 | 36 |
/* retract the pane between two annotations */ |
| 162 | 37 |
this.selector.find(".Ldt-SaTitle").text(""); |
38 |
this.selector.find(".Ldt-SaDescription").text(""); |
|
39 |
this.selector.find(".Ldt-SaKeywordText").html(""); |
|
40 |
this.selector.find(".Ldt-ShowAnnotation").slideUp(); |
|
| 130 | 41 |
}; |
42 |
||
| 98 | 43 |
IriSP.AnnotationsWidget.prototype.draw = function() { |
44 |
var _this = this; |
|
45 |
||
46 |
var annotationMarkup = Mustache.to_html(IriSP.annotationWidget_template, {"share_template" : IriSP.share_template}); |
|
| 162 | 47 |
this.selector.append(annotationMarkup); |
| 139 | 48 |
|
| 98 | 49 |
var annotations = this._serializer._data.annotations; |
| 146 | 50 |
var i; |
51 |
|
|
| 98 | 52 |
for (i in annotations) { |
53 |
var annotation = annotations[i]; |
|
54 |
var begin = Math.round((+ annotation.begin) / 1000); |
|
55 |
var end = Math.round((+ annotation.end) / 1000); |
|
56 |
||
| 125 | 57 |
var conf = {start: begin, end: end, |
58 |
onStart: |
|
| 264 | 59 |
function(annotation) { |
60 |
return function() { |
|
61 |
/* we need it because we have to restore |
|
62 |
the display after displaying the contents |
|
63 |
of a tweet. |
|
64 |
*/ |
|
65 |
_this._currentAnnotation = annotation; |
|
66 |
_this.displayAnnotation(annotation); |
|
67 |
|
|
68 |
} }(annotation), |
|
| 125 | 69 |
onEnd: |
| 264 | 70 |
function() { _this.clearWidget.call(_this); }, |
| 125 | 71 |
}; |
72 |
this._Popcorn = this._Popcorn.code(conf); |
|
| 98 | 73 |
} |
| 264 | 74 |
|
|
309
49c2b9e63591
added segment duration display to the annotationsWidget
hamidouk
parents:
264
diff
changeset
|
75 |
}; |