| author | veltr |
| Thu, 05 Jul 2012 19:08:13 +0200 | |
| branch | new-model |
| changeset 924 | 64c2eaafe5e2 |
| parent 923 | b3ee7d1b472a |
| child 925 | 28efc97b5d78 |
| permissions | -rw-r--r-- |
| 923 | 1 |
/* TODO: Add Social Network Sharing, Finish Current Timecode Sync & Arrow Takeover */ |
|
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 = { |
|
| 923 | 10 |
show_title_field : false, /* For the moment, titles can't be sent to ldtplatform */ |
11 |
show_creator_field : true, |
|
12 |
start_visible : true, |
|
| 924 | 13 |
always_visible : false, |
| 923 | 14 |
sync_on_slice_widget : true, /* If false, syncs on current timecode */ |
15 |
takeover_arrow : false, |
|
| 924 | 16 |
minimize_annotation_widget : true, |
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
17 |
creator_name : "", |
| 924 | 18 |
creator_avatar : "", |
| 904 | 19 |
tags : false, |
| 924 | 20 |
tag_titles : false, |
| 923 | 21 |
pause_on_write : true, |
| 904 | 22 |
max_tags : 8, |
23 |
polemics : [{ |
|
24 |
keyword: "++", |
|
25 |
background_color: "#00a000", |
|
26 |
text_color: "#ffffff" |
|
27 |
},{ |
|
28 |
keyword: "--", |
|
29 |
background_color: "#c00000", |
|
30 |
text_color: "#ffffff" |
|
31 |
},{ |
|
32 |
keyword: "??", |
|
33 |
background_color: "#0000e0", |
|
34 |
text_color: "#ffffff" |
|
35 |
},{ |
|
36 |
keyword: "==", |
|
37 |
background_color: "#f0e000", |
|
38 |
text_color: "#000000" |
|
39 |
}], |
|
40 |
annotation_type: "Contributions", |
|
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
41 |
api_serializer: "ldt_annotate", |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
42 |
api_endpoint_template: "", |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
43 |
api_method: "PUT", |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
44 |
close_widget_timeout: 0 |
| 880 | 45 |
} |
46 |
||
47 |
IriSP.Widgets.CreateAnnotation.prototype.messages = { |
|
| 882 | 48 |
en: { |
49 |
from_time: "from", |
|
50 |
to_time: "to", |
|
| 923 | 51 |
at_time: "at", |
| 882 | 52 |
submit: "Submit", |
| 904 | 53 |
add_keywords_: "Add keywords:", |
54 |
add_polemic_keywords_: "Add polemic keywords:", |
|
| 923 | 55 |
your_name_: "Your name:", |
| 882 | 56 |
no_title: "Annotate this video", |
57 |
type_title: "Annotation title", |
|
58 |
type_description: "Type the full description of your annotation here.", |
|
59 |
wait_while_processing: "Please wait while your request is being processed...", |
|
60 |
error_while_contacting: "An error happened while contacting the server. Your annotation has not been saved.", |
|
61 |
empty_annotation: "Your annotation is empty. Please write something before submitting.", |
|
62 |
annotation_saved: "Thank you, your annotation has been saved.", |
|
63 |
share_annotation: "Would you like to share it on social networks ?", |
|
64 |
share_on: "Share on", |
|
65 |
more_tags: "More tags", |
|
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
66 |
cancel: "Cancel", |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
67 |
close_widget: "Cacher la zone de création d'annotations" |
| 880 | 68 |
}, |
| 882 | 69 |
fr: { |
| 904 | 70 |
from_time: "de", |
| 882 | 71 |
to_time: "Ã ", |
| 923 | 72 |
at_time: "Ã ", |
| 882 | 73 |
submit: "Envoyer", |
| 904 | 74 |
add_keywords_: "Ajouter des mots-clés :", |
75 |
add_polemic_keywords_: "Ajouter des mots-clés polémiques :", |
|
| 923 | 76 |
your_name_: "Votre nom :", |
| 882 | 77 |
no_title: "Annoter cette vidéo", |
78 |
type_title: "Titre de l'annotation", |
|
79 |
type_description: "Rédigez le contenu de votre annotation ici.", |
|
80 |
wait_while_processing: "Veuillez patienter pendant le traitement de votre requête...", |
|
81 |
error_while_contacting: "Une erreur s'est produite en contactant le serveur. Votre annotation n'a pas été enregistrée", |
|
82 |
empty_annotation: "Votre annotation est vide. Merci de rédiger un texte avant de l'envoyer.", |
|
83 |
annotation_saved: "Merci, votre annotation a été enregistrée.", |
|
84 |
share_annotation: "Souhaitez-vous la partager sur les réseaux sociaux ?", |
|
85 |
share_on: "Partager sur", |
|
86 |
more_tags: "Plus de mots-clés", |
|
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
87 |
cancel: "Cancel", |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
88 |
close_widget: "Hide the annotation creating block" |
| 880 | 89 |
} |
90 |
} |
|
91 |
||
92 |
IriSP.Widgets.CreateAnnotation.prototype.template = |
|
| 881 | 93 |
'<div class="Ldt-CreateAnnotation"><div class="Ldt-CreateAnnotation-Inner">' |
94 |
+ '<form class="Ldt-CreateAnnotation-Screen Ldt-CreateAnnotation-Main">' |
|
| 924 | 95 |
+ '<h3><span class="Ldt-CreateAnnotation-h3Left">{{#show_title_field}}<input class="Ldt-CreateAnnotation-Title" placeholder="{{l10n.type_title}}" />{{/show_title_field}}' |
| 904 | 96 |
+ '{{^show_title_field}}<span class="Ldt-CreateAnnotation-NoTitle">{{l10n.no_title}} </span>{{/show_title_field}}' |
| 923 | 97 |
+ ' <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>' |
| 924 | 98 |
+ '{{#sync_on_slice_widget}} {{l10n.to_time}} <span class="Ldt-CreateAnnotation-End">00:00</span>{{/sync_on_slice_widget}}</span></span>' |
99 |
+ '{{#show_creator_field}}{{l10n.your_name_}} <input class="Ldt-CreateAnnotation-Creator" value="{{creator_name}}" /></h3>{{/show_creator_field}}' |
|
| 904 | 100 |
+ '<textarea class="Ldt-CreateAnnotation-Description" placeholder="{{l10n.type_description}}"></textarea>' |
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
101 |
+ '<div class="Ldt-CreateAnnotation-Avatar"><img src="{{creator_avatar}}" title="{{creator_name}}"></img></div>' |
| 904 | 102 |
+ '<input type="submit" class="Ldt-CreateAnnotation-Submit" value="{{l10n.submit}}" />' |
103 |
+ '{{#tags.length}}<div class="Ldt-CreateAnnotation-Tags"><div class="Ldt-CreateAnnotation-TagTitle">{{l10n.add_keywords_}}</div><ul class="Ldt-CreateAnnotation-TagList">' |
|
104 |
+ '{{#tags}}<li class="Ldt-CreateAnnotation-TagLi" tag-id="{{id}}"><span class="Ldt-CreateAnnotation-TagButton">{{title}}</span></li>{{/tags}}</ul></div>{{/tags.length}}' |
|
105 |
+ '{{#polemics.length}}<div class="Ldt-CreateAnnotation-Polemics"><div class="Ldt-CreateAnnotation-PolemicTitle">{{l10n.add_polemic_keywords_}}</div><ul class="Ldt-CreateAnnotation-PolemicList">' |
|
106 |
+ '{{#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
|
107 |
+ '<div style="clear: both;"></div></form>' |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
108 |
+ '<div class="Ldt-CreateAnnotation-Screen Ldt-CreateAnnotation-Wait"><div class="Ldt-CreateAnnotation-InnerBox">{{l10n.wait_while_processing}}</div></div>' |
| 923 | 109 |
+ '<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>' |
110 |
+ '<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
|
111 |
+ '</div></div>'; |
| 880 | 112 |
|
|
887
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
882
diff
changeset
|
113 |
IriSP.Widgets.CreateAnnotation.prototype.draw = function() { |
| 924 | 114 |
var _this = this; |
115 |
if (this.tag_titles && !this.tags) { |
|
116 |
this.tags = IriSP._(this.tag_titles).map(function(_tag_title) { |
|
117 |
var _tag, |
|
118 |
_tags = _this.source.getTags().searchByTitle(_tag_title); |
|
119 |
if (_tags.length) { |
|
120 |
_tag = _tags[0]; |
|
121 |
} else { |
|
122 |
_tag = new IriSP.Model.Tag(false, _this.source); |
|
123 |
_tag.title = _tag_title; |
|
124 |
} |
|
125 |
return _tag; |
|
126 |
}); |
|
127 |
} |
|
| 904 | 128 |
if (!this.tags) { |
129 |
this.tags = this.source.getTags() |
|
130 |
.sortBy(function (_tag) { |
|
131 |
return -_tag.getAnnotations().length; |
|
132 |
}) |
|
133 |
.slice(0, this.max_tags) |
|
134 |
.map(function(_tag) { |
|
135 |
return _tag; |
|
136 |
}); |
|
137 |
// We have to use the map function because Mustache doesn't like our tags object |
|
138 |
} |
|
|
887
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
882
diff
changeset
|
139 |
this.renderTemplate(); |
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
140 |
this.$.find(".Ldt-CreateAnnotation-Close").click(function() { |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
141 |
_this.hide(); |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
142 |
return false; |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
143 |
}); |
| 904 | 144 |
this.$.find(".Ldt-CreateAnnotation-TagLi, .Ldt-CreateAnnotation-PolemicLi").click(function() { |
145 |
_this.addKeyword(IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,'')); |
|
146 |
return false; |
|
147 |
}); |
|
148 |
this.$.find(".Ldt-CreateAnnotation-Description").bind("change keyup input paste", this.functionWrapper("onDescriptionChange")); |
|
149 |
if (this.show_title_field) { |
|
150 |
this.$.find(".Ldt-CreateAnnotation-Title").bind("change keyup input paste", this.functionWrapper("onTitleChange")); |
|
151 |
} |
|
| 923 | 152 |
if (this.show_creator_field) { |
153 |
this.$.find(".Ldt-CreateAnnotation-Creator").bind("change keyup input paste", this.functionWrapper("onCreatorChange")); |
|
154 |
} |
|
| 904 | 155 |
|
| 923 | 156 |
if (this.start_visible) { |
157 |
this.show(); |
|
158 |
} else { |
|
159 |
this.$.hide(); |
|
160 |
this.hide(); |
|
161 |
} |
|
162 |
|
|
| 904 | 163 |
this.bindPopcorn("IriSP.CreateAnnotation.toggle","toggle"); |
164 |
this.bindPopcorn("IriSP.Slice.boundsChanged","onBoundsChanged"); |
|
165 |
this.begin = new IriSP.Model.Time(); |
|
166 |
this.end = this.source.getDuration(); |
|
167 |
this.$.find("form").submit(this.functionWrapper("onSubmit")); |
|
168 |
} |
|
169 |
||
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
170 |
IriSP.Widgets.CreateAnnotation.prototype.showScreen = function(_screenName) { |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
171 |
this.$.find('.Ldt-CreateAnnotation-' + _screenName).show() |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
172 |
.siblings().hide(); |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
173 |
} |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
174 |
|
| 904 | 175 |
IriSP.Widgets.CreateAnnotation.prototype.show = function() { |
176 |
this.visible = true; |
|
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
177 |
this.showScreen('Main'); |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
178 |
this.$.find(".Ldt-CreateAnnotation-Description").val("").css("border-color", "#666666"); |
| 923 | 179 |
if (this.show_title_field) { |
180 |
this.$.find(".Ldt-CreateAnnotation-Title").val("").css("border-color", "#666666"); |
|
181 |
} |
|
182 |
if (this.show_creator_field) { |
|
183 |
this.$.find(".Ldt-CreateAnnotation-Creator").val(this.creator_name).css("border-color", "#666666"); |
|
184 |
} |
|
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
185 |
this.$.find(".Ldt-CreateAnnotation-TagLi, .Ldt-CreateAnnotation-PolemicLi").removeClass("selected"); |
| 904 | 186 |
this.$.slideDown(); |
| 923 | 187 |
if (this.minimize_annotation_widget) { |
188 |
this.player.popcorn.trigger("IriSP.Annotation.minimize"); |
|
189 |
} |
|
| 904 | 190 |
this.player.popcorn.trigger("IriSP.Slice.show"); |
191 |
} |
|
192 |
||
193 |
IriSP.Widgets.CreateAnnotation.prototype.hide = function() { |
|
| 923 | 194 |
if (!this.always_visible) { |
195 |
this.visible = false; |
|
196 |
this.$.slideUp(); |
|
197 |
if (this.minimize_annotation_widget) { |
|
198 |
this.player.popcorn.trigger("IriSP.Annotation.maximize"); |
|
199 |
} |
|
200 |
this.player.popcorn.trigger("IriSP.Slice.hide"); |
|
201 |
} |
|
| 904 | 202 |
} |
203 |
||
204 |
IriSP.Widgets.CreateAnnotation.prototype.toggle = function() { |
|
| 923 | 205 |
if (!this.always_visible) { |
206 |
if (this.visible) { |
|
207 |
this.hide(); |
|
208 |
} else { |
|
209 |
this.show(); |
|
210 |
} |
|
| 904 | 211 |
} |
212 |
} |
|
213 |
||
214 |
IriSP.Widgets.CreateAnnotation.prototype.onBoundsChanged = function(_values) { |
|
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
215 |
this.begin = new IriSP.Model.Time(_values[0] || 0); |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
216 |
this.end = new IriSP.Model.Time(_values[1] || 0); |
| 904 | 217 |
this.$.find(".Ldt-CreateAnnotation-Begin").html(this.begin.toString()); |
218 |
this.$.find(".Ldt-CreateAnnotation-End").html(this.end.toString()); |
|
219 |
} |
|
220 |
||
221 |
IriSP.Widgets.CreateAnnotation.prototype.addKeyword = function(_keyword) { |
|
222 |
var _field = this.$.find(".Ldt-CreateAnnotation-Description"), |
|
223 |
_rx = IriSP.Model.regexpFromTextOrArray(_keyword), |
|
224 |
_contents = _field.val(); |
|
225 |
_contents = ( _rx.test(_contents) |
|
226 |
? _contents.replace(_rx,"") |
|
227 |
: _contents + " " + _keyword |
|
228 |
); |
|
229 |
_field.val(_contents.replace(/\s{2,}/g,' ').replace(/(^\s+|\s+$)/g,'')); |
|
230 |
this.onDescriptionChange(); |
|
231 |
} |
|
232 |
||
| 923 | 233 |
IriSP.Widgets.CreateAnnotation.prototype.pauseOnWrite = function() { |
234 |
if (this.pause_on_write && !this.player.popcorn.media.paused) { |
|
235 |
this.player.popcorn.pause(); |
|
236 |
} |
|
237 |
} |
|
238 |
||
| 904 | 239 |
IriSP.Widgets.CreateAnnotation.prototype.onDescriptionChange = function() { |
240 |
var _field = this.$.find(".Ldt-CreateAnnotation-Description"), |
|
241 |
_contents = _field.val(); |
|
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
242 |
_field.css("border-color", !!_contents ? "#666666" : "#ff0000"); |
| 904 | 243 |
this.$.find(".Ldt-CreateAnnotation-TagLi, .Ldt-CreateAnnotation-PolemicLi").each(function() { |
244 |
var _rx = IriSP.Model.regexpFromTextOrArray(IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,'')); |
|
245 |
if (_rx.test(_contents)) { |
|
246 |
IriSP.jQuery(this).addClass("selected"); |
|
247 |
} else { |
|
248 |
IriSP.jQuery(this).removeClass("selected"); |
|
249 |
} |
|
250 |
}); |
|
| 923 | 251 |
this.pauseOnWrite(); |
| 904 | 252 |
return !!_contents; |
253 |
} |
|
254 |
||
255 |
IriSP.Widgets.CreateAnnotation.prototype.onTitleChange = function() { |
|
256 |
var _field = this.$.find(".Ldt-CreateAnnotation-Title"), |
|
257 |
_contents = _field.val(); |
|
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
258 |
_field.css("border-color", !!_contents ? "#666666" : "#ff0000"); |
| 923 | 259 |
this.pauseOnWrite(); |
260 |
return !!_contents; |
|
261 |
} |
|
262 |
||
263 |
||
264 |
IriSP.Widgets.CreateAnnotation.prototype.onCreatorChange = function() { |
|
265 |
var _field = this.$.find(".Ldt-CreateAnnotation-Creator"), |
|
266 |
_contents = _field.val(); |
|
267 |
_field.css("border-color", !!_contents ? "#666666" : "#ff0000"); |
|
268 |
this.pauseOnWrite(); |
|
| 904 | 269 |
return !!_contents; |
270 |
} |
|
271 |
||
272 |
IriSP.Widgets.CreateAnnotation.prototype.onSubmit = function() { |
|
| 923 | 273 |
if (!this.onDescriptionChange() || (this.show_title_field && !this.onTitleChange()) || (this.show_creator_field && !this.onCreatorChange())) { |
| 904 | 274 |
return; |
275 |
} |
|
276 |
|
|
277 |
var _exportedAnnotations = new IriSP.Model.List(this.player.sourceManager); |
|
278 |
_export = this.player.sourceManager.newLocalSource({serializer: IriSP.serializers[this.api_serializer]}), |
|
279 |
_annotation = new IriSP.Model.Annotation(false, _export), |
|
| 915 | 280 |
_annotationTypes = this.source.getAnnotationTypes().searchByTitle(this.annotation_type), |
281 |
_annotationType = (_annotationTypes.length ? _annotationTypes[0] : new IriSP.Model.AnnotationType(false, _export)), |
|
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
282 |
_url = Mustache.to_html(this.api_endpoint_template, {id: this.source.projectId}); |
| 904 | 283 |
|
| 915 | 284 |
if (!_annotationTypes.length) { |
285 |
_annotationType.dont_send_id = true; |
|
286 |
} |
|
287 |
|
|
| 904 | 288 |
_annotationType.title = this.annotation_type; |
289 |
_annotation.setBegin(this.begin); |
|
290 |
_annotation.setEnd(this.end); |
|
291 |
_annotation.setMedia(this.source.currentMedia.id); |
|
292 |
_annotation.setAnnotationType(_annotationType.id); |
|
293 |
if (this.show_title_field) { |
|
| 923 | 294 |
_annotation.title = this.$.find(".Ldt-CreateAnnotation-Title").val(); |
| 904 | 295 |
} |
296 |
_annotation.created = new Date(); |
|
297 |
_annotation.description = this.$.find(".Ldt-CreateAnnotation-Description").val(); |
|
298 |
_annotation.setTags(this.$.find(".Ldt-CreateAnnotation-TagLi.selected").map(function() { return IriSP.jQuery(this).attr("tag-id")})); |
|
299 |
|
|
| 923 | 300 |
if (this.show_creator_field) { |
301 |
_export.creator = this.$.find(".Ldt-CreateAnnotation-Creator").val(); |
|
302 |
} else { |
|
303 |
_export.creator = this.creator_name; |
|
304 |
} |
|
| 904 | 305 |
_export.created = new Date(); |
306 |
_exportedAnnotations.push(_annotation); |
|
307 |
_export.addList("annotation",_exportedAnnotations); |
|
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
308 |
|
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
309 |
var _this = this; |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
310 |
IriSP.jQuery.ajax({ |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
311 |
url: _url, |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
312 |
type: this.api_method, |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
313 |
contentType: 'application/json', |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
314 |
data: _export.serialize(), |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
315 |
success: function(_data) { |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
316 |
_this.showScreen('Saved'); |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
317 |
if (_this.close_widget_timeout) { |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
318 |
window.setTimeout(_this.functionWrapper("hide"),_this.close_widget_timeout); |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
319 |
} |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
320 |
_export.getAnnotations().removeElement(_annotation, true); |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
321 |
_export.deSerialize(_data); |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
322 |
_this.source.merge(_export); |
| 923 | 323 |
if (this.pause_on_write && this.player.popcorn.media.paused) { |
324 |
this.player.popcorn.play(); |
|
325 |
} |
|
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
326 |
_this.player.popcorn.trigger("IriSP.AnnotationsList.refresh"); |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
327 |
}, |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
328 |
error: function(_xhr, _error, _thrown) { |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
329 |
IriSP.log("Error when sending annotation", _thrown); |
| 916 | 330 |
_export.getAnnotations().removeElement(_annotation, true); |
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
331 |
_this.showScreen('Error'); |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
332 |
window.setTimeout(function(){ |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
333 |
_this.showScreen("Main") |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
334 |
}, |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
335 |
(_this.close_widget_timeout || 5000)); |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
336 |
} |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
337 |
}); |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
338 |
this.showScreen('Wait'); |
| 904 | 339 |
|
340 |
return false; |
|
|
887
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
882
diff
changeset
|
341 |
} |
| 880 | 342 |