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