| author | veltr |
| Mon, 05 Nov 2012 19:02:48 +0100 | |
| branch | platform-restapi |
| changeset 976 | 4b9ec475026a |
| parent 975 | 35aadec4131b |
| child 979 | ff62016e051d |
| permissions | -rw-r--r-- |
| 965 | 1 |
/* TODO: Add Social Network Sharing */ |
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
2 |
|
| 880 | 3 |
IriSP.Widgets.CreateAnnotation = function(player, config) { |
4 |
IriSP.Widgets.Widget.call(this, player, config); |
|
5 |
}; |
|
6 |
||
7 |
IriSP.Widgets.CreateAnnotation.prototype = new IriSP.Widgets.Widget(); |
|
8 |
||
9 |
IriSP.Widgets.CreateAnnotation.prototype.defaults = { |
|
| 975 | 10 |
show_title_field : true, |
| 923 | 11 |
show_creator_field : true, |
12 |
start_visible : true, |
|
| 924 | 13 |
always_visible : false, |
| 965 | 14 |
show_slice : true, |
15 |
show_arrow : true, |
|
| 966 | 16 |
show_mic_record: false, |
17 |
show_mic_play: false, |
|
| 924 | 18 |
minimize_annotation_widget : true, |
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
19 |
creator_name : "", |
| 924 | 20 |
creator_avatar : "", |
| 904 | 21 |
tags : false, |
| 924 | 22 |
tag_titles : false, |
| 923 | 23 |
pause_on_write : true, |
| 904 | 24 |
max_tags : 8, |
25 |
polemics : [{ |
|
26 |
keyword: "++", |
|
27 |
background_color: "#00a000", |
|
28 |
text_color: "#ffffff" |
|
29 |
},{ |
|
30 |
keyword: "--", |
|
31 |
background_color: "#c00000", |
|
32 |
text_color: "#ffffff" |
|
33 |
},{ |
|
34 |
keyword: "??", |
|
35 |
background_color: "#0000e0", |
|
36 |
text_color: "#ffffff" |
|
37 |
},{ |
|
38 |
keyword: "==", |
|
39 |
background_color: "#f0e000", |
|
40 |
text_color: "#000000" |
|
41 |
}], |
|
| 965 | 42 |
slice_annotation_type: "chap", |
| 904 | 43 |
annotation_type: "Contributions", |
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
44 |
api_serializer: "ldt_annotate", |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
45 |
api_endpoint_template: "", |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
46 |
api_method: "PUT", |
| 925 | 47 |
after_send_timeout: 0, |
48 |
close_after_send: false, |
|
| 880 | 49 |
} |
50 |
||
51 |
IriSP.Widgets.CreateAnnotation.prototype.messages = { |
|
| 882 | 52 |
en: { |
53 |
from_time: "from", |
|
54 |
to_time: "to", |
|
| 923 | 55 |
at_time: "at", |
| 882 | 56 |
submit: "Submit", |
| 904 | 57 |
add_keywords_: "Add keywords:", |
58 |
add_polemic_keywords_: "Add polemic keywords:", |
|
| 923 | 59 |
your_name_: "Your name:", |
| 882 | 60 |
no_title: "Annotate this video", |
61 |
type_title: "Annotation title", |
|
62 |
type_description: "Type the full description of your annotation here.", |
|
63 |
wait_while_processing: "Please wait while your request is being processed...", |
|
64 |
error_while_contacting: "An error happened while contacting the server. Your annotation has not been saved.", |
|
65 |
empty_annotation: "Your annotation is empty. Please write something before submitting.", |
|
66 |
annotation_saved: "Thank you, your annotation has been saved.", |
|
67 |
share_annotation: "Would you like to share it on social networks ?", |
|
68 |
share_on: "Share on", |
|
69 |
more_tags: "More tags", |
|
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
70 |
cancel: "Cancel", |
| 970 | 71 |
close_widget: "Cacher la zone de création d'annotations", |
72 |
"polemic++": "Agree", |
|
73 |
"polemic--": "Disagree", |
|
74 |
"polemic??": "Question", |
|
75 |
"polemic==": "Reference" |
|
| 880 | 76 |
}, |
| 882 | 77 |
fr: { |
| 904 | 78 |
from_time: "de", |
| 882 | 79 |
to_time: "à", |
| 923 | 80 |
at_time: "à", |
| 882 | 81 |
submit: "Envoyer", |
| 904 | 82 |
add_keywords_: "Ajouter des mots-clés :", |
83 |
add_polemic_keywords_: "Ajouter des mots-clés polémiques :", |
|
| 923 | 84 |
your_name_: "Votre nom :", |
| 882 | 85 |
no_title: "Annoter cette vidéo", |
86 |
type_title: "Titre de l'annotation", |
|
87 |
type_description: "Rédigez le contenu de votre annotation ici.", |
|
88 |
wait_while_processing: "Veuillez patienter pendant le traitement de votre requête...", |
|
89 |
error_while_contacting: "Une erreur s'est produite en contactant le serveur. Votre annotation n'a pas été enregistrée", |
|
90 |
empty_annotation: "Votre annotation est vide. Merci de rédiger un texte avant de l'envoyer.", |
|
91 |
annotation_saved: "Merci, votre annotation a été enregistrée.", |
|
92 |
share_annotation: "Souhaitez-vous la partager sur les réseaux sociaux ?", |
|
93 |
share_on: "Partager sur", |
|
94 |
more_tags: "Plus de mots-clés", |
|
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
95 |
cancel: "Cancel", |
| 970 | 96 |
close_widget: "Hide the annotation creating block", |
97 |
"polemic++": "Accord", |
|
98 |
"polemic--": "Désaccord", |
|
99 |
"polemic??": "Question", |
|
100 |
"polemic==": "Référence" |
|
| 880 | 101 |
} |
102 |
} |
|
103 |
||
104 |
IriSP.Widgets.CreateAnnotation.prototype.template = |
|
| 965 | 105 |
'{{#show_slice}}<div class="Ldt-CreateAnnotation-Slice"></div>{{/show_slice}}' |
106 |
+ '{{^show_slice}}{{#show_arrow}}<div class="Ldt-CreateAnnotation-Arrow"></div>{{/show_arrow}}{{/show_slice}}' |
|
107 |
+ '<div class="Ldt-CreateAnnotation"><div class="Ldt-CreateAnnotation-Inner">' |
|
| 881 | 108 |
+ '<form class="Ldt-CreateAnnotation-Screen Ldt-CreateAnnotation-Main">' |
| 975 | 109 |
+ '<h3><span class="Ldt-CreateAnnotation-h3Left">{{#show_title_field}}<input class="Ldt-CreateAnnotation-Title empty" placeholder="{{l10n.type_title}}" />{{/show_title_field}}' |
| 904 | 110 |
+ '{{^show_title_field}}<span class="Ldt-CreateAnnotation-NoTitle">{{l10n.no_title}} </span>{{/show_title_field}}' |
| 975 | 111 |
+ '<span class="Ldt-CreateAnnotation-Times"> {{#show_slice}}{{l10n.from_time}} {{/show_slice}}{{^show_slice}}{{l10n.at_time}} {{/show_slice}} <span class="Ldt-CreateAnnotation-Begin">00:00</span>' |
| 966 | 112 |
+ '{{#show_slice}} {{l10n.to_time}} <span class="Ldt-CreateAnnotation-End">{{end}}</span>{{/show_slice}}</span></span>' |
| 975 | 113 |
+ '{{#show_creator_field}}{{l10n.your_name_}} <input class="Ldt-CreateAnnotation-Creator empty" value="{{creator_name}}" /></h3>{{/show_creator_field}}' |
114 |
+ '<textarea class="Ldt-CreateAnnotation-Description empty" placeholder="{{l10n.type_description}}"></textarea>' |
|
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
115 |
+ '<div class="Ldt-CreateAnnotation-Avatar"><img src="{{creator_avatar}}" title="{{creator_name}}"></img></div>' |
| 904 | 116 |
+ '<input type="submit" class="Ldt-CreateAnnotation-Submit" value="{{l10n.submit}}" />' |
| 966 | 117 |
+ '{{#show_mic_record}}<div class="Ldt-CreateAnnotation-RecBlock"><div class="Ldt-CreateAnnotation-RecLabel">Add voice annotation</div>' |
118 |
+ ' <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="220" height="160">' |
|
119 |
+ ' <param name="movie" value="{{record_swf}}" />' |
|
120 |
+ ' <param name="quality" value="high" />' |
|
121 |
+ ' <param name="bgcolor" value="#ffffff" />' |
|
122 |
+ ' <param name="play" value="true" />' |
|
123 |
+ ' <param name="loop" value="true" />' |
|
124 |
+ ' <param name="wmode" value="transparent" />' |
|
125 |
+ ' <param name="scale" value="showall" />' |
|
126 |
+ ' <param name="menu" value="true" />' |
|
127 |
+ ' <param name="devicefont" value="false" />' |
|
128 |
+ ' <param name="salign" value="" />' |
|
129 |
+ ' <param name="allowScriptAccess" value="always" />' |
|
130 |
+ ' <param name="allowFullScreen" value="true" />' |
|
131 |
+ ' <param name="flashvars" value="playVisible={{show_mic_play}}">' |
|
132 |
+ ' <embed src="{{record_swf}}"" quality="high" bgcolor="#ffffff"' |
|
133 |
+ ' width="220" height="160" name="ExternalInterfaceExample" align="middle"' |
|
134 |
+ ' play="true" loop="false" quality="high" allowScriptAccess="always" ' |
|
135 |
+ ' type="application/x-shockwave-flash" allowFullScreen="true" wmode="transparent" ' |
|
136 |
+ ' flashvars="playVisible={{show_mic_play}}"' |
|
137 |
+ ' pluginspage="http://www.macromedia.com/go/getflashplayer">' |
|
138 |
+ ' </embed>' |
|
139 |
+ ' </object>' |
|
140 |
+ '</div>{{/show_mic_record}}' |
|
| 904 | 141 |
+ '{{#tags.length}}<div class="Ldt-CreateAnnotation-Tags"><div class="Ldt-CreateAnnotation-TagTitle">{{l10n.add_keywords_}}</div><ul class="Ldt-CreateAnnotation-TagList">' |
142 |
+ '{{#tags}}<li class="Ldt-CreateAnnotation-TagLi" tag-id="{{id}}"><span class="Ldt-CreateAnnotation-TagButton">{{title}}</span></li>{{/tags}}</ul></div>{{/tags.length}}' |
|
143 |
+ '{{#polemics.length}}<div class="Ldt-CreateAnnotation-Polemics"><div class="Ldt-CreateAnnotation-PolemicTitle">{{l10n.add_polemic_keywords_}}</div><ul class="Ldt-CreateAnnotation-PolemicList">' |
|
144 |
+ '{{#polemics}}<li class="Ldt-CreateAnnotation-PolemicLi" style="background-color: {{background_color}}; color: {{text_color}}">{{keyword}}</li>{{/polemics}}</ul></div>{{/polemics.length}}' |
|
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
145 |
+ '<div style="clear: both;"></div></form>' |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
146 |
+ '<div class="Ldt-CreateAnnotation-Screen Ldt-CreateAnnotation-Wait"><div class="Ldt-CreateAnnotation-InnerBox">{{l10n.wait_while_processing}}</div></div>' |
| 923 | 147 |
+ '<div class="Ldt-CreateAnnotation-Screen Ldt-CreateAnnotation-Error">{{^always_visible}}<a title="{{l10n.close_widget}}" class="Ldt-CreateAnnotation-Close" href="#"></a>{{/always_visible}}<div class="Ldt-CreateAnnotation-InnerBox">{{l10n.error_while_contacting}}</div></div>' |
148 |
+ '<div class="Ldt-CreateAnnotation-Screen Ldt-CreateAnnotation-Saved">{{^always_visible}}<a title="{{l10n.close_widget}}" class="Ldt-CreateAnnotation-Close" href="#"></a>{{/always_visible}}<div class="Ldt-CreateAnnotation-InnerBox">{{l10n.annotation_saved}}</div></div>' |
|
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
149 |
+ '</div></div>'; |
| 880 | 150 |
|
|
887
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
882
diff
changeset
|
151 |
IriSP.Widgets.CreateAnnotation.prototype.draw = function() { |
| 924 | 152 |
var _this = this; |
| 966 | 153 |
|
154 |
this.begin = new IriSP.Model.Time(); |
|
155 |
this.end = this.source.getDuration(); |
|
156 |
|
|
| 924 | 157 |
if (this.tag_titles && !this.tags) { |
158 |
this.tags = IriSP._(this.tag_titles).map(function(_tag_title) { |
|
159 |
var _tag, |
|
160 |
_tags = _this.source.getTags().searchByTitle(_tag_title); |
|
161 |
if (_tags.length) { |
|
162 |
_tag = _tags[0]; |
|
163 |
} else { |
|
164 |
_tag = new IriSP.Model.Tag(false, _this.source); |
|
165 |
_tag.title = _tag_title; |
|
166 |
} |
|
167 |
return _tag; |
|
168 |
}); |
|
169 |
} |
|
| 904 | 170 |
if (!this.tags) { |
171 |
this.tags = this.source.getTags() |
|
172 |
.sortBy(function (_tag) { |
|
173 |
return -_tag.getAnnotations().length; |
|
174 |
}) |
|
175 |
.slice(0, this.max_tags) |
|
176 |
.map(function(_tag) { |
|
177 |
return _tag; |
|
178 |
}); |
|
| 928 | 179 |
/* We have to use the map function because Mustache doesn't like our tags object */ |
| 904 | 180 |
} |
| 966 | 181 |
this.record_swf = IriSP.getLib("recordMicSwf"); |
|
887
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
882
diff
changeset
|
182 |
this.renderTemplate(); |
| 966 | 183 |
if (this.show_mic_record) { |
184 |
this.recorder = this.$.find("embed")[0]; |
|
185 |
|
|
186 |
window.setAudioUrl = function(_url) { |
|
187 |
_this.audio_url = _url; |
|
188 |
} |
|
189 |
} |
|
| 965 | 190 |
if (this.show_slice) { |
191 |
this.insertSubwidget( |
|
192 |
this.$.find(".Ldt-CreateAnnotation-Slice"), |
|
193 |
{ |
|
194 |
type: "Slice", |
|
195 |
show_arrow: this.show_arrow, |
|
196 |
annotation_type: this.slice_annotation_type, |
|
197 |
onBoundsChanged: function(_from, _to) { |
|
198 |
_this.begin = new IriSP.Model.Time(_from || 0); |
|
199 |
_this.end = new IriSP.Model.Time(_to || 0); |
|
200 |
_this.$.find(".Ldt-CreateAnnotation-Begin").html(_this.begin.toString()); |
|
201 |
_this.$.find(".Ldt-CreateAnnotation-End").html(_this.end.toString()); |
|
202 |
} |
|
203 |
}, |
|
204 |
"slice" |
|
205 |
); |
|
206 |
} else { |
|
207 |
if (this.show_arrow) { |
|
208 |
this.insertSubwidget(this.$.find(".Ldt-CreateAnnotation-Arrow"), {type: "Arrow"},"arrow"); |
|
209 |
} |
|
210 |
this.onMediaEvent("timeupdate", function(_time) { |
|
211 |
_this.begin = new IriSP.Model.Time(_time || 0); |
|
212 |
_this.end = new IriSP.Model.Time(_time || 0); |
|
213 |
_this.$.find(".Ldt-CreateAnnotation-Begin").html(_this.begin.toString()); |
|
214 |
if (_this.arrow) { |
|
215 |
_this.arrow.moveToTime(_time); |
|
216 |
} |
|
217 |
}); |
|
218 |
} |
|
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
219 |
this.$.find(".Ldt-CreateAnnotation-Close").click(function() { |
| 925 | 220 |
_this.close_after_send |
221 |
? _this.hide() |
|
222 |
: _this.showScreen("Main"); |
|
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
223 |
return false; |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
224 |
}); |
| 904 | 225 |
this.$.find(".Ldt-CreateAnnotation-TagLi, .Ldt-CreateAnnotation-PolemicLi").click(function() { |
226 |
_this.addKeyword(IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,'')); |
|
227 |
return false; |
|
228 |
}); |
|
| 970 | 229 |
this.$.find(".Ldt-CreateAnnotation-PolemicLi").each(function() { |
230 |
var _el = IriSP.jQuery(this), |
|
231 |
_kw = _el.text().replace(/(^\s+|\s+$)/g,''), |
|
232 |
_msg = _this.l10n["polemic" + _kw]; |
|
233 |
if (_msg) { |
|
234 |
_el.attr("title",_msg); |
|
235 |
} |
|
236 |
}); |
|
| 904 | 237 |
this.$.find(".Ldt-CreateAnnotation-Description").bind("change keyup input paste", this.functionWrapper("onDescriptionChange")); |
238 |
if (this.show_title_field) { |
|
239 |
this.$.find(".Ldt-CreateAnnotation-Title").bind("change keyup input paste", this.functionWrapper("onTitleChange")); |
|
240 |
} |
|
| 923 | 241 |
if (this.show_creator_field) { |
242 |
this.$.find(".Ldt-CreateAnnotation-Creator").bind("change keyup input paste", this.functionWrapper("onCreatorChange")); |
|
243 |
} |
|
| 904 | 244 |
|
| 923 | 245 |
if (this.start_visible) { |
246 |
this.show(); |
|
247 |
} else { |
|
248 |
this.$.hide(); |
|
249 |
this.hide(); |
|
250 |
} |
|
251 |
|
|
| 957 | 252 |
this.onMdpEvent("CreateAnnotation.toggle","toggle"); |
| 904 | 253 |
this.$.find("form").submit(this.functionWrapper("onSubmit")); |
254 |
} |
|
255 |
||
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
256 |
IriSP.Widgets.CreateAnnotation.prototype.showScreen = function(_screenName) { |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
257 |
this.$.find('.Ldt-CreateAnnotation-' + _screenName).show() |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
258 |
.siblings().hide(); |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
259 |
} |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
260 |
|
| 904 | 261 |
IriSP.Widgets.CreateAnnotation.prototype.show = function() { |
262 |
this.visible = true; |
|
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
263 |
this.showScreen('Main'); |
| 975 | 264 |
this.$.find(".Ldt-CreateAnnotation-Description").val("").css("border-color", "#666666").addClass("empty"); |
| 923 | 265 |
if (this.show_title_field) { |
| 975 | 266 |
this.$.find(".Ldt-CreateAnnotation-Title").val("").css("border-color", "#666666").addClass("empty"); |
| 923 | 267 |
} |
268 |
if (this.show_creator_field) { |
|
269 |
this.$.find(".Ldt-CreateAnnotation-Creator").val(this.creator_name).css("border-color", "#666666"); |
|
| 975 | 270 |
if (!this.creator_name) { |
271 |
this.$.find(".Ldt-CreateAnnotation-Creator").addClass("empty"); |
|
272 |
} |
|
| 923 | 273 |
} |
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
274 |
this.$.find(".Ldt-CreateAnnotation-TagLi, .Ldt-CreateAnnotation-PolemicLi").removeClass("selected"); |
| 904 | 275 |
this.$.slideDown(); |
| 923 | 276 |
if (this.minimize_annotation_widget) { |
| 957 | 277 |
this.player.trigger("Annotation.minimize"); |
| 923 | 278 |
} |
| 904 | 279 |
} |
280 |
||
281 |
IriSP.Widgets.CreateAnnotation.prototype.hide = function() { |
|
| 966 | 282 |
if (this.recorder) { |
283 |
this.recorder.stopRecord(); |
|
284 |
} |
|
| 923 | 285 |
if (!this.always_visible) { |
286 |
this.visible = false; |
|
287 |
this.$.slideUp(); |
|
288 |
if (this.minimize_annotation_widget) { |
|
| 957 | 289 |
this.player.trigger("Annotation.maximize"); |
| 923 | 290 |
} |
291 |
} |
|
| 904 | 292 |
} |
293 |
||
294 |
IriSP.Widgets.CreateAnnotation.prototype.toggle = function() { |
|
| 923 | 295 |
if (!this.always_visible) { |
296 |
if (this.visible) { |
|
297 |
this.hide(); |
|
298 |
} else { |
|
299 |
this.show(); |
|
300 |
} |
|
| 904 | 301 |
} |
302 |
} |
|
303 |
||
304 |
IriSP.Widgets.CreateAnnotation.prototype.addKeyword = function(_keyword) { |
|
305 |
var _field = this.$.find(".Ldt-CreateAnnotation-Description"), |
|
306 |
_rx = IriSP.Model.regexpFromTextOrArray(_keyword), |
|
307 |
_contents = _field.val(); |
|
| 925 | 308 |
_contents = ( !!_contents.match(_rx) |
| 904 | 309 |
? _contents.replace(_rx,"") |
310 |
: _contents + " " + _keyword |
|
311 |
); |
|
312 |
_field.val(_contents.replace(/\s{2,}/g,' ').replace(/(^\s+|\s+$)/g,'')); |
|
313 |
this.onDescriptionChange(); |
|
314 |
} |
|
315 |
||
| 923 | 316 |
IriSP.Widgets.CreateAnnotation.prototype.pauseOnWrite = function() { |
| 957 | 317 |
if (this.pause_on_write && !this.media.getPaused()) { |
318 |
this.media.pause(); |
|
| 923 | 319 |
} |
320 |
} |
|
321 |
||
| 904 | 322 |
IriSP.Widgets.CreateAnnotation.prototype.onDescriptionChange = function() { |
323 |
var _field = this.$.find(".Ldt-CreateAnnotation-Description"), |
|
324 |
_contents = _field.val(); |
|
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
325 |
_field.css("border-color", !!_contents ? "#666666" : "#ff0000"); |
| 975 | 326 |
if (!!_contents) { |
327 |
_field.removeClass("empty"); |
|
328 |
} else { |
|
329 |
_field.addClass("empty"); |
|
330 |
} |
|
| 904 | 331 |
this.$.find(".Ldt-CreateAnnotation-TagLi, .Ldt-CreateAnnotation-PolemicLi").each(function() { |
332 |
var _rx = IriSP.Model.regexpFromTextOrArray(IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,'')); |
|
| 925 | 333 |
if (_contents.match(_rx)) { |
| 904 | 334 |
IriSP.jQuery(this).addClass("selected"); |
335 |
} else { |
|
336 |
IriSP.jQuery(this).removeClass("selected"); |
|
337 |
} |
|
338 |
}); |
|
| 923 | 339 |
this.pauseOnWrite(); |
| 904 | 340 |
return !!_contents; |
341 |
} |
|
342 |
||
343 |
IriSP.Widgets.CreateAnnotation.prototype.onTitleChange = function() { |
|
344 |
var _field = this.$.find(".Ldt-CreateAnnotation-Title"), |
|
345 |
_contents = _field.val(); |
|
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
346 |
_field.css("border-color", !!_contents ? "#666666" : "#ff0000"); |
| 975 | 347 |
if (!!_contents) { |
348 |
_field.removeClass("empty"); |
|
349 |
} else { |
|
350 |
_field.addClass("empty"); |
|
351 |
} |
|
| 923 | 352 |
this.pauseOnWrite(); |
353 |
return !!_contents; |
|
354 |
} |
|
355 |
||
356 |
||
357 |
IriSP.Widgets.CreateAnnotation.prototype.onCreatorChange = function() { |
|
358 |
var _field = this.$.find(".Ldt-CreateAnnotation-Creator"), |
|
359 |
_contents = _field.val(); |
|
360 |
_field.css("border-color", !!_contents ? "#666666" : "#ff0000"); |
|
| 975 | 361 |
if (!!_contents) { |
362 |
_field.removeClass("empty"); |
|
363 |
} else { |
|
364 |
_field.addClass("empty"); |
|
365 |
} |
|
| 923 | 366 |
this.pauseOnWrite(); |
| 904 | 367 |
return !!_contents; |
368 |
} |
|
369 |
||
| 928 | 370 |
/* Fonction effectuant l'envoi des annotations */ |
| 904 | 371 |
IriSP.Widgets.CreateAnnotation.prototype.onSubmit = function() { |
| 928 | 372 |
/* Si les champs obligatoires sont vides, on annule l'envoi */ |
| 923 | 373 |
if (!this.onDescriptionChange() || (this.show_title_field && !this.onTitleChange()) || (this.show_creator_field && !this.onCreatorChange())) { |
| 970 | 374 |
return false; |
| 904 | 375 |
} |
376 |
|
|
| 966 | 377 |
if (this.recorder) { |
378 |
this.recorder.stopRecord(); |
|
379 |
} |
|
380 |
|
|
| 928 | 381 |
var _exportedAnnotations = new IriSP.Model.List(this.player.sourceManager), /* Création d'une liste d'annotations contenant une annotation afin de l'envoyer au serveur */ |
382 |
_export = this.player.sourceManager.newLocalSource({serializer: IriSP.serializers[this.api_serializer]}), /* Création d'un objet source utilisant un sérialiseur spécifique pour l'export */ |
|
383 |
_annotation = new IriSP.Model.Annotation(false, _export), /* Création d'une annotation dans cette source avec un ID généré à la volée (param. false) */ |
|
384 |
_annotationTypes = this.source.getAnnotationTypes().searchByTitle(this.annotation_type), /* Récupération du type d'annotation dans lequel l'annotation doit être ajoutée */ |
|
385 |
_annotationType = (_annotationTypes.length ? _annotationTypes[0] : new IriSP.Model.AnnotationType(false, _export)), /* Si le Type d'Annotation n'existe pas, il est créé à la volée */ |
|
386 |
_url = Mustache.to_html(this.api_endpoint_template, {id: this.source.projectId}); /* Génération de l'URL à laquelle l'annotation doit être envoyée, qui doit inclure l'ID du projet */ |
|
387 |
|
|
388 |
/* Si nous avons dû générer un ID d'annotationType à la volée... */ |
|
| 915 | 389 |
if (!_annotationTypes.length) { |
| 928 | 390 |
/* Il ne faudra pas envoyer l'ID généré au serveur */ |
| 915 | 391 |
_annotationType.dont_send_id = true; |
| 928 | 392 |
/* Il faut inclure le titre dans le type d'annotation */ |
393 |
_annotationType.title = this.annotation_type; |
|
| 915 | 394 |
} |
395 |
|
|
| 928 | 396 |
/* |
397 |
* Nous remplissons les données de l'annotation générée à la volée |
|
398 |
* ATTENTION: Si nous sommes sur un MASHUP, ces éléments doivent se référer AU MEDIA D'ORIGINE |
|
399 |
* */ |
|
400 |
_annotation.setBegin(this.begin); /*Timecode de début */ |
|
401 |
_annotation.setEnd(this.end); /* Timecode de fin */ |
|
402 |
_annotation.setMedia(this.source.currentMedia.id); /* Id du média annoté */ |
|
403 |
|
|
404 |
_annotation.setAnnotationType(_annotationType.id); /* Id du type d'annotation */ |
|
| 904 | 405 |
if (this.show_title_field) { |
| 928 | 406 |
/* Champ titre, seulement s'il est visible */ |
| 923 | 407 |
_annotation.title = this.$.find(".Ldt-CreateAnnotation-Title").val(); |
| 904 | 408 |
} |
| 928 | 409 |
_annotation.created = new Date(); /* Date de création de l'annotation */ |
410 |
_annotation.description = this.$.find(".Ldt-CreateAnnotation-Description").val(); /* Champ description */ |
|
411 |
_annotation.setTags(this.$.find(".Ldt-CreateAnnotation-TagLi.selected") |
|
412 |
.map(function() { return IriSP.jQuery(this).attr("tag-id")})); /*Liste des ids de tags */ |
|
| 966 | 413 |
if (this.audio_url) { |
414 |
_annotation.audio = { |
|
415 |
src: "mic", |
|
416 |
mimetype: "audio/mp3", |
|
417 |
href: this.audio_url |
|
418 |
}; |
|
419 |
} |
|
| 923 | 420 |
if (this.show_creator_field) { |
| 974 | 421 |
_annotation.creator = this.$.find(".Ldt-CreateAnnotation-Creator").val(); |
| 923 | 422 |
} else { |
| 974 | 423 |
_annotation.creator = this.creator_name; |
| 923 | 424 |
} |
| 928 | 425 |
_exportedAnnotations.push(_annotation); /* Ajout de l'annotation à la liste à exporter */ |
426 |
_export.addList("annotation",_exportedAnnotations); /* Ajout de la liste à exporter à l'objet Source */ |
|
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
427 |
|
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
428 |
var _this = this; |
| 928 | 429 |
/* Envoi de l'annotation via AJAX au serveur ! */ |
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
430 |
IriSP.jQuery.ajax({ |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
431 |
url: _url, |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
432 |
type: this.api_method, |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
433 |
contentType: 'application/json', |
| 928 | 434 |
data: _export.serialize(), /* L'objet Source est sérialisé */ |
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
435 |
success: function(_data) { |
| 928 | 436 |
_this.showScreen('Saved'); /* Si l'appel a fonctionné, on affiche l'écran "Annotation enregistrée" */ |
437 |
if (_this.after_send_timeout) { /* Selon les options de configuration, on revient à l'écran principal ou on ferme le widget, ou rien */ |
|
| 925 | 438 |
window.setTimeout( |
439 |
function() { |
|
440 |
_this.close_after_send |
|
441 |
? _this.hide() |
|
| 975 | 442 |
: _this.show(); |
| 925 | 443 |
}, |
444 |
_this.after_send_timeout |
|
445 |
); |
|
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
446 |
} |
| 928 | 447 |
_export.getAnnotations().removeElement(_annotation, true); /* Pour éviter les doublons, on supprime l'annotation qui a été envoyée */ |
448 |
_export.deSerialize(_data); /* On désérialise les données reçues pour les réinjecter */ |
|
449 |
_this.source.merge(_export); /* On récupère les données réimportées dans l'espace global des données */ |
|
| 957 | 450 |
if (_this.pause_on_write && _this.media.getPaused()) { |
451 |
_this.media.play(); |
|
| 923 | 452 |
} |
| 957 | 453 |
_this.player.trigger("AnnotationsList.refresh"); /* On force le rafraîchissement du widget AnnotationsList */ |
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
454 |
}, |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
455 |
error: function(_xhr, _error, _thrown) { |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
456 |
IriSP.log("Error when sending annotation", _thrown); |
| 916 | 457 |
_export.getAnnotations().removeElement(_annotation, true); |
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
458 |
_this.showScreen('Error'); |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
459 |
window.setTimeout(function(){ |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
460 |
_this.showScreen("Main") |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
461 |
}, |
| 925 | 462 |
(_this.after_send_timeout || 5000)); |
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
463 |
} |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
464 |
}); |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
465 |
this.showScreen('Wait'); |
| 904 | 466 |
|
467 |
return false; |
|
|
887
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
882
diff
changeset
|
468 |
} |
| 880 | 469 |