| author | hamidouk |
| Wed, 18 Jan 2012 11:34:52 +0100 | |
| branch | popcorn-port |
| changeset 661 | 48c1beea7b1c |
| parent 651 | c43441822b1b |
| child 777 | 96e89720ff18 |
| permissions | -rw-r--r-- |
| 98 | 1 |
IriSP.AnnotationsWidget = function(Popcorn, config, Serializer) { |
2 |
IriSP.Widget.call(this, Popcorn, config, Serializer); |
|
| 541 | 3 |
/* flag used when we're creating an annotation */ |
4 |
this._hidden = false; |
|
| 98 | 5 |
}; |
6 |
||
7 |
||
| 139 | 8 |
IriSP.AnnotationsWidget.prototype = new IriSP.Widget(); |
| 98 | 9 |
|
10 |
IriSP.AnnotationsWidget.prototype.clear = function() { |
|
| 162 | 11 |
this.selector.find(".Ldt-SaTitle").text(""); |
12 |
this.selector.find(".Ldt-SaDescription").text(""); |
|
13 |
this.selector.find(".Ldt-SaKeywordText").text(""); |
|
| 98 | 14 |
}; |
15 |
||
| 541 | 16 |
IriSP.AnnotationsWidget.prototype.displayAnnotation = function(annotation) { |
| 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; |
| 651 | 36 |
var url = document.location.href + "#id=" + annotation.id; |
37 |
this.selector.find(".Ldt-fbShare").attr("href", IriSP.mkFbUrl(url, text)); |
|
38 |
this.selector.find(".Ldt-TwShare").attr("href", IriSP.mkTweetUrl(url, text)); |
|
39 |
this.selector.find(".Ldt-GplusShare").attr("href", IriSP.mkGplusUrl(url, text)); |
|
| 98 | 40 |
}; |
41 |
||
| 541 | 42 |
IriSP.AnnotationsWidget.prototype.clearWidget = function() { |
| 125 | 43 |
/* retract the pane between two annotations */ |
| 162 | 44 |
this.selector.find(".Ldt-SaTitle").text(""); |
45 |
this.selector.find(".Ldt-SaDescription").text(""); |
|
46 |
this.selector.find(".Ldt-SaKeywordText").html(""); |
|
47 |
this.selector.find(".Ldt-ShowAnnotation").slideUp(); |
|
| 130 | 48 |
}; |
49 |
||
| 98 | 50 |
IriSP.AnnotationsWidget.prototype.draw = function() { |
51 |
var _this = this; |
|
52 |
||
| 382 | 53 |
var annotationMarkup = IriSP.templToHTML(IriSP.annotationWidget_template); |
| 162 | 54 |
this.selector.append(annotationMarkup); |
| 541 | 55 |
|
56 |
this._Popcorn.listen("IriSP.PlayerWidget.AnnotateButton.clicked", |
|
57 |
IriSP.wrap(this, this.handleAnnotateSignal)); |
|
|
595
29d86e6c61a6
finished going through the widgets to add stricter line checking.
hamidouk
parents:
541
diff
changeset
|
58 |
var legal_ids = []; |
|
29d86e6c61a6
finished going through the widgets to add stricter line checking.
hamidouk
parents:
541
diff
changeset
|
59 |
if (typeof(this._serializer.getChapitrage()) !== "undefined") |
|
29d86e6c61a6
finished going through the widgets to add stricter line checking.
hamidouk
parents:
541
diff
changeset
|
60 |
legal_ids.push(this._serializer.getChapitrage()); |
|
29d86e6c61a6
finished going through the widgets to add stricter line checking.
hamidouk
parents:
541
diff
changeset
|
61 |
else |
|
29d86e6c61a6
finished going through the widgets to add stricter line checking.
hamidouk
parents:
541
diff
changeset
|
62 |
legal_ids = this._serializer.getNonTweetIds(); |
| 538 | 63 |
|
| 98 | 64 |
var annotations = this._serializer._data.annotations; |
| 146 | 65 |
var i; |
66 |
|
|
| 98 | 67 |
for (i in annotations) { |
68 |
var annotation = annotations[i]; |
|
69 |
var begin = Math.round((+ annotation.begin) / 1000); |
|
70 |
var end = Math.round((+ annotation.end) / 1000); |
|
71 |
||
| 538 | 72 |
if (typeof(annotation.meta) !== "undefined" && typeof(annotation.meta["id-ref"]) !== "undefined" |
73 |
&& !IriSP.underscore.include(legal_ids, annotation.meta["id-ref"])) { |
|
| 393 | 74 |
continue; |
75 |
} |
|
76 |
||
77 |
||
| 125 | 78 |
var conf = {start: begin, end: end, |
79 |
onStart: |
|
| 264 | 80 |
function(annotation) { |
81 |
return function() { |
|
| 393 | 82 |
_this.displayAnnotation(annotation); |
| 264 | 83 |
|
84 |
} }(annotation), |
|
| 125 | 85 |
onEnd: |
| 493 | 86 |
function() { _this.clearWidget.call(_this); } |
| 125 | 87 |
}; |
88 |
this._Popcorn = this._Popcorn.code(conf); |
|
| 98 | 89 |
} |
| 264 | 90 |
|
|
309
49c2b9e63591
added segment duration display to the annotationsWidget
hamidouk
parents:
264
diff
changeset
|
91 |
}; |
| 541 | 92 |
|
93 |
IriSP.AnnotationsWidget.prototype.handleAnnotateSignal = function() { |
|
94 |
if (this._hidden == false) { |
|
95 |
this.selector.hide(); |
|
96 |
this._hidden = true; |
|
97 |
} else { |
|
98 |
this.selector.show(); |
|
99 |
this._hidden = false; |
|
100 |
} |
|
101 |
}; |