| author | hamidouk |
| Fri, 25 Nov 2011 11:10:19 +0100 | |
| branch | popcorn-port |
| changeset 331 | ef3447aa6920 |
| parent 312 | 228b27fd2a7c |
| child 382 | d68de477761b |
| 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); |
| 98 | 29 |
}; |
30 |
||
| 125 | 31 |
IriSP.AnnotationsWidget.prototype.clearWidget = function() { |
| 264 | 32 |
|
33 |
|
|
| 125 | 34 |
/* retract the pane between two annotations */ |
| 162 | 35 |
this.selector.find(".Ldt-SaTitle").text(""); |
36 |
this.selector.find(".Ldt-SaDescription").text(""); |
|
37 |
this.selector.find(".Ldt-SaKeywordText").html(""); |
|
38 |
this.selector.find(".Ldt-ShowAnnotation").slideUp(); |
|
| 130 | 39 |
}; |
40 |
||
| 98 | 41 |
IriSP.AnnotationsWidget.prototype.draw = function() { |
42 |
var _this = this; |
|
43 |
||
44 |
var annotationMarkup = Mustache.to_html(IriSP.annotationWidget_template, {"share_template" : IriSP.share_template}); |
|
| 162 | 45 |
this.selector.append(annotationMarkup); |
| 139 | 46 |
|
| 98 | 47 |
var annotations = this._serializer._data.annotations; |
| 146 | 48 |
var i; |
49 |
|
|
| 98 | 50 |
for (i in annotations) { |
51 |
var annotation = annotations[i]; |
|
52 |
var begin = Math.round((+ annotation.begin) / 1000); |
|
53 |
var end = Math.round((+ annotation.end) / 1000); |
|
54 |
||
| 125 | 55 |
var conf = {start: begin, end: end, |
56 |
onStart: |
|
| 264 | 57 |
function(annotation) { |
58 |
return function() { |
|
59 |
/* we need it because we have to restore |
|
60 |
the display after displaying the contents |
|
61 |
of a tweet. |
|
62 |
*/ |
|
63 |
_this._currentAnnotation = annotation; |
|
64 |
_this.displayAnnotation(annotation); |
|
65 |
|
|
66 |
} }(annotation), |
|
| 125 | 67 |
onEnd: |
| 264 | 68 |
function() { _this.clearWidget.call(_this); }, |
| 125 | 69 |
}; |
70 |
this._Popcorn = this._Popcorn.code(conf); |
|
| 98 | 71 |
} |
| 264 | 72 |
|
|
309
49c2b9e63591
added segment duration display to the annotationsWidget
hamidouk
parents:
264
diff
changeset
|
73 |
}; |