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