| author | hamidouk |
| Mon, 19 Dec 2011 12:30:36 +0100 | |
| branch | popcorn-port |
| changeset 479 | 24308670f1bb |
| parent 470 | 19389e221722 |
| child 493 | f7333cdf5320 |
| 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 |
||
|
470
19389e221722
the annotationWidget "share" buttons now work correctly.
hamidouk
parents:
393
diff
changeset
|
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"]; |
|
470
19389e221722
the annotationWidget "share" buttons now work correctly.
hamidouk
parents:
393
diff
changeset
|
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); |
|
470
19389e221722
the annotationWidget "share" buttons now work correctly.
hamidouk
parents:
393
diff
changeset
|
29 |
|
|
19389e221722
the annotationWidget "share" buttons now work correctly.
hamidouk
parents:
393
diff
changeset
|
30 |
// update sharing buttons |
|
19389e221722
the annotationWidget "share" buttons now work correctly.
hamidouk
parents:
393
diff
changeset
|
31 |
var defaults = IriSP.widgetsDefaults.AnnotationsWidget; |
|
19389e221722
the annotationWidget "share" buttons now work correctly.
hamidouk
parents:
393
diff
changeset
|
32 |
var text = defaults.share_text; |
|
19389e221722
the annotationWidget "share" buttons now work correctly.
hamidouk
parents:
393
diff
changeset
|
33 |
var fb_link = defaults.fb_link; |
|
19389e221722
the annotationWidget "share" buttons now work correctly.
hamidouk
parents:
393
diff
changeset
|
34 |
var tw_link = defaults.tw_link; |
|
19389e221722
the annotationWidget "share" buttons now work correctly.
hamidouk
parents:
393
diff
changeset
|
35 |
var gplus_link = defaults.gplus_link; |
|
19389e221722
the annotationWidget "share" buttons now work correctly.
hamidouk
parents:
393
diff
changeset
|
36 |
var url = document.location.href + "#a=" + annotation.id; |
|
19389e221722
the annotationWidget "share" buttons now work correctly.
hamidouk
parents:
393
diff
changeset
|
37 |
this.selector.find(".Ldt-fbShare").attr("href", fb_link + IriSP.encodeURI(text) + IriSP.encodeURI(url)); |
|
19389e221722
the annotationWidget "share" buttons now work correctly.
hamidouk
parents:
393
diff
changeset
|
38 |
this.selector.find(".Ldt-TwShare").attr("href", tw_link + IriSP.encodeURI(text) + IriSP.encodeURI(url)); |
|
19389e221722
the annotationWidget "share" buttons now work correctly.
hamidouk
parents:
393
diff
changeset
|
39 |
this.selector.find(".Ldt-GplusShare").attr("href", fb_link + IriSP.encodeURI(text) + IriSP.encodeURI(url)); |
| 98 | 40 |
}; |
41 |
||
| 125 | 42 |
IriSP.AnnotationsWidget.prototype.clearWidget = function() { |
| 264 | 43 |
|
44 |
|
|
| 125 | 45 |
/* retract the pane between two annotations */ |
| 162 | 46 |
this.selector.find(".Ldt-SaTitle").text(""); |
47 |
this.selector.find(".Ldt-SaDescription").text(""); |
|
48 |
this.selector.find(".Ldt-SaKeywordText").html(""); |
|
49 |
this.selector.find(".Ldt-ShowAnnotation").slideUp(); |
|
| 130 | 50 |
}; |
51 |
||
| 98 | 52 |
IriSP.AnnotationsWidget.prototype.draw = function() { |
53 |
var _this = this; |
|
54 |
||
| 382 | 55 |
var annotationMarkup = IriSP.templToHTML(IriSP.annotationWidget_template); |
| 162 | 56 |
this.selector.append(annotationMarkup); |
| 393 | 57 |
var view; |
| 139 | 58 |
|
| 393 | 59 |
if (typeof(this._serializer._data.views) !== "undefined" && this._serializer._data.views !== null) |
60 |
view = this._serializer._data.views[0]; |
|
61 |
||
62 |
var view_type = ""; |
|
63 |
||
64 |
if(typeof(view) !== "undefined" && typeof(view.annotation_types) !== "undefined" && view.annotation_types.length > 1) { |
|
65 |
view_type = view.annotation_types[0]; |
|
66 |
} |
|
67 |
|
|
| 98 | 68 |
var annotations = this._serializer._data.annotations; |
| 146 | 69 |
var i; |
70 |
|
|
| 98 | 71 |
for (i in annotations) { |
72 |
var annotation = annotations[i]; |
|
73 |
var begin = Math.round((+ annotation.begin) / 1000); |
|
74 |
var end = Math.round((+ annotation.end) / 1000); |
|
75 |
||
| 393 | 76 |
if (view_type != "" && typeof(annotation.meta) !== "undefined" && typeof(annotation.meta["id-ref"]) !== "undefined" |
77 |
&& annotation.meta["id-ref"] != view_type) { |
|
78 |
continue; |
|
79 |
} |
|
80 |
||
81 |
||
| 125 | 82 |
var conf = {start: begin, end: end, |
83 |
onStart: |
|
| 264 | 84 |
function(annotation) { |
85 |
return function() { |
|
| 393 | 86 |
_this.displayAnnotation(annotation); |
| 264 | 87 |
|
88 |
} }(annotation), |
|
| 125 | 89 |
onEnd: |
| 264 | 90 |
function() { _this.clearWidget.call(_this); }, |
| 125 | 91 |
}; |
92 |
this._Popcorn = this._Popcorn.code(conf); |
|
| 98 | 93 |
} |
| 264 | 94 |
|
|
309
49c2b9e63591
added segment duration display to the annotationsWidget
hamidouk
parents:
264
diff
changeset
|
95 |
}; |