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