| author | veltr |
| Fri, 16 Nov 2012 19:23:20 +0100 | |
| changeset 43 | 5a5024bc74e6 |
| parent 42 | 40909e8d6855 |
| child 45 | f39df810caab |
| permissions | -rw-r--r-- |
| 32 | 1 |
|
2 |
IriSP.hc_messages = { |
|
| 39 | 3 |
Duration_ : "Durée :", |
4 |
duration_ : "durée :", |
|
| 32 | 5 |
edit_segment: "Éditer le segment", |
6 |
segment_down: "Descendre le segment", |
|
7 |
segment_up: "Remonter le segment", |
|
| 39 | 8 |
delete_segment: "Supprimer le segment", |
9 |
clone_segment: "Cloner le segment", |
|
10 |
From_: "De :", |
|
11 |
to_: "à :", |
|
12 |
segment_title_placeholder: "Segment sans titre", |
|
| 43 | 13 |
mashup_title_placeholder: "Hashcut sans titre", |
14 |
copy_of_: "Copie de ", |
|
| 32 | 15 |
} |
16 |
||
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
17 |
IriSP.editor = function(options) { |
| 32 | 18 |
|
| 22 | 19 |
/* Load Media List */ |
20 |
|
|
21 |
var directory = new IriSP.Model.Directory(), |
|
| 42 | 22 |
apidirectory = new IriSP.Model.Directory(), |
| 22 | 23 |
project = directory.remoteSource({ |
| 27 | 24 |
url: options.url, |
| 22 | 25 |
serializer: IriSP.serializers.medialist |
26 |
}), |
|
| 25 | 27 |
mashup = new IriSP.Model.Mashup(false, project), |
| 43 | 28 |
mediatemplate = _.template('<li class="item-video media" data-media-id="<%= id %>"><div class="media-count-wrap"><span class="media-count"></span></div>' |
29 |
+ '<img src="<%= thumbnail %>" alt="<%= title %>" />' |
|
30 |
+ '<div class="video-info"><h3 class="title-video"><%= title %></h3><p class="description"><%= description %></p>' |
|
31 |
+ '<p class="time-length"><%= IriSP.hc_messages.Duration_ %> <span><%= duration.toString() %></span></p></div></li>'), |
|
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
32 |
segmenttemplate = _.template('<li class="item-video annotation" data-segment-id="<%= annotation.id %>" data-media-id="<%= annotation.getMedia().id %>">' |
| 43 | 33 |
+ '<img src="<%= annotation.thumbnail %>" alt="<%= annotation.getMedia().title %>" />' |
34 |
+ '<div class="validate <%= annotation.status %>"><div class="validate-tooltip"><ul><li><%= annotation.status_messages.join("</li><li>") %></li></ul></div></div><div class="video-info"><h3 class="title-video"><%= annotation.getMedia().title %></h3>' |
|
35 |
+ '<p class="subtitle"><%= annotation.title %></p><p class="duration"><%= annotation.begin.toString() %> - <%= annotation.end.toString() %> (<%= annotation.getDuration().toString() %>)</p>' |
|
| 32 | 36 |
+ '<ul class="tools"><li><a class="edit" href="#" title="<%= IriSP.hc_messages.edit_segment %>"></a></li><li><a class="bottom" href="#" title="<%= IriSP.hc_messages.segment_down %>"></a></li>' |
| 43 | 37 |
+ '<li><a class="top" href="#" title="<%= IriSP.hc_messages.segment_up %>"></a></li><li><a class="delete" href="#" title="<%= IriSP.hc_messages.delete_segment %>"></a></li></ul></div></li>'), |
| 29 | 38 |
mediasegmenttemplate = _.template('<div class="media-segments-list"><div class="media-segment">' |
| 43 | 39 |
+ '<div class="media-section media-segment-section" style="left:<%= left %>px; width:<%= width %>px; background:<%= color %>"></div>' |
| 29 | 40 |
+ '<div class="media-section media-current-section" style="left:<%= currentleft %>px; width:<%= currentwidth %>px;"><div class="media-current-section-inner"></div></div>' |
41 |
+ '<div class="popin media-segment-popin" style="left:<%= popleft %>px"><img style="left:<%= pointerpos %>px;" class="pointer" src="img/popin-triangle.png" alt="" /><div class="popin-content">' |
|
| 39 | 42 |
+ '<h3><%= annotation.title %></h3><a href="#" class="button reprendre-segment" data-segment-id="<%= annotation.id %>"><%= IriSP.hc_messages.clone_segment %></a>' |
43 |
+ '<p><%= IriSP.hc_messages.From_ %> <span><%= annotation.begin.toString() %></span> <%= IriSP.hc_messages.to_ %> <span><%= annotation.end.toString() %></span> (<%= IriSP.hc_messages.duration_ %> <span><%= annotation.getDuration().toString() %></span>)</p>' |
|
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
44 |
+ '</div></div></div></div>'), |
| 43 | 45 |
mashupstatus = '', |
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
46 |
addMode, currentMedia, currentSegment; |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
47 |
|
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
48 |
IriSP.mashupcore(project, mashup); |
| 39 | 49 |
|
50 |
/* Validation of segments and mashup */ |
|
51 |
|
|
52 |
var segmentcritical = [ |
|
53 |
{ |
|
54 |
validate: function(_s) { |
|
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
55 |
return (_s.getDuration() >= 1000); |
| 39 | 56 |
}, |
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
57 |
message: "Le segment doit durer au moins une seconde" |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
58 |
}, |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
59 |
{ |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
60 |
validate: function(_s) { |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
61 |
return (_s.getDuration() < 180000); |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
62 |
}, |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
63 |
message: "Le segment doit durer moins de trois minutes" |
| 39 | 64 |
}, |
65 |
{ |
|
66 |
validate: function(_s) { |
|
67 |
return (!!_s.title && _s.title !== IriSP.hc_messages.segment_title_placeholder); |
|
68 |
}, |
|
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
69 |
message: "Le segment doit avoir un titre" |
| 39 | 70 |
} |
71 |
]; |
|
72 |
var segmentwarning = [ |
|
73 |
{ |
|
74 |
validate: function(_s) { |
|
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
75 |
return (!!_s.description); |
| 39 | 76 |
}, |
77 |
message: "Il est recommandé de donner une description au segment" |
|
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
78 |
}, |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
79 |
{ |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
80 |
validate: function(_s) { |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
81 |
return (!!_s.keywords.length); |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
82 |
}, |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
83 |
message: "Il est recommandé de tagguer le segment" |
| 39 | 84 |
} |
85 |
]; |
|
86 |
|
|
87 |
var mashupcritical = [ |
|
88 |
{ |
|
89 |
validate: function(_m) { |
|
90 |
return _m.segments.length > 2; |
|
91 |
}, |
|
92 |
message: "Un hashcut doit être composé d'au moins trois segments" |
|
93 |
}, |
|
94 |
{ |
|
95 |
validate: function(_m) { |
|
96 |
return (!!_m.title && _m.title !== IriSP.hc_messages.mashup_title_placeholder); |
|
97 |
}, |
|
98 |
message: "Un titre doit être donné au hashcut" |
|
99 |
} |
|
100 |
]; |
|
101 |
var mashupwarning = [ |
|
102 |
{ |
|
103 |
validate: function(_m) { |
|
104 |
return !!_m.description |
|
105 |
}, |
|
106 |
message: "Il est recommandé de donner une description au hashcut" |
|
107 |
} |
|
108 |
]; |
|
| 22 | 109 |
|
110 |
/* Fill left column with Media List */ |
|
| 25 | 111 |
|
| 22 | 112 |
project.onLoad(function() { |
113 |
var html = ''; |
|
114 |
project.getMedias().forEach(function(_m) { |
|
| 27 | 115 |
html += mediatemplate(_m); |
| 13 | 116 |
}); |
| 22 | 117 |
$(".col-left .list-video").html(html); |
| 43 | 118 |
project.getMedias().forEach(function(_m) { |
119 |
/* var dataType = (IriSP.Model.isLocalURL(options.segment_api_endpoint) ? "json" : "jsonp"); |
|
120 |
$.ajax({ |
|
121 |
url: , |
|
122 |
dataType: dataType, |
|
123 |
data: { |
|
124 |
format: dataType, |
|
125 |
iri_id: _m.id |
|
126 |
}, |
|
127 |
success: function(data) { |
|
128 |
console.log(data); |
|
129 |
if (data.objects && data.objects.length) { |
|
130 |
var mediaid = data.objects[0].iri_id; |
|
131 |
mediasegmentscache[mediaid] = data.objects; |
|
132 |
if (currentMedia && mediaid === currentMedia.id && currentSegment) { |
|
133 |
showOtherSegments(); |
|
134 |
} |
|
135 |
} |
|
136 |
} |
|
137 |
}); */ |
|
138 |
apidirectory.remoteSource({ |
|
139 |
url: options.segment_api_endpoint, |
|
140 |
url_params: { |
|
141 |
iri_id: _m.id, |
|
142 |
limit: 0 |
|
143 |
}, |
|
144 |
serializer: IriSP.serializers.segmentapi |
|
145 |
}).onLoad(function() { |
|
146 |
var medias = this.getMedias(), |
|
147 |
annotations = this.getAnnotations(); |
|
148 |
if (medias && medias.length) { |
|
149 |
var mediaid = medias[0].id; |
|
150 |
el = $(".item-video[data-media-id='" + mediaid + "'] .media-count"); |
|
151 |
el.text(annotations.length).parent().show(); |
|
152 |
mediasegmentscache[mediaid] = annotations; |
|
153 |
if (currentMedia && mediaid === currentMedia.id && currentSegment) { |
|
154 |
showOtherSegments(); |
|
155 |
} |
|
156 |
} |
|
157 |
}); |
|
158 |
}); |
|
| 22 | 159 |
}); |
160 |
|
|
161 |
/* Search Media with left column form */ |
|
162 |
|
|
163 |
$(".col-left input").on("keyup change input paste", function() { |
|
164 |
var val = $(this).val(); |
|
165 |
if (val) { |
|
166 |
var find = IriSP.Model.regexpFromTextOrArray(val, true), |
|
167 |
replace = IriSP.Model.regexpFromTextOrArray(val, false); |
|
168 |
} |
|
169 |
$(".col-left .item-video").each(function() { |
|
170 |
var li = $(this), |
|
171 |
title = $(this).find(".title-video"), |
|
172 |
titletext = title.text(); |
|
173 |
if (val && find.test(titletext)) { |
|
174 |
title.html(titletext.replace(replace, '<span style="background: yellow;">$1</span>')); |
|
175 |
li.show(); |
|
176 |
} else { |
|
177 |
title.text(titletext); |
|
178 |
if (val) { |
|
179 |
li.hide(); |
|
| 13 | 180 |
} else { |
| 22 | 181 |
li.show(); |
| 13 | 182 |
} |
| 22 | 183 |
} |
184 |
}) |
|
185 |
}); |
|
186 |
|
|
| 25 | 187 |
/* Fill right column when mashup is updated */ |
188 |
|
|
| 27 | 189 |
function updateMashupUI() { |
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
190 |
var listhtml = '', critical = false, warning = false, messages = []; |
| 27 | 191 |
mashup.segments.forEach(function(_s) { |
192 |
listhtml += segmenttemplate(_s); |
|
| 39 | 193 |
if (_s.annotation.status === "critical") { |
194 |
critical = true; |
|
195 |
} |
|
| 27 | 196 |
}); |
| 39 | 197 |
if (critical) { |
198 |
messages.push("Certains segments ne sont pas valides"); |
|
199 |
} |
|
200 |
|
|
201 |
_(mashupcritical).each(function(sc) { |
|
202 |
if (!sc.validate(mashup)) { |
|
203 |
critical = true; |
|
204 |
messages.push(sc.message); |
|
205 |
} |
|
206 |
}); |
|
207 |
_(mashupwarning).each(function(sc) { |
|
208 |
if (!sc.validate(mashup)) { |
|
209 |
warning = true; |
|
210 |
messages.push(sc.message); |
|
211 |
} |
|
212 |
}); |
|
213 |
mashup.status = critical ? "critical" : (warning ? "warning" : "valid"); |
|
214 |
if (!messages.length) { |
|
215 |
messages.push("Le hashcut est valide !"); |
|
216 |
} |
|
| 43 | 217 |
mashupstatus = ' - ' + messages.join('\n - '); |
218 |
|
|
| 39 | 219 |
$(".publier-button").toggleClass("disable", critical); |
220 |
|
|
221 |
$(".liste-segment .validate").removeClass("critical warning valid").addClass(mashup.status); |
|
222 |
$(".liste-segment .validate-tooltip").html("<ul><li>" + messages.join("</li><li>")+"</li></ul>"); |
|
| 27 | 223 |
|
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
224 |
$(".col-right .list-video").html(listhtml).find(".item-video:last-child .bottom, .item-video:first-child .top").addClass("disable"); |
| 27 | 225 |
|
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
226 |
project.trigger("mouseout-annotation"); |
| 22 | 227 |
} |
228 |
|
|
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
229 |
mashup.on("setcurrent", function() { |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
230 |
currentMedia = mashup; |
| 22 | 231 |
}); |
232 |
|
|
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
233 |
mashup.on("change",updateMashupUI); |
| 25 | 234 |
|
| 23 | 235 |
/* Slice Widget */ |
| 25 | 236 |
|
| 23 | 237 |
var sliceSlider = $(".Ldt-Slice"), |
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
238 |
sliceStartTime, |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
239 |
slidersRange = 920; |
| 23 | 240 |
|
241 |
sliceSlider.slider({ |
|
242 |
range: true, |
|
243 |
values: [0, slidersRange], |
|
244 |
min: 0, |
|
245 |
max: slidersRange, |
|
246 |
start: function() { |
|
247 |
if (currentMedia) { |
|
248 |
if (!currentMedia.getPaused()) { |
|
249 |
currentMedia.pause(); |
|
250 |
} |
|
251 |
} |
|
252 |
}, |
|
253 |
slide: function(event, ui) { |
|
| 27 | 254 |
if (currentMedia && currentSegment) { |
| 23 | 255 |
var t = currentMedia.duration * ui.value / slidersRange; |
| 25 | 256 |
if (ui.value === ui.values[0]) { |
| 27 | 257 |
currentSegment.setBegin(t); |
| 25 | 258 |
} else { |
| 27 | 259 |
currentSegment.setEnd(t); |
| 25 | 260 |
} |
| 23 | 261 |
} |
262 |
} |
|
263 |
}); |
|
264 |
|
|
| 25 | 265 |
sliceSlider.find(".ui-slider-handle:first") |
266 |
.addClass("Ldt-Slice-left-handle") |
|
267 |
.click(function() { |
|
| 27 | 268 |
if (currentMedia && currentSegment) { |
269 |
currentMedia.setCurrentTime(currentSegment.begin); |
|
| 25 | 270 |
} |
271 |
}); |
|
272 |
sliceSlider.find(".ui-slider-handle:last") |
|
273 |
.addClass("Ldt-Slice-right-handle") |
|
274 |
.click(function() { |
|
| 27 | 275 |
if (currentMedia && currentSegment) { |
276 |
currentMedia.setCurrentTime(currentSegment.end); |
|
| 25 | 277 |
} |
278 |
}); |
|
| 23 | 279 |
|
280 |
|
|
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
281 |
/* Update Segment UI */ |
| 22 | 282 |
|
| 39 | 283 |
function updateSegmentUI() { |
| 27 | 284 |
if (currentMedia && currentSegment) { |
285 |
var start = currentSegment.begin, |
|
286 |
end = currentSegment.end, |
|
287 |
dur = currentSegment.getDuration(), |
|
288 |
f = slidersRange / currentMedia.duration, |
|
289 |
tangleStart = $(".tangle-start"), |
|
290 |
tangleEnd = $(".tangle-end"), |
|
| 29 | 291 |
tangleDuration = $(".tangle-duration"), |
292 |
k = 100 / currentMedia.duration, |
|
293 |
p = k * (start + end) / 2; |
|
| 25 | 294 |
sliceSlider.slider( "values", [ f * start, f * end ] ); |
| 27 | 295 |
tangleStart.text(start.toString(tangleStart.hasClass("active"))).attr("data-milliseconds",start.milliseconds); |
296 |
tangleEnd.text(end.toString(tangleEnd.hasClass("active"))).attr("data-milliseconds",end.milliseconds); |
|
297 |
tangleDuration.text(dur.toString(tangleDuration.hasClass("active"))).attr("data-milliseconds",dur.milliseconds); |
|
| 39 | 298 |
$(".segmentation .pointer").css("left", p + "%"); |
| 29 | 299 |
$(".media-current-section").css({ |
300 |
left: (k * start) + "%", |
|
301 |
width: (k * dur) + "%" |
|
| 39 | 302 |
}); |
303 |
var messages = [], |
|
304 |
critical = false, |
|
305 |
warning = false; |
|
306 |
_(segmentcritical).each(function(sc) { |
|
307 |
if (!sc.validate(currentSegment)) { |
|
308 |
critical = true; |
|
309 |
messages.push(sc.message); |
|
310 |
} |
|
311 |
}); |
|
312 |
_(segmentwarning).each(function(sc) { |
|
313 |
if (!sc.validate(currentSegment)) { |
|
314 |
warning = true; |
|
315 |
messages.push(sc.message); |
|
316 |
} |
|
317 |
}); |
|
318 |
currentSegment.status = critical ? "critical" : (warning ? "warning" : "valid"); |
|
319 |
if (!messages.length) { |
|
320 |
messages.push("Le segment est valide !") |
|
321 |
} |
|
322 |
currentSegment.status_messages = messages; |
|
323 |
|
|
324 |
$(".segmentation .validate").removeClass("critical warning valid").addClass(currentSegment.status); |
|
325 |
$(".segmentation .validate-tooltip").html("<ul><li>" + currentSegment.status_messages.join("</li><li>")+"</li></ul>"); |
|
| 25 | 326 |
} |
327 |
} |
|
328 |
|
|
| 42 | 329 |
var mediasegmentscache = {}; |
330 |
|
|
| 27 | 331 |
function setMedia(media) { |
| 23 | 332 |
if (currentMedia) { |
333 |
currentMedia.pause(); |
|
334 |
} |
|
| 27 | 335 |
currentMedia = media; |
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
336 |
project.trigger("set-current", media); |
| 22 | 337 |
if (currentMedia.elementType == "media") { |
| 23 | 338 |
showSegmentation(); |
339 |
$(".tab-media-title").text(currentMedia.title); |
|
| 27 | 340 |
|
341 |
addMode = !(currentSegment && mashup.hasAnnotation(currentSegment)); |
|
342 |
|
|
343 |
if (!currentSegment) { |
|
344 |
currentSegment = new IriSP.Model.Annotation(false, project); |
|
345 |
currentSegment.setMedia(currentMedia.id); |
|
346 |
currentSegment.setBegin(0); |
|
347 |
currentSegment.setEnd(currentMedia.duration); |
|
| 39 | 348 |
currentSegment.title = IriSP.hc_messages.segment_title_placeholder; |
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
349 |
currentSegment.color = currentMedia.color; |
| 43 | 350 |
currentSegment.thumbnail = currentMedia.thumbnail; |
| 42 | 351 |
currentSegment.created = new Date(); |
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
352 |
currentSegment.keywords = []; |
| 39 | 353 |
currentSegment.description = ""; |
| 27 | 354 |
currentSegment.on("change-begin", function() { |
355 |
if (currentMedia && currentSegment === this) { |
|
| 25 | 356 |
currentMedia.setCurrentTime(this.begin); |
| 39 | 357 |
updateSegmentUI(); |
| 25 | 358 |
} |
359 |
}); |
|
| 27 | 360 |
currentSegment.on("change-end", function() { |
361 |
if (currentMedia && currentSegment === this) { |
|
| 25 | 362 |
currentMedia.setCurrentTime(this.end); |
| 39 | 363 |
updateSegmentUI(); |
| 25 | 364 |
} |
365 |
}); |
|
366 |
} |
|
| 27 | 367 |
if (currentMedia.loaded) { |
368 |
currentMedia.setCurrentTime(currentSegment.begin); |
|
369 |
} |
|
370 |
$(".add-segment").val(addMode ? "Ajouter au Hashcut" : "Sauvegarder"); |
|
371 |
$(".create-or-edit").text(addMode ? "Créer un nouveau segment" : "Modifier le segment"); |
|
372 |
media.show(); |
|
373 |
$("#segment-title").val(currentSegment.title); |
|
374 |
$("#segment-description").val(currentSegment.description); |
|
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
375 |
var segment_tags = $("#segment-tags"); |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
376 |
segment_tags.tagit("option","onTagRemoved",function(){}); |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
377 |
segment_tags.tagit("option","onTagAdded",function(){}); |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
378 |
segment_tags.tagit("removeAll"); |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
379 |
_(currentSegment.keywords).each(function(tag) { |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
380 |
segment_tags.tagit("createTag",tag); |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
381 |
}); |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
382 |
segment_tags.tagit("option","onTagRemoved",updateSegmentTags); |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
383 |
segment_tags.tagit("option","onTagAdded",updateSegmentTags); |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
384 |
updateSegmentUI(); |
| 29 | 385 |
var relatedSegments = mashup.segments.filter(function(_s) { |
386 |
return _s.getMedia() === currentMedia && _s.annotation !== currentSegment; |
|
387 |
}); |
|
| 42 | 388 |
var html = "", |
| 43 | 389 |
k = $(".Ldt-Slider").width() / currentMedia.duration, |
| 42 | 390 |
currentleft = k * currentSegment.begin, |
391 |
currentwidth = k * currentSegment.getDuration(); |
|
| 29 | 392 |
if (relatedSegments.length) { |
393 |
relatedSegments.forEach(function(_s) { |
|
394 |
var pos = k * (_s.annotation.begin + _s.annotation.end) / 2, |
|
395 |
corrpos = Math.max(145, Math.min(305, pos)); |
|
396 |
vizdata = { |
|
397 |
annotation : _s.annotation, |
|
398 |
currentleft : currentleft, |
|
399 |
currentwidth : currentwidth, |
|
400 |
popleft : corrpos, |
|
401 |
left : k * _s.annotation.begin, |
|
402 |
width : k * _s.annotation.getDuration(), |
|
403 |
pointerpos : (pos - corrpos) |
|
404 |
} |
|
405 |
html += mediasegmenttemplate(vizdata); |
|
406 |
}); |
|
407 |
$(".self-media-segments").show(); |
|
408 |
} else { |
|
409 |
$(".self-media-segments").hide(); |
|
410 |
} |
|
| 42 | 411 |
$(".self-media-segments .media-segments-list").html(html); |
| 43 | 412 |
showOtherSegments(); |
413 |
project.trigger("mouseout-annotation"); |
|
| 22 | 414 |
} |
| 27 | 415 |
if (currentMedia.elementType === "mashup") { |
416 |
showPreview(); |
|
417 |
} |
|
| 22 | 418 |
} |
| 43 | 419 |
|
420 |
/* Show Related Segments */ |
|
421 |
|
|
422 |
function showOtherSegments() { |
|
423 |
var annotations = mediasegmentscache[currentMedia.id] |
|
424 |
if (annotations && annotations.length) { |
|
425 |
var html = "", |
|
426 |
k = $(".Ldt-Slider").width() / currentMedia.duration, |
|
427 |
currentleft = k * currentSegment.begin, |
|
428 |
currentwidth = k * currentSegment.getDuration(); |
|
429 |
annotations.forEach(function(_a) { |
|
430 |
var pos = k * (_a.begin + _a.end) / 2, |
|
431 |
corrpos = Math.max(145, Math.min(305, pos)); |
|
432 |
vizdata = { |
|
433 |
annotation : _a, |
|
434 |
currentleft : currentleft, |
|
435 |
currentwidth : currentwidth, |
|
436 |
popleft : corrpos, |
|
437 |
left : k * _a.begin, |
|
438 |
width : k * _a.getDuration(), |
|
439 |
pointerpos : (pos - corrpos), |
|
440 |
color: currentMedia.color |
|
441 |
} |
|
442 |
html += mediasegmenttemplate(vizdata); |
|
443 |
}); |
|
444 |
$(".other-media-segments").show(); |
|
445 |
$(".other-media-segments .media-segments-list").html(html); |
|
446 |
} |
|
447 |
else { |
|
448 |
$(".other-media-segments").hide(); |
|
449 |
$(".other-media-segments .media-segments-list").html(""); |
|
450 |
} |
|
451 |
} |
|
452 |
/* Set In, Out */ |
|
453 |
|
|
454 |
$(".Ldt-Ctrl-SetIn").click(function() { |
|
455 |
if (currentMedia && currentSegment) { |
|
456 |
currentSegment.setBegin(currentMedia.getCurrentTime()); |
|
457 |
} |
|
458 |
}); |
|
459 |
$(".Ldt-Ctrl-SetOut").click(function() { |
|
460 |
if (currentMedia && currentSegment) { |
|
461 |
currentSegment.setEnd(currentMedia.getCurrentTime()); |
|
462 |
} |
|
463 |
}); |
|
464 |
|
|
| 25 | 465 |
/* Segment Form interaction */ |
466 |
|
|
467 |
$("#segment-title").on("keyup change input paste", function() { |
|
| 27 | 468 |
if (currentMedia && currentSegment) { |
469 |
currentSegment.title = $(this).val(); |
|
| 39 | 470 |
updateSegmentUI(); |
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
471 |
mashup.trigger("change"); |
| 25 | 472 |
} |
473 |
}); |
|
| 43 | 474 |
$("#segment-title").on("focus click", function() { |
475 |
if ($(this).val() === IriSP.hc_messages.segment_title_placeholder) { |
|
476 |
$(this).val(""); |
|
477 |
} |
|
478 |
}); |
|
| 25 | 479 |
$("#segment-description").on("keyup change input paste", function() { |
| 27 | 480 |
if (currentMedia && currentSegment) { |
481 |
currentSegment.description = $(this).val(); |
|
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
482 |
mashup.trigger("change"); |
| 25 | 483 |
} |
484 |
}); |
|
485 |
$("#segment-form").submit(function() { |
|
| 27 | 486 |
if (addMode) { |
487 |
mashup.addAnnotation(currentSegment); |
|
488 |
} else { |
|
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
489 |
mashup.trigger("change"); |
| 27 | 490 |
} |
491 |
var segment = mashup.getAnnotation(currentSegment); |
|
492 |
currentSegment = undefined; |
|
493 |
setMedia(mashup); |
|
494 |
if (segment) { |
|
495 |
mashup.setCurrentTime(segment.begin); |
|
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
496 |
mashup.trigger("enter-annotation",segment); |
| 27 | 497 |
} |
| 29 | 498 |
return false; |
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
499 |
}); |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
500 |
|
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
501 |
$("#segment-tags").tagit(); |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
502 |
|
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
503 |
|
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
504 |
/* We have to defer this function because the tagit events |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
505 |
* are triggered before the data are updated */ |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
506 |
function updateSegmentTags() { |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
507 |
window.setTimeout(function() { |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
508 |
if (currentMedia && currentSegment) { |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
509 |
currentSegment.keywords = $("#segment-tags").tagit("assignedTags"); |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
510 |
} |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
511 |
}, 0); |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
512 |
} |
| 25 | 513 |
|
| 22 | 514 |
/* Click on media items */ |
515 |
|
|
516 |
$(".col-left").on("click", ".item-video", function() { |
|
| 27 | 517 |
currentSegment = undefined; |
518 |
setMedia(project.getElement($(this).attr("data-media-id"))); |
|
| 22 | 519 |
}); |
| 12 | 520 |
|
| 22 | 521 |
/* Click on Tabs */ |
522 |
|
|
523 |
function showSegmentation() { |
|
524 |
$(".col-middle").removeClass("empty-mode pvw-mode").addClass("segment-mode"); |
|
525 |
return false; |
|
526 |
} |
|
527 |
function showPreview() { |
|
528 |
$(".col-middle").removeClass("empty-mode segment-mode").addClass("pvw-mode"); |
|
529 |
return false; |
|
530 |
} |
|
| 32 | 531 |
function showEmpty() { |
532 |
$("video").hide(); |
|
533 |
$(".col-middle").removeClass("pvw-mode segment-mode").addClass("empty-mode"); |
|
534 |
return false; |
|
535 |
} |
|
| 22 | 536 |
|
| 27 | 537 |
$(".tab-pvw").click(function() { |
538 |
if (mashup.segments.length) { |
|
539 |
setMedia(mashup); |
|
| 22 | 540 |
} |
541 |
}); |
|
542 |
|
|
| 27 | 543 |
/* Click on segments */ |
544 |
|
|
545 |
function reorganizeMashup() { |
|
546 |
var ids = $(".organize-segments .item-video").map(function(){return $(this).attr("data-segment-id")}); |
|
547 |
mashup.setAnnotationsById(ids); |
|
548 |
} |
|
549 |
|
|
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
550 |
project.on("mouseover-annotation", function(annotation) { |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
551 |
var mediaid = annotation.getMedia().id; |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
552 |
$(".media").removeClass("active"); |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
553 |
$(".media[data-media-id='" + mediaid + "']").addClass("active"); |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
554 |
}); |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
555 |
|
| 43 | 556 |
project.on("mouseout-annotation", function() { |
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
557 |
$(".media").removeClass("active"); |
| 32 | 558 |
var mediaid = undefined; |
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
559 |
if (currentMedia && currentMedia.elementType === "media") { |
| 32 | 560 |
mediaid = currentMedia.id; |
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
561 |
if (currentSegment) { |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
562 |
$(".annotation").removeClass("active"); |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
563 |
$(".annotation[data-segment-id='" + currentSegment.id + "']").addClass("active"); |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
564 |
} |
| 32 | 565 |
} |
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
566 |
if (currentMedia === mashup && mashup.currentMedia) { |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
567 |
mediaid = mashup.currentMedia.id |
| 32 | 568 |
} |
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
569 |
$(".media[data-media-id='" + mediaid + "']").addClass("active"); |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
570 |
}); |
| 32 | 571 |
|
572 |
$(".organize-segments") |
|
573 |
.sortable({ |
|
| 27 | 574 |
stop : reorganizeMashup |
| 32 | 575 |
}) |
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
576 |
.on("mouseover", ".item-video", function() { |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
577 |
project.trigger("mouseover-annotation", project.getElement($(this).attr("data-segment-id"))); |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
578 |
}) |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
579 |
.on("mouseout", ".item-video", function() { |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
580 |
project.trigger("mouseout-annotation"); |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
581 |
}) |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
582 |
.on("click", ".item-video", function() { |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
583 |
project.trigger("click-annotation", project.getElement($(this).attr("data-segment-id"))); |
| 32 | 584 |
}) |
585 |
.on("click", ".edit", function(e) { |
|
| 27 | 586 |
var currentItem = $(this).parents(".item-video"), |
587 |
media = project.getElement(currentItem.attr("data-media-id")), |
|
588 |
segment = project.getElement(currentItem.attr("data-segment-id")); |
|
589 |
currentSegment = segment; |
|
590 |
setMedia(media); |
|
591 |
return false; |
|
| 32 | 592 |
}) |
593 |
.on("click", ".top", function(e){ |
|
| 22 | 594 |
var currentItem = $(this).parents(".item-video"); |
595 |
currentItem.insertBefore(currentItem.prev()); |
|
| 27 | 596 |
reorganizeMashup(); |
597 |
return false; |
|
| 32 | 598 |
}) |
599 |
.on("click", ".bottom", function(e){ |
|
| 22 | 600 |
var currentItem = $(this).parents(".item-video"); |
601 |
currentItem.insertAfter(currentItem.next()); |
|
| 27 | 602 |
reorganizeMashup(); |
603 |
return false; |
|
| 32 | 604 |
}) |
605 |
.on("click", ".delete", function(e){ |
|
| 27 | 606 |
var id = $(this).parents(".item-video").attr("data-segment-id"); |
607 |
mashup.removeAnnotationById(id); |
|
| 32 | 608 |
if (!mashup.segments.length) { |
609 |
showEmpty(); |
|
610 |
} |
|
| 27 | 611 |
return false; |
| 22 | 612 |
}); |
613 |
|
|
| 25 | 614 |
/* Tangles */ |
615 |
var tangleMsPerPixel = 100, |
|
616 |
activeTangle, |
|
| 23 | 617 |
tangleStartX, |
| 25 | 618 |
tangleStartVal, |
619 |
tangleHasMoved; |
|
620 |
|
|
| 23 | 621 |
$(".time-tangle").mousedown(function(evt) { |
622 |
activeTangle = $(this); |
|
623 |
activeTangle.addClass("active"); |
|
624 |
tangleStartVal = +activeTangle.attr("data-milliseconds"); |
|
625 |
tangleStartX = evt.pageX; |
|
| 25 | 626 |
tangleHasMoved = false; |
627 |
$(this).siblings(".time-tangle").addClass("deactivate"); |
|
| 23 | 628 |
return false; |
629 |
}); |
|
630 |
$(document) |
|
631 |
.mousemove(function(evt) { |
|
632 |
if (activeTangle) { |
|
| 25 | 633 |
tangleHasMoved = true; |
634 |
var newval = new IriSP.Model.Time(tangleMsPerPixel * (evt.pageX - tangleStartX) + tangleStartVal); |
|
| 23 | 635 |
activeTangle.trigger("valuechange", newval); |
636 |
return false; |
|
637 |
} |
|
638 |
}) |
|
639 |
.mouseup(function() { |
|
640 |
if (activeTangle) { |
|
| 27 | 641 |
activeTangle.text(activeTangle.text().replace(/\.\d+$/,'')); |
| 25 | 642 |
$(".time-tangle").removeClass("active deactivate"); |
| 23 | 643 |
activeTangle = undefined; |
644 |
} |
|
| 25 | 645 |
}); |
646 |
|
|
647 |
$(".tangle-start") |
|
648 |
.mouseup(function(evt) { |
|
| 27 | 649 |
if (!tangleHasMoved && currentMedia && currentSegment) { |
650 |
currentMedia.setCurrentTime(currentSegment.begin); |
|
| 25 | 651 |
} |
| 23 | 652 |
}) |
| 25 | 653 |
.on("valuechange", function(evt, val) { |
| 27 | 654 |
if (currentMedia && currentSegment) { |
655 |
currentSegment.setBegin(val); |
|
| 25 | 656 |
} |
657 |
}); |
|
658 |
$(".tangle-end") |
|
659 |
.mouseup(function(evt) { |
|
| 27 | 660 |
if (!tangleHasMoved && currentMedia && currentSegment) { |
661 |
currentMedia.setCurrentTime(currentSegment.end); |
|
| 25 | 662 |
} |
663 |
}) |
|
664 |
.on("valuechange", function(evt, val) { |
|
| 27 | 665 |
if (currentMedia && currentSegment) { |
666 |
currentSegment.setEnd(val); |
|
| 25 | 667 |
} |
668 |
}); |
|
669 |
$(".tangle-duration").on("valuechange", function(evt, val) { |
|
| 27 | 670 |
if (currentMedia && currentSegment) { |
671 |
currentSegment.setDuration(val); |
|
| 25 | 672 |
} |
673 |
}); |
|
| 27 | 674 |
|
| 29 | 675 |
/* Click on current segment in Preview */ |
676 |
|
|
| 27 | 677 |
$(".mashup-description .edit").click(function() { |
| 43 | 678 |
if (mashup.currentAnnotation) { |
679 |
currentSegment = mashup.currentAnnotation.annotation; |
|
680 |
setMedia(mashup.currentAnnotation.getMedia()); |
|
| 27 | 681 |
} |
| 43 | 682 |
return false; |
| 29 | 683 |
}); |
684 |
|
|
685 |
/* Handling related segments */ |
|
686 |
|
|
687 |
$(".media-segments-list").on("mouseover", ".media-segment", function() { |
|
688 |
$(this).find(".media-segment-popin").show(); |
|
689 |
}).on("mouseout", ".media-segment", function() { |
|
690 |
$(this).find(".media-segment-popin").hide(); |
|
691 |
}).on("click", ".reprendre-segment", function() { |
|
| 42 | 692 |
var sid = $(this).attr("data-segment-id"), |
693 |
s = directory.getElement(sid) || apidirectory.getElement(sid); |
|
| 43 | 694 |
currentSegment.title = IriSP.hc_messages.copy_of_ + s.title; |
| 29 | 695 |
currentSegment.description = s.description; |
| 43 | 696 |
$("#segment-title").val(IriSP.hc_messages.copy_of_ + s.title); |
| 29 | 697 |
$("#segment-description").val(s.description); |
698 |
currentSegment.setBegin(s.begin); |
|
699 |
currentSegment.setEnd(s.end); |
|
| 43 | 700 |
//TODO: ET LES TAGS ! |
| 29 | 701 |
return false; |
702 |
}); |
|
703 |
|
|
| 32 | 704 |
/* Changing Hashcut Title and description */ |
| 39 | 705 |
|
706 |
mashup.title = IriSP.hc_messages.mashup_title_placeholder; |
|
707 |
$(".title-video-wrap a").text(mashup.title); |
|
708 |
$("#hashcut-title").val(mashup.title); |
|
709 |
|
|
| 32 | 710 |
$("#hashcut-title").on("keyup change input paste", function() { |
711 |
mashup.title = $(this).val(); |
|
712 |
$(".title-video-wrap a").text(mashup.title); |
|
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
713 |
mashup.trigger("change"); |
| 32 | 714 |
}); |
| 43 | 715 |
$("#hashcut-title").on("focus click", function() { |
716 |
if ($(this).val() === IriSP.hc_messages.mashup_title_placeholder) { |
|
717 |
$(this).val(""); |
|
718 |
} |
|
719 |
}); |
|
| 32 | 720 |
|
| 39 | 721 |
$("#hashcut-description").on("keyup change input paste", function() { |
722 |
mashup.description = $(this).val(); |
|
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
723 |
mashup.trigger("change"); |
| 39 | 724 |
}); |
725 |
|
|
| 43 | 726 |
$("#hashcut-form").submit(function() { |
727 |
$(".update-title").hide(); |
|
728 |
return false; |
|
729 |
}) |
|
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
730 |
|
| 42 | 731 |
/* Publication */ |
732 |
|
|
733 |
$(".publier-button").click(function() { |
|
| 43 | 734 |
if ($(this).hasClass("disable")) { |
735 |
alert("Le Mashup ne peut pas être publié pour les raisons suivantes :\n\n"+mashupstatus); |
|
736 |
return false; |
|
737 |
} |
|
| 42 | 738 |
var postproject = directory.newLocalSource(), |
| 43 | 739 |
medias = mashup.getMedias() |
| 42 | 740 |
annotations = mashup.getOriginalAnnotations(); |
| 43 | 741 |
postproject.addList("annotationType"); |
742 |
postproject.addList("tag"); |
|
743 |
medias.forEach(function(_m) { |
|
744 |
var anntype = new IriSP.Model.AnnotationType(false, postproject); |
|
745 |
anntype.title = "Segments from " + _m.title; |
|
746 |
anntype.media = _m; |
|
747 |
postproject.getAnnotationTypes().push(anntype); |
|
| 42 | 748 |
}); |
| 43 | 749 |
annotations.forEach(function(_a) { |
750 |
_a.setAnnotationType( |
|
751 |
postproject.getAnnotationTypes().filter( |
|
752 |
function(_at) { return _at.media === _a.getMedia() } |
|
753 |
)[0].id); |
|
754 |
var tagids = []; |
|
755 |
_(_a.keywords).each(function(keyword) { |
|
756 |
var tags = postproject.getTags().searchByTitle(keyword); |
|
757 |
if (tags.length) { |
|
758 |
tagids.push(tags[0].id); |
|
759 |
} else { |
|
760 |
var tag = new IriSP.Model.Tag(false, postproject); |
|
761 |
tag.title = tag.description = keyword; |
|
762 |
postproject.getTags().push(tag); |
|
763 |
tagids.push(tag.id); |
|
764 |
} |
|
765 |
}); |
|
766 |
_a.setTags(tagids); |
|
767 |
}); |
|
| 42 | 768 |
postproject.addList("annotation",annotations); |
| 43 | 769 |
postproject.addList("media",medias); |
| 42 | 770 |
postproject.addList("mashup",[mashup]); |
| 43 | 771 |
postproject.creator = "admin"; |
772 |
postproject.created = new Date(); |
|
773 |
postproject.modified = new Date(); |
|
| 42 | 774 |
postproject.title = mashup.title; |
775 |
postproject.description = mashup.description; |
|
776 |
$.ajax({ |
|
777 |
type: "POST", |
|
778 |
url: options.project_api_endpoint, |
|
779 |
data: IriSP.serializers.ldt.serialize(postproject), |
|
780 |
contentType: "application/cinelab", |
|
781 |
// headers: {"X-CSRFToken": "{{csrf_token}}"}, |
|
782 |
success: function(data, status, request){ |
|
| 43 | 783 |
console.log(request.getResponseHeader("Location")); |
| 42 | 784 |
}, |
785 |
error: function(jqXHR, textStatus, errorThrown){ |
|
786 |
alert(errorThrown); |
|
787 |
} |
|
788 |
}); |
|
| 43 | 789 |
return false; |
| 42 | 790 |
}); |
791 |
|
|
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
39
diff
changeset
|
792 |
mashup.trigger("change"); |
| 13 | 793 |
} |