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