| author | hamidouk |
| Fri, 09 Dec 2011 15:42:10 +0100 | |
| branch | popcorn-port |
| changeset 446 | d801a7f9c7c5 |
| parent 393 | 54947acf2770 |
| child 470 | 19389e221722 |
| 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 |
||
| 382 | 44 |
var annotationMarkup = IriSP.templToHTML(IriSP.annotationWidget_template); |
| 162 | 45 |
this.selector.append(annotationMarkup); |
| 393 | 46 |
var view; |
| 139 | 47 |
|
| 393 | 48 |
if (typeof(this._serializer._data.views) !== "undefined" && this._serializer._data.views !== null) |
49 |
view = this._serializer._data.views[0]; |
|
50 |
||
51 |
var view_type = ""; |
|
52 |
||
53 |
if(typeof(view) !== "undefined" && typeof(view.annotation_types) !== "undefined" && view.annotation_types.length > 1) { |
|
54 |
view_type = view.annotation_types[0]; |
|
55 |
} |
|
56 |
|
|
| 98 | 57 |
var annotations = this._serializer._data.annotations; |
| 146 | 58 |
var i; |
59 |
|
|
| 98 | 60 |
for (i in annotations) { |
61 |
var annotation = annotations[i]; |
|
62 |
var begin = Math.round((+ annotation.begin) / 1000); |
|
63 |
var end = Math.round((+ annotation.end) / 1000); |
|
64 |
||
| 393 | 65 |
if (view_type != "" && typeof(annotation.meta) !== "undefined" && typeof(annotation.meta["id-ref"]) !== "undefined" |
66 |
&& annotation.meta["id-ref"] != view_type) { |
|
67 |
continue; |
|
68 |
} |
|
69 |
||
70 |
||
| 125 | 71 |
var conf = {start: begin, end: end, |
72 |
onStart: |
|
| 264 | 73 |
function(annotation) { |
74 |
return function() { |
|
| 393 | 75 |
_this.displayAnnotation(annotation); |
| 264 | 76 |
|
77 |
} }(annotation), |
|
| 125 | 78 |
onEnd: |
| 264 | 79 |
function() { _this.clearWidget.call(_this); }, |
| 125 | 80 |
}; |
81 |
this._Popcorn = this._Popcorn.code(conf); |
|
| 98 | 82 |
} |
| 264 | 83 |
|
|
309
49c2b9e63591
added segment duration display to the annotationsWidget
hamidouk
parents:
264
diff
changeset
|
84 |
}; |