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