| author | cavaliet |
| Mon, 13 Feb 2012 12:49:02 +0100 | |
| branch | popcorn-port |
| changeset 798 | 56fd575cb447 |
| parent 782 | 144e215dd324 |
| child 820 | 7968346b9689 |
| 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; |
|
| 798 | 19 |
var keywords = ""; |
|
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"]; |
| 782 | 23 |
var tags = ""; |
|
470
19389e221722
the annotationWidget "share" buttons now work correctly.
hamidouk
parents:
393
diff
changeset
|
24 |
|
|
309
49c2b9e63591
added segment duration display to the annotationsWidget
hamidouk
parents:
264
diff
changeset
|
25 |
var title_templ = "{{title}} - ( {{begin}} - {{end}} )"; |
|
49c2b9e63591
added segment duration display to the annotationsWidget
hamidouk
parents:
264
diff
changeset
|
26 |
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
|
27 |
|
|
49c2b9e63591
added segment duration display to the annotationsWidget
hamidouk
parents:
264
diff
changeset
|
28 |
this.selector.find(".Ldt-SaTitle").text(endstr); |
| 162 | 29 |
this.selector.find(".Ldt-SaDescription").text(description); |
|
470
19389e221722
the annotationWidget "share" buttons now work correctly.
hamidouk
parents:
393
diff
changeset
|
30 |
|
| 782 | 31 |
|
32 |
if (!IriSP.null_or_undefined(annotation.tags) && !IriSP.null_or_undefined(this._serializer._data.tags)) { |
|
33 |
/* save the tag id and keywords in a unique structure */ |
|
34 |
var tag_list = {}; |
|
35 |
for (var i = 0; i < this._serializer._data.tags.length; i++) { |
|
36 |
var id = this._serializer._data.tags[i]["id"]; |
|
37 |
var keyword = this._serializer._data.tags[i]["meta"]["dc:title"]; |
|
38 |
||
39 |
tag_list[id] = keyword; |
|
40 |
} |
|
41 |
||
42 |
/* then browse the list of defined tags for the current annotation */ |
|
43 |
for (var i = 0; i < annotation.tags.length; i++) { |
|
44 |
if (tag_list.hasOwnProperty(annotation.tags[i]["id-ref"])) |
|
45 |
tags += tag_list[annotation.tags[i]["id-ref"]] + ", "; |
|
46 |
} |
|
47 |
} |
|
48 |
|
|
49 |
tags = "Keywords: " + tags.slice(0, tags.length - 2); |
|
50 |
|
|
51 |
this.selector.find(".Ldt-SaKeywords").text(tags); |
|
52 |
|
|
|
470
19389e221722
the annotationWidget "share" buttons now work correctly.
hamidouk
parents:
393
diff
changeset
|
53 |
// update sharing buttons |
|
19389e221722
the annotationWidget "share" buttons now work correctly.
hamidouk
parents:
393
diff
changeset
|
54 |
var defaults = IriSP.widgetsDefaults.AnnotationsWidget; |
|
19389e221722
the annotationWidget "share" buttons now work correctly.
hamidouk
parents:
393
diff
changeset
|
55 |
var text = defaults.share_text; |
|
19389e221722
the annotationWidget "share" buttons now work correctly.
hamidouk
parents:
393
diff
changeset
|
56 |
var fb_link = defaults.fb_link; |
|
19389e221722
the annotationWidget "share" buttons now work correctly.
hamidouk
parents:
393
diff
changeset
|
57 |
var tw_link = defaults.tw_link; |
|
19389e221722
the annotationWidget "share" buttons now work correctly.
hamidouk
parents:
393
diff
changeset
|
58 |
var gplus_link = defaults.gplus_link; |
| 651 | 59 |
var url = document.location.href + "#id=" + annotation.id; |
60 |
this.selector.find(".Ldt-fbShare").attr("href", IriSP.mkFbUrl(url, text)); |
|
61 |
this.selector.find(".Ldt-TwShare").attr("href", IriSP.mkTweetUrl(url, text)); |
|
62 |
this.selector.find(".Ldt-GplusShare").attr("href", IriSP.mkGplusUrl(url, text)); |
|
| 98 | 63 |
}; |
64 |
||
| 541 | 65 |
IriSP.AnnotationsWidget.prototype.clearWidget = function() { |
| 125 | 66 |
/* retract the pane between two annotations */ |
| 162 | 67 |
this.selector.find(".Ldt-SaTitle").text(""); |
68 |
this.selector.find(".Ldt-SaDescription").text(""); |
|
69 |
this.selector.find(".Ldt-SaKeywordText").html(""); |
|
70 |
this.selector.find(".Ldt-ShowAnnotation").slideUp(); |
|
| 130 | 71 |
}; |
72 |
||
| 98 | 73 |
IriSP.AnnotationsWidget.prototype.draw = function() { |
74 |
var _this = this; |
|
75 |
||
| 382 | 76 |
var annotationMarkup = IriSP.templToHTML(IriSP.annotationWidget_template); |
| 162 | 77 |
this.selector.append(annotationMarkup); |
| 541 | 78 |
|
|
777
96e89720ff18
added show/hide message. Removed reaction to annotateClick signal
hamidouk
parents:
651
diff
changeset
|
79 |
this._Popcorn.listen("IriSP.AnnotationsWidget.show", |
|
96e89720ff18
added show/hide message. Removed reaction to annotateClick signal
hamidouk
parents:
651
diff
changeset
|
80 |
IriSP.wrap(this, this.show)); |
|
96e89720ff18
added show/hide message. Removed reaction to annotateClick signal
hamidouk
parents:
651
diff
changeset
|
81 |
this._Popcorn.listen("IriSP.AnnotationsWidget.hide", |
|
96e89720ff18
added show/hide message. Removed reaction to annotateClick signal
hamidouk
parents:
651
diff
changeset
|
82 |
IriSP.wrap(this, this.hide)); |
|
96e89720ff18
added show/hide message. Removed reaction to annotateClick signal
hamidouk
parents:
651
diff
changeset
|
83 |
|
|
595
29d86e6c61a6
finished going through the widgets to add stricter line checking.
hamidouk
parents:
541
diff
changeset
|
84 |
var legal_ids = []; |
|
29d86e6c61a6
finished going through the widgets to add stricter line checking.
hamidouk
parents:
541
diff
changeset
|
85 |
if (typeof(this._serializer.getChapitrage()) !== "undefined") |
|
29d86e6c61a6
finished going through the widgets to add stricter line checking.
hamidouk
parents:
541
diff
changeset
|
86 |
legal_ids.push(this._serializer.getChapitrage()); |
|
29d86e6c61a6
finished going through the widgets to add stricter line checking.
hamidouk
parents:
541
diff
changeset
|
87 |
else |
|
29d86e6c61a6
finished going through the widgets to add stricter line checking.
hamidouk
parents:
541
diff
changeset
|
88 |
legal_ids = this._serializer.getNonTweetIds(); |
| 538 | 89 |
|
| 98 | 90 |
var annotations = this._serializer._data.annotations; |
| 146 | 91 |
var i; |
92 |
|
|
| 98 | 93 |
for (i in annotations) { |
94 |
var annotation = annotations[i]; |
|
95 |
var begin = Math.round((+ annotation.begin) / 1000); |
|
96 |
var end = Math.round((+ annotation.end) / 1000); |
|
97 |
||
| 538 | 98 |
if (typeof(annotation.meta) !== "undefined" && typeof(annotation.meta["id-ref"]) !== "undefined" |
99 |
&& !IriSP.underscore.include(legal_ids, annotation.meta["id-ref"])) { |
|
| 393 | 100 |
continue; |
101 |
} |
|
102 |
||
103 |
||
| 125 | 104 |
var conf = {start: begin, end: end, |
105 |
onStart: |
|
| 264 | 106 |
function(annotation) { |
107 |
return function() { |
|
| 393 | 108 |
_this.displayAnnotation(annotation); |
| 264 | 109 |
|
110 |
} }(annotation), |
|
| 125 | 111 |
onEnd: |
| 493 | 112 |
function() { _this.clearWidget.call(_this); } |
| 125 | 113 |
}; |
114 |
this._Popcorn = this._Popcorn.code(conf); |
|
| 98 | 115 |
} |
| 264 | 116 |
|
|
309
49c2b9e63591
added segment duration display to the annotationsWidget
hamidouk
parents:
264
diff
changeset
|
117 |
}; |
| 541 | 118 |
|
|
777
96e89720ff18
added show/hide message. Removed reaction to annotateClick signal
hamidouk
parents:
651
diff
changeset
|
119 |
IriSP.AnnotationsWidget.prototype.hide = function() { |
| 541 | 120 |
if (this._hidden == false) { |
121 |
this.selector.hide(); |
|
122 |
this._hidden = true; |
|
|
777
96e89720ff18
added show/hide message. Removed reaction to annotateClick signal
hamidouk
parents:
651
diff
changeset
|
123 |
} |
|
96e89720ff18
added show/hide message. Removed reaction to annotateClick signal
hamidouk
parents:
651
diff
changeset
|
124 |
}; |
|
96e89720ff18
added show/hide message. Removed reaction to annotateClick signal
hamidouk
parents:
651
diff
changeset
|
125 |
|
|
96e89720ff18
added show/hide message. Removed reaction to annotateClick signal
hamidouk
parents:
651
diff
changeset
|
126 |
IriSP.AnnotationsWidget.prototype.show = function() { |
|
96e89720ff18
added show/hide message. Removed reaction to annotateClick signal
hamidouk
parents:
651
diff
changeset
|
127 |
if (this._hidden == true) { |
| 541 | 128 |
this.selector.show(); |
129 |
this._hidden = false; |
|
130 |
} |
|
131 |
}; |