|
924
|
1 |
// TODO: Migrate Timeupdate functions to Extract |
|
876
|
2 |
|
|
|
3 |
IriSP.Widgets.Annotation = function(player, config) { |
|
|
4 |
IriSP.Widgets.Widget.call(this, player, config); |
|
|
5 |
this.lastAnnotation = false; |
|
923
|
6 |
this.minimized = this.start_minimized || false; |
|
|
7 |
this.bounds = [ 0, 0 ]; |
|
876
|
8 |
}; |
|
|
9 |
|
|
|
10 |
IriSP.Widgets.Annotation.prototype = new IriSP.Widgets.Widget(); |
|
|
11 |
|
|
|
12 |
IriSP.Widgets.Annotation.prototype.messages = { |
|
923
|
13 |
fr: { |
|
876
|
14 |
watching: "Je regarde ", |
|
|
15 |
on_site: " sur ", |
|
923
|
16 |
tags_: "Mots-clés :", |
|
|
17 |
description_: "Description :", |
|
982
|
18 |
excerpt_from: "Extrait de :", |
|
|
19 |
untitled: "Segment sans titre" |
|
876
|
20 |
}, |
|
923
|
21 |
en: { |
|
876
|
22 |
watching: "I'm watching ", |
|
|
23 |
on_site: " on ", |
|
923
|
24 |
tags_: "Keywords:", |
|
|
25 |
description_: "Description:", |
|
982
|
26 |
excerpt_from: "Excerpt from:", |
|
|
27 |
untitled: "Untitled segment" |
|
876
|
28 |
} |
|
|
29 |
} |
|
|
30 |
|
|
|
31 |
IriSP.Widgets.Annotation.prototype.template = |
|
965
|
32 |
'{{#show_arrow}}<div class="Ldt-Annotation-Arrow"></div>{{/show_arrow}}' |
|
|
33 |
+ '<div class="Ldt-Annotation-Widget {{^show_arrow}}Ldt-Annotation-ShowTop{{/show_arrow}}">' |
|
923
|
34 |
+ '<div class="Ldt-Annotation-Inner Ldt-Annotation-Empty{{#start_minimized}} Ldt-Annotation-Minimized{{/start_minimized}}">' |
|
|
35 |
+ '<div class="Ldt-Annotation-HiddenWhenEmpty Ldt-Annotation-MaxMinButton"></div>' |
|
982
|
36 |
+ '{{#show_social}}<div class="Ldt-Annotation-Social Ldt-Annotation-HiddenWhenMinimized Ldt-Annotation-HiddenWhenEmpty"></div>{{/show_social}}' |
|
|
37 |
+ '<h3 class="Ldt-Annotation-HiddenWhenEmpty">{{#show_annotation_type}}<span class="Ldt-Annotation-Type"></span> » {{/show_annotation_type}}<span class="Ldt-Annotation-Title"></span> <span class="Ldt-Annotation-Time Ldt-Annotation-HiddenWhenMinimized">' |
|
|
38 |
+ '(<span class="Ldt-Annotation-Begin"></span> - <span class="Ldt-Annotation-End"></span>)</span></h3>' |
|
|
39 |
+ '<h3 class="Ldt-Annotation-MashupOrigin Ldt-Annotation-HiddenWhenEmpty">{{l10n.excerpt_from}} <span class="Ldt-Annotation-MashupMedia"></span> <span class="Ldt-Annotation-Time Ldt-Annotation-HiddenWhenMinimized">' |
|
|
40 |
+ '(<span class="Ldt-Annotation-MashupBegin"></span> - <span class="Ldt-Annotation-MashupEnd"></span>)</span></h3>' |
|
923
|
41 |
+ '<div class="Ldt-Annotation-Cleared Ldt-Annotation-HiddenWhenMinimized Ldt-Annotation-HiddenWhenEmpty Ldt-Annotation-Description-Block"><div class="Ldt-Annotation-Label">{{l10n.description_}}</div>' |
|
|
42 |
+ '<p class="Ldt-Annotation-Labelled Ldt-Annotation-Description"></p></div>' |
|
|
43 |
+ '<div class="Ldt-Annotation-Tags-Block Ldt-Annotation-HiddenWhenMinimized Ldt-Annotation-HiddenWhenEmpty Ldt-Annotation-Cleared">' |
|
|
44 |
+ '<div class="Ldt-Annotation-Label">{{l10n.tags_}}</div><ul class="Ldt-Annotation-Labelled Ldt-Annotation-Tags"></ul>' |
|
924
|
45 |
+ '</div></div></div></div>'; |
|
876
|
46 |
|
|
|
47 |
IriSP.Widgets.Annotation.prototype.defaults = { |
|
|
48 |
annotation_type : "chap", |
|
965
|
49 |
start_minimized: false, |
|
|
50 |
show_arrow : true, |
|
964
|
51 |
site_name : "Lignes de Temps", |
|
982
|
52 |
search_on_tag_click: true, |
|
|
53 |
show_social: true, |
|
|
54 |
show_annotation_type: false |
|
876
|
55 |
} |
|
|
56 |
|
|
|
57 |
IriSP.Widgets.Annotation.prototype.draw = function() { |
|
965
|
58 |
|
|
|
59 |
var _this = this; |
|
|
60 |
|
|
|
61 |
function timeupdate(_time) { |
|
|
62 |
var _list = _this.getWidgetAnnotationsAtTime(); |
|
|
63 |
if (!_list.length) { |
|
|
64 |
_this.$.find(".Ldt-Annotation-Inner").addClass("Ldt-Annotation-Empty"); |
|
|
65 |
if (_this.arrow) { |
|
|
66 |
_this.arrow.moveToTime(_time); |
|
|
67 |
} |
|
|
68 |
_this.bounds = [ _time, _time ]; |
|
|
69 |
_this.sendBounds(); |
|
|
70 |
} |
|
|
71 |
} |
|
|
72 |
|
|
|
73 |
function drawAnnotation(_annotation) { |
|
|
74 |
var _url = (typeof _annotation.url !== "undefined" |
|
|
75 |
? _annotation.url |
|
|
76 |
: (document.location.href.replace(/#.*$/,'') + '#id=' + _annotation.id)), |
|
|
77 |
_text = _this.l10n.watching + _annotation.title + (_this.site_name ? _this.l10n.on_site + _this.site_name : ''), |
|
|
78 |
_tags = _annotation.getTags(), |
|
|
79 |
_tagblock = _this.$.find(".Ldt-Annotation-Tags"); |
|
|
80 |
if (_tags.length) { |
|
|
81 |
_this.$.find(".Ldt-Annotation-Tags-Block").removeClass("Ldt-Annotation-EmptyBlock"); |
|
|
82 |
_tags.forEach(function(_tag) { |
|
|
83 |
var _trimmedTitle = _tag.title.replace(/(^\s+|\s+$)/g,''); |
|
|
84 |
if (_trimmedTitle) { |
|
|
85 |
var _el = IriSP.jQuery('<li class="Ldt-Annotation-TagLabel"></li>').append(IriSP.jQuery('<span>').text(_trimmedTitle)); |
|
|
86 |
_el.click(function() { |
|
|
87 |
if (_this.search_on_tag_click) { |
|
|
88 |
_this.player.trigger("search.triggeredSearch",_trimmedTitle); |
|
|
89 |
} |
|
|
90 |
_tag.trigger("click"); |
|
|
91 |
}); |
|
|
92 |
_tagblock.append(_el); |
|
|
93 |
} |
|
|
94 |
}); |
|
|
95 |
} else { |
|
|
96 |
_this.$.find(".Ldt-Annotation-Tags-Block").addClass("Ldt-Annotation-EmptyBlock"); |
|
|
97 |
} |
|
982
|
98 |
_this.$.find(".Ldt-Annotation-Title").text(_annotation.title || "(" + _this.l10n.untitled + ")"); |
|
965
|
99 |
var _desc = _annotation.description.replace(/(^\s+|\s+$)/g,''); |
|
|
100 |
if (_desc) { |
|
|
101 |
_this.$.find(".Ldt-Annotation-Description-Block").removeClass("Ldt-Annotation-EmptyBlock"); |
|
|
102 |
_this.$.find(".Ldt-Annotation-Description").html(_desc); |
|
|
103 |
} else { |
|
|
104 |
_this.$.find(".Ldt-Annotation-Description-Block").addClass("Ldt-Annotation-EmptyBlock"); |
|
|
105 |
} |
|
982
|
106 |
if (_this.show_annotation_type) { |
|
|
107 |
_this.$.find(".Ldt-Annotation-Type").text(_annotation.getAnnotationType().title) |
|
|
108 |
} |
|
|
109 |
_this.$.find(".Ldt-Annotation-Begin").text(_annotation.begin.toString()); |
|
|
110 |
_this.$.find(".Ldt-Annotation-End").text(_annotation.end.toString()); |
|
965
|
111 |
if (_annotation.elementType === "mashedAnnotation") { |
|
|
112 |
_this.$.find('.Ldt-Annotation-Inner').addClass("Ldt-Annotation-isMashup"); |
|
982
|
113 |
_this.$.find(".Ldt-Annotation-MashupMedia").text(_annotation.getMedia().title); |
|
|
114 |
_this.$.find(".Ldt-Annotation-MashupBegin").text(_annotation.annotation.begin.toString()); |
|
|
115 |
_this.$.find(".Ldt-Annotation-MashupEnd").text(_annotation.annotation.end.toString()); |
|
965
|
116 |
} else { |
|
|
117 |
_this.$.find('.Ldt-Annotation-Inner').removeClass("Ldt-Annotation-isMashup"); |
|
|
118 |
} |
|
|
119 |
if (typeof _this.socialWidget !== "undefined") { |
|
|
120 |
_this.socialWidget.updateUrls(_url, _text); |
|
|
121 |
} else { |
|
|
122 |
setTimeout(function() { |
|
|
123 |
if (typeof _this.socialWidget !== "undefined") { |
|
|
124 |
_this.socialWidget.updateUrls(_url, _text); |
|
|
125 |
} |
|
|
126 |
},800); |
|
|
127 |
} |
|
|
128 |
_this.$.find(".Ldt-Annotation-Inner").removeClass("Ldt-Annotation-Empty"); |
|
|
129 |
_this.bounds = [ _annotation.begin, _annotation.end ]; |
|
|
130 |
if (_this.arrow) { |
|
|
131 |
_this.arrow.moveToTime((_annotation.begin + _annotation.end)/2); |
|
|
132 |
} |
|
|
133 |
_this.sendBounds(); |
|
|
134 |
} |
|
|
135 |
|
|
876
|
136 |
this.renderTemplate(); |
|
982
|
137 |
|
|
|
138 |
if (_this.show_social) { |
|
|
139 |
this.insertSubwidget(this.$.find(".Ldt-Annotation-Social"), { type: "Social" }, "socialWidget"); |
|
|
140 |
} |
|
|
141 |
|
|
965
|
142 |
this.insertSubwidget(this.$.find(".Ldt-Annotation-Arrow"), { type: "Arrow" }, "arrow"); |
|
|
143 |
this.onMediaEvent("timeupdate",timeupdate); |
|
957
|
144 |
this.onMdpEvent("Annotation.hide","hide"); |
|
|
145 |
this.onMdpEvent("Annotation.show","show"); |
|
|
146 |
this.onMdpEvent("Annotation.minimize","minimize"); |
|
|
147 |
this.onMdpEvent("Annotation.maximize","maximize"); |
|
|
148 |
this.onMdpEvent("Annotation.getBounds","sendBounds"); |
|
923
|
149 |
this.$.find(".Ldt-Annotation-MaxMinButton").click(this.functionWrapper("toggleSize")); |
|
965
|
150 |
this.getWidgetAnnotations().forEach(function(_a) { |
|
|
151 |
_a.on("enter", function() { |
|
|
152 |
drawAnnotation(_a) |
|
|
153 |
}); |
|
|
154 |
}); |
|
923
|
155 |
} |
|
|
156 |
|
|
|
157 |
IriSP.Widgets.Annotation.prototype.sendBounds = function() { |
|
957
|
158 |
this.player.trigger("Annotation.boundsChanged",this.bounds); |
|
876
|
159 |
} |
|
|
160 |
|
|
|
161 |
IriSP.Widgets.Annotation.prototype.drawAnnotation = function(_annotation) { |
|
|
162 |
this.lastAnnotation = _annotation.id; |
|
965
|
163 |
|
|
876
|
164 |
} |
|
880
|
165 |
|
|
|
166 |
IriSP.Widgets.Annotation.prototype.hide = function() { |
|
|
167 |
this.$.slideUp(); |
|
|
168 |
} |
|
|
169 |
|
|
|
170 |
IriSP.Widgets.Annotation.prototype.show = function() { |
|
|
171 |
this.$.slideDown(); |
|
|
172 |
} |
|
|
173 |
|
|
923
|
174 |
IriSP.Widgets.Annotation.prototype.toggleSize = function() { |
|
|
175 |
if (this.minimized) { |
|
|
176 |
this.maximize(); |
|
|
177 |
} else { |
|
|
178 |
this.minimize(); |
|
|
179 |
} |
|
|
180 |
} |
|
|
181 |
|
|
880
|
182 |
IriSP.Widgets.Annotation.prototype.minimize = function() { |
|
923
|
183 |
this.minimized = true; |
|
880
|
184 |
this.$.find('.Ldt-Annotation-Inner').addClass("Ldt-Annotation-Minimized"); |
|
|
185 |
} |
|
|
186 |
|
|
|
187 |
IriSP.Widgets.Annotation.prototype.maximize = function() { |
|
923
|
188 |
this.minimized = false; |
|
880
|
189 |
this.$.find('.Ldt-Annotation-Inner').removeClass("Ldt-Annotation-Minimized"); |
|
|
190 |
} |