| author | veltr |
| Mon, 26 Mar 2012 19:18:04 +0200 | |
| branch | popcorn-port |
| changeset 838 | 03b03865eb9b |
| parent 820 | 7968346b9689 |
| child 842 | 4ae2247a59f4 |
| permissions | -rw-r--r-- |
|
838
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
820
diff
changeset
|
1 |
/* Internationalization for this widget */ |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
820
diff
changeset
|
2 |
|
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
820
diff
changeset
|
3 |
IriSP.i18n.addMessages( |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
820
diff
changeset
|
4 |
{ |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
820
diff
changeset
|
5 |
"fr": { |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
820
diff
changeset
|
6 |
"keywords": "Mots-clés" |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
820
diff
changeset
|
7 |
}, |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
820
diff
changeset
|
8 |
"en": { |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
820
diff
changeset
|
9 |
"keywords": "Keywords" |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
820
diff
changeset
|
10 |
} |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
820
diff
changeset
|
11 |
} |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
820
diff
changeset
|
12 |
); |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
820
diff
changeset
|
13 |
|
| 98 | 14 |
IriSP.AnnotationsWidget = function(Popcorn, config, Serializer) { |
15 |
IriSP.Widget.call(this, Popcorn, config, Serializer); |
|
| 541 | 16 |
/* flag used when we're creating an annotation */ |
17 |
this._hidden = false; |
|
| 98 | 18 |
}; |
19 |
||
20 |
||
| 139 | 21 |
IriSP.AnnotationsWidget.prototype = new IriSP.Widget(); |
| 98 | 22 |
|
23 |
IriSP.AnnotationsWidget.prototype.clear = function() { |
|
| 162 | 24 |
this.selector.find(".Ldt-SaTitle").text(""); |
25 |
this.selector.find(".Ldt-SaDescription").text(""); |
|
26 |
this.selector.find(".Ldt-SaKeywordText").text(""); |
|
| 98 | 27 |
}; |
28 |
||
| 541 | 29 |
IriSP.AnnotationsWidget.prototype.displayAnnotation = function(annotation) { |
| 98 | 30 |
var title = annotation.content.title; |
31 |
var description = annotation.content.description; |
|
| 798 | 32 |
var keywords = ""; |
|
309
49c2b9e63591
added segment duration display to the annotationsWidget
hamidouk
parents:
264
diff
changeset
|
33 |
var begin = +annotation.begin / 1000; |
|
49c2b9e63591
added segment duration display to the annotationsWidget
hamidouk
parents:
264
diff
changeset
|
34 |
var end = +annotation.end / 1000; |
|
820
7968346b9689
Added compatibility with cinecast format (with get_aliased)
veltr
parents:
798
diff
changeset
|
35 |
var duration = this._serializer.getDuration(); |
| 782 | 36 |
var tags = ""; |
|
470
19389e221722
the annotationWidget "share" buttons now work correctly.
hamidouk
parents:
393
diff
changeset
|
37 |
|
|
309
49c2b9e63591
added segment duration display to the annotationsWidget
hamidouk
parents:
264
diff
changeset
|
38 |
var title_templ = "{{title}} - ( {{begin}} - {{end}} )"; |
|
49c2b9e63591
added segment duration display to the annotationsWidget
hamidouk
parents:
264
diff
changeset
|
39 |
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
|
40 |
|
|
49c2b9e63591
added segment duration display to the annotationsWidget
hamidouk
parents:
264
diff
changeset
|
41 |
this.selector.find(".Ldt-SaTitle").text(endstr); |
| 162 | 42 |
this.selector.find(".Ldt-SaDescription").text(description); |
|
470
19389e221722
the annotationWidget "share" buttons now work correctly.
hamidouk
parents:
393
diff
changeset
|
43 |
|
| 782 | 44 |
|
45 |
if (!IriSP.null_or_undefined(annotation.tags) && !IriSP.null_or_undefined(this._serializer._data.tags)) { |
|
46 |
/* save the tag id and keywords in a unique structure */ |
|
47 |
var tag_list = {}; |
|
48 |
for (var i = 0; i < this._serializer._data.tags.length; i++) { |
|
49 |
var id = this._serializer._data.tags[i]["id"]; |
|
|
820
7968346b9689
Added compatibility with cinecast format (with get_aliased)
veltr
parents:
798
diff
changeset
|
50 |
var keyword = IriSP.get_aliased(this._serializer._data.tags[i]["meta"], ["dc:title", "title"]); |
| 782 | 51 |
|
52 |
tag_list[id] = keyword; |
|
53 |
} |
|
54 |
||
55 |
/* then browse the list of defined tags for the current annotation */ |
|
56 |
for (var i = 0; i < annotation.tags.length; i++) { |
|
57 |
if (tag_list.hasOwnProperty(annotation.tags[i]["id-ref"])) |
|
58 |
tags += tag_list[annotation.tags[i]["id-ref"]] + ", "; |
|
59 |
} |
|
60 |
} |
|
61 |
|
|
|
838
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
820
diff
changeset
|
62 |
tags = IriSP.i18n.getMessage("keywords") + ": " + tags.slice(0, tags.length - 2); |
| 782 | 63 |
|
64 |
this.selector.find(".Ldt-SaKeywords").text(tags); |
|
65 |
|
|
|
470
19389e221722
the annotationWidget "share" buttons now work correctly.
hamidouk
parents:
393
diff
changeset
|
66 |
// update sharing buttons |
|
19389e221722
the annotationWidget "share" buttons now work correctly.
hamidouk
parents:
393
diff
changeset
|
67 |
var defaults = IriSP.widgetsDefaults.AnnotationsWidget; |
|
19389e221722
the annotationWidget "share" buttons now work correctly.
hamidouk
parents:
393
diff
changeset
|
68 |
var text = defaults.share_text; |
|
19389e221722
the annotationWidget "share" buttons now work correctly.
hamidouk
parents:
393
diff
changeset
|
69 |
var fb_link = defaults.fb_link; |
|
19389e221722
the annotationWidget "share" buttons now work correctly.
hamidouk
parents:
393
diff
changeset
|
70 |
var tw_link = defaults.tw_link; |
|
19389e221722
the annotationWidget "share" buttons now work correctly.
hamidouk
parents:
393
diff
changeset
|
71 |
var gplus_link = defaults.gplus_link; |
| 651 | 72 |
var url = document.location.href + "#id=" + annotation.id; |
73 |
this.selector.find(".Ldt-fbShare").attr("href", IriSP.mkFbUrl(url, text)); |
|
74 |
this.selector.find(".Ldt-TwShare").attr("href", IriSP.mkTweetUrl(url, text)); |
|
75 |
this.selector.find(".Ldt-GplusShare").attr("href", IriSP.mkGplusUrl(url, text)); |
|
| 98 | 76 |
}; |
77 |
||
| 541 | 78 |
IriSP.AnnotationsWidget.prototype.clearWidget = function() { |
| 125 | 79 |
/* retract the pane between two annotations */ |
| 162 | 80 |
this.selector.find(".Ldt-SaTitle").text(""); |
81 |
this.selector.find(".Ldt-SaDescription").text(""); |
|
82 |
this.selector.find(".Ldt-SaKeywordText").html(""); |
|
83 |
this.selector.find(".Ldt-ShowAnnotation").slideUp(); |
|
| 130 | 84 |
}; |
85 |
||
| 98 | 86 |
IriSP.AnnotationsWidget.prototype.draw = function() { |
87 |
var _this = this; |
|
88 |
||
| 382 | 89 |
var annotationMarkup = IriSP.templToHTML(IriSP.annotationWidget_template); |
| 162 | 90 |
this.selector.append(annotationMarkup); |
| 541 | 91 |
|
|
777
96e89720ff18
added show/hide message. Removed reaction to annotateClick signal
hamidouk
parents:
651
diff
changeset
|
92 |
this._Popcorn.listen("IriSP.AnnotationsWidget.show", |
|
96e89720ff18
added show/hide message. Removed reaction to annotateClick signal
hamidouk
parents:
651
diff
changeset
|
93 |
IriSP.wrap(this, this.show)); |
|
96e89720ff18
added show/hide message. Removed reaction to annotateClick signal
hamidouk
parents:
651
diff
changeset
|
94 |
this._Popcorn.listen("IriSP.AnnotationsWidget.hide", |
|
96e89720ff18
added show/hide message. Removed reaction to annotateClick signal
hamidouk
parents:
651
diff
changeset
|
95 |
IriSP.wrap(this, this.hide)); |
|
96e89720ff18
added show/hide message. Removed reaction to annotateClick signal
hamidouk
parents:
651
diff
changeset
|
96 |
|
|
595
29d86e6c61a6
finished going through the widgets to add stricter line checking.
hamidouk
parents:
541
diff
changeset
|
97 |
var legal_ids = []; |
|
29d86e6c61a6
finished going through the widgets to add stricter line checking.
hamidouk
parents:
541
diff
changeset
|
98 |
if (typeof(this._serializer.getChapitrage()) !== "undefined") |
|
29d86e6c61a6
finished going through the widgets to add stricter line checking.
hamidouk
parents:
541
diff
changeset
|
99 |
legal_ids.push(this._serializer.getChapitrage()); |
|
29d86e6c61a6
finished going through the widgets to add stricter line checking.
hamidouk
parents:
541
diff
changeset
|
100 |
else |
|
29d86e6c61a6
finished going through the widgets to add stricter line checking.
hamidouk
parents:
541
diff
changeset
|
101 |
legal_ids = this._serializer.getNonTweetIds(); |
| 538 | 102 |
|
| 98 | 103 |
var annotations = this._serializer._data.annotations; |
| 146 | 104 |
var i; |
105 |
|
|
| 98 | 106 |
for (i in annotations) { |
107 |
var annotation = annotations[i]; |
|
108 |
var begin = Math.round((+ annotation.begin) / 1000); |
|
109 |
var end = Math.round((+ annotation.end) / 1000); |
|
110 |
||
| 538 | 111 |
if (typeof(annotation.meta) !== "undefined" && typeof(annotation.meta["id-ref"]) !== "undefined" |
112 |
&& !IriSP.underscore.include(legal_ids, annotation.meta["id-ref"])) { |
|
| 393 | 113 |
continue; |
114 |
} |
|
115 |
||
116 |
||
| 125 | 117 |
var conf = {start: begin, end: end, |
118 |
onStart: |
|
| 264 | 119 |
function(annotation) { |
120 |
return function() { |
|
| 393 | 121 |
_this.displayAnnotation(annotation); |
| 264 | 122 |
|
123 |
} }(annotation), |
|
| 125 | 124 |
onEnd: |
| 493 | 125 |
function() { _this.clearWidget.call(_this); } |
| 125 | 126 |
}; |
127 |
this._Popcorn = this._Popcorn.code(conf); |
|
| 98 | 128 |
} |
| 264 | 129 |
|
|
309
49c2b9e63591
added segment duration display to the annotationsWidget
hamidouk
parents:
264
diff
changeset
|
130 |
}; |
| 541 | 131 |
|
|
777
96e89720ff18
added show/hide message. Removed reaction to annotateClick signal
hamidouk
parents:
651
diff
changeset
|
132 |
IriSP.AnnotationsWidget.prototype.hide = function() { |
| 541 | 133 |
if (this._hidden == false) { |
134 |
this.selector.hide(); |
|
135 |
this._hidden = true; |
|
|
777
96e89720ff18
added show/hide message. Removed reaction to annotateClick signal
hamidouk
parents:
651
diff
changeset
|
136 |
} |
|
96e89720ff18
added show/hide message. Removed reaction to annotateClick signal
hamidouk
parents:
651
diff
changeset
|
137 |
}; |
|
96e89720ff18
added show/hide message. Removed reaction to annotateClick signal
hamidouk
parents:
651
diff
changeset
|
138 |
|
|
96e89720ff18
added show/hide message. Removed reaction to annotateClick signal
hamidouk
parents:
651
diff
changeset
|
139 |
IriSP.AnnotationsWidget.prototype.show = function() { |
|
96e89720ff18
added show/hide message. Removed reaction to annotateClick signal
hamidouk
parents:
651
diff
changeset
|
140 |
if (this._hidden == true) { |
| 541 | 141 |
this.selector.show(); |
142 |
this._hidden = false; |
|
143 |
} |
|
144 |
}; |