16 + '<span class="video-info"><span class="title-video"><%= annotation.getMedia().title %></span>' |
16 + '<span class="video-info"><span class="title-video"><%= annotation.getMedia().title %></span>' |
17 + '<span class="subtitle"><%= annotation.title %></span><span class="duration"><%= annotation.begin.toString() %> - <%= annotation.end.toString() %> (<%= annotation.getDuration().toString() %>)</span>' |
17 + '<span class="subtitle"><%= annotation.title %></span><span class="duration"><%= annotation.begin.toString() %> - <%= annotation.end.toString() %> (<%= annotation.getDuration().toString() %>)</span>' |
18 + '<ul class="tools"><li><a class="edit" href="#" title="Éditer le segment"></a></li><li><a class="bottom" href="#" title="Descendre le segment"></a></li>' |
18 + '<ul class="tools"><li><a class="edit" href="#" title="Éditer le segment"></a></li><li><a class="bottom" href="#" title="Descendre le segment"></a></li>' |
19 + '<li><a class="top" href="#" title="Remonter le segment"></a></li><li><a class="delete" href="#" title="Supprimer le segment"></a></li></ul></span></li>'), |
19 + '<li><a class="top" href="#" title="Remonter le segment"></a></li><li><a class="delete" href="#" title="Supprimer le segment"></a></li></ul></span></li>'), |
20 viztemplate = _.template('<div class="frise-segment" style="background-color:<%= color %>; left:<%= left %>%; width:<%= width %>%;"></div>'), |
20 viztemplate = _.template('<div class="frise-segment" style="background-color:<%= color %>; left:<%= left %>%; width:<%= width %>%;"></div>'), |
21 intervaltemplate = _.template('<span class="frise-indication" style="left:<%= left %>%;"><%= time.toString() %></span>'); |
21 intervaltemplate = _.template('<span class="frise-indication" style="left:<%= left %>%;"><%= time.toString() %></span>'), |
|
22 mediasegmenttemplate = _.template('<div class="media-segments-list"><div class="media-segment">' |
|
23 + '<div class="media-section media-segment-section" style="left:<%= left %>px; width:<%= width %>px; background:<%= annotation.getMedia().color %>"></div>' |
|
24 + '<div class="media-section media-current-section" style="left:<%= currentleft %>px; width:<%= currentwidth %>px;"><div class="media-current-section-inner"></div></div>' |
|
25 + '<div class="popin media-segment-popin" style="left:<%= popleft %>px"><img style="left:<%= pointerpos %>px;" class="pointer" src="img/popin-triangle.png" alt="" /><div class="popin-content">' |
|
26 + '<h3><%= annotation.title %></h3><a href="#" class="button reprendre-segment" data-segment-id="<%= annotation.id %>">Cloner le segment</a>' |
|
27 + '<p>De: <span><%= annotation.begin.toString() %></span> à <span><%= annotation.end.toString() %></span> (durée: <span><%= annotation.getDuration().toString() %></span>)</p>' |
|
28 + '</div></div></div></div>'); |
22 |
29 |
23 /* Fill left column with Media List */ |
30 /* Fill left column with Media List */ |
24 |
31 |
25 project.onLoad(function() { |
32 project.onLoad(function() { |
26 var html = ''; |
33 var html = ''; |
134 timeSliderMinimizedHeight = 4, |
142 timeSliderMinimizedHeight = 4, |
135 timeSliderMaximizedHeight = 10, |
143 timeSliderMaximizedHeight = 10, |
136 timeSliderTimeoutDuration = 1500, |
144 timeSliderTimeoutDuration = 1500, |
137 timeTooltip = $(".Ldt-Slider-Time"); |
145 timeTooltip = $(".Ldt-Slider-Time"); |
138 |
146 |
139 timeSlider.css(calculateSliderCss(timeSliderMinimizedHeight)); |
147 timeSliderContainer.css(calculateSliderCss(timeSliderMinimizedHeight)); |
140 timeSliderHandle.css(calculateHandleCss(timeSliderMinimizedHeight)); |
148 timeSliderHandle.css(calculateHandleCss(timeSliderMinimizedHeight)); |
141 |
149 |
142 function timeSliderMouseOver() { |
150 function timeSliderMouseOver() { |
143 if (timeSliderTimeoutId) { |
151 if (timeSliderTimeoutId) { |
144 window.clearTimeout(timeSliderTimeoutId); |
152 window.clearTimeout(timeSliderTimeoutId); |
163 } |
171 } |
164 timeSliderTimeoutId = false; |
172 timeSliderTimeoutId = false; |
165 }, timeSliderTimeoutDuration); |
173 }, timeSliderTimeoutDuration); |
166 } |
174 } |
167 |
175 |
168 timeSlider |
176 timeSliderContainer |
169 .mouseover(function() { |
177 .mouseover(function() { |
170 timeTooltip.show(); |
178 timeTooltip.show(); |
171 timeSliderMouseOver(); |
179 timeSliderMouseOver(); |
172 }) |
180 }) |
173 .mouseout(timeSliderMouseOut) |
181 .mouseout(timeSliderMouseOut); |
174 .mousemove(function(_e) { |
182 timeSlider.mousemove(function(_e) { |
175 var _x = _e.pageX - timeSlider.offset().left, |
183 var _x = _e.pageX - timeSlider.offset().left, |
176 _t = new IriSP.Model.Time( |
184 _t = new IriSP.Model.Time( |
177 currentMedia ? currentMedia.duration * _x / timeSlider.width() : 0 |
185 currentMedia ? currentMedia.duration * _x / timeSlider.width() : 0 |
178 ); |
186 ); |
179 timeTooltip.text(_t.toString()).css("left",_x); |
187 timeTooltip.text(_t.toString()).css("left",_x); |
180 }); |
188 }); |
181 |
189 |
182 $(".Ldt-Ctrl").mouseover(timeSliderMouseOver).mouseout(timeSliderMouseOut); |
190 $(".Ldt-Ctrl").mouseover(timeSliderMouseOver).mouseout(timeSliderMouseOut); |
183 |
191 |
184 function timeSliderAnimateToHeight(_height) { |
192 function timeSliderAnimateToHeight(_height) { |
185 timeSlider.stop().animate( |
193 timeSliderContainer.stop().animate( |
186 calculateSliderCss(_height), |
194 calculateSliderCss(_height), |
187 500, |
195 500, |
188 function() { |
196 function() { |
189 IriSP.jQuery(this).css("overflow","visible"); |
197 IriSP.jQuery(this).css("overflow","visible"); |
190 }); |
198 }); |
417 end = currentSegment.end, |
425 end = currentSegment.end, |
418 dur = currentSegment.getDuration(), |
426 dur = currentSegment.getDuration(), |
419 f = slidersRange / currentMedia.duration, |
427 f = slidersRange / currentMedia.duration, |
420 tangleStart = $(".tangle-start"), |
428 tangleStart = $(".tangle-start"), |
421 tangleEnd = $(".tangle-end"), |
429 tangleEnd = $(".tangle-end"), |
422 tangleDuration = $(".tangle-duration"); |
430 tangleDuration = $(".tangle-duration"), |
|
431 k = 100 / currentMedia.duration, |
|
432 p = k * (start + end) / 2; |
423 sliceSlider.slider( "values", [ f * start, f * end ] ); |
433 sliceSlider.slider( "values", [ f * start, f * end ] ); |
424 tangleStart.text(start.toString(tangleStart.hasClass("active"))).attr("data-milliseconds",start.milliseconds); |
434 tangleStart.text(start.toString(tangleStart.hasClass("active"))).attr("data-milliseconds",start.milliseconds); |
425 tangleEnd.text(end.toString(tangleEnd.hasClass("active"))).attr("data-milliseconds",end.milliseconds); |
435 tangleEnd.text(end.toString(tangleEnd.hasClass("active"))).attr("data-milliseconds",end.milliseconds); |
426 tangleDuration.text(dur.toString(tangleDuration.hasClass("active"))).attr("data-milliseconds",dur.milliseconds); |
436 tangleDuration.text(dur.toString(tangleDuration.hasClass("active"))).attr("data-milliseconds",dur.milliseconds); |
427 $(".segment-info .pointer").css("left",(parseFloat($(".Ldt-Slice-left-handle").css("left")) + parseFloat($(".Ldt-Slice-right-handle").css("left")))/2) |
437 $(".segment-info .pointer").css("left", p + "%"); |
|
438 $(".media-current-section").css({ |
|
439 left: (k * start) + "%", |
|
440 width: (k * dur) + "%" |
|
441 }) |
428 } |
442 } |
429 } |
443 } |
430 |
444 |
431 var addMode; |
445 var addMode; |
432 |
446 |
433 function setMedia(media) { |
447 function setMedia(media) { |
434 $(".col-left .item-video").removeClass("active"); |
448 $(".col-left .item-video").removeClass("active"); |
435 $(".tutorial").hide(); |
449 $(".tutorial").hide(); |
|
450 //TODO: Show Tutorial when Hashcut is empty |
436 if (currentMedia) { |
451 if (currentMedia) { |
437 currentMedia.pause(); |
452 currentMedia.pause(); |
438 } |
453 } |
439 currentMedia = media; |
454 currentMedia = media; |
440 if (currentMedia.elementType == "media") { |
455 if (currentMedia.elementType == "media") { |
475 $(".annotation-end").text(this.end.toString()); |
490 $(".annotation-end").text(this.end.toString()); |
476 $(".annotation-media-title").text(this.getMedia().title); |
491 $(".annotation-media-title").text(this.getMedia().title); |
477 $(".annotation-description").text(this.description); |
492 $(".annotation-description").text(this.description); |
478 setPointerToCurrentAnnotation(); |
493 setPointerToCurrentAnnotation(); |
479 } |
494 } |
480 }) |
495 }); |
481 } |
496 } |
482 if (currentMedia.loaded) { |
497 if (currentMedia.loaded) { |
483 currentMedia.setCurrentTime(currentSegment.begin); |
498 currentMedia.setCurrentTime(currentSegment.begin); |
484 } |
499 } |
485 $(".add-segment").val(addMode ? "Ajouter au Hashcut" : "Sauvegarder"); |
500 $(".add-segment").val(addMode ? "Ajouter au Hashcut" : "Sauvegarder"); |
487 updateSliderAndTangles(); |
502 updateSliderAndTangles(); |
488 media.show(); |
503 media.show(); |
489 $("#segment-title").val(currentSegment.title); |
504 $("#segment-title").val(currentSegment.title); |
490 $("#segment-description").val(currentSegment.description); |
505 $("#segment-description").val(currentSegment.description); |
491 $("#segment-tags").val(""); |
506 $("#segment-tags").val(""); |
492 } |
507 var relatedSegments = mashup.segments.filter(function(_s) { |
|
508 return _s.getMedia() === currentMedia && _s.annotation !== currentSegment; |
|
509 }); |
|
510 var html = ""; |
|
511 if (relatedSegments.length) { |
|
512 var k = $(".Ldt-Slider").width() / currentSegment.getMedia().duration, |
|
513 currentleft = k * currentSegment.begin, |
|
514 currentwidth = k * currentSegment.getDuration(); |
|
515 relatedSegments.forEach(function(_s) { |
|
516 var pos = k * (_s.annotation.begin + _s.annotation.end) / 2, |
|
517 corrpos = Math.max(145, Math.min(305, pos)); |
|
518 vizdata = { |
|
519 annotation : _s.annotation, |
|
520 currentleft : currentleft, |
|
521 currentwidth : currentwidth, |
|
522 popleft : corrpos, |
|
523 left : k * _s.annotation.begin, |
|
524 width : k * _s.annotation.getDuration(), |
|
525 pointerpos : (pos - corrpos) |
|
526 } |
|
527 html += mediasegmenttemplate(vizdata); |
|
528 }); |
|
529 $(".self-media-segments").show(); |
|
530 } else { |
|
531 $(".self-media-segments").hide(); |
|
532 } |
|
533 } |
|
534 $(".self-media-segments .media-segments-list").html(html); |
493 if (currentMedia.elementType === "mashup") { |
535 if (currentMedia.elementType === "mashup") { |
494 showPreview(); |
536 showPreview(); |
495 mashup.checkLoaded(); |
537 mashup.checkLoaded(); |
496 } |
538 } |
497 $(".Ldt-Ctrl-Time-Total").text(currentMedia.duration.toString()); |
539 $(".Ldt-Ctrl-Time-Total").text(currentMedia.duration.toString()); |
901 if (currentMedia && currentSegment) { |
944 if (currentMedia && currentSegment) { |
902 currentSegment.setDuration(val); |
945 currentSegment.setDuration(val); |
903 } |
946 } |
904 }); |
947 }); |
905 |
948 |
|
949 /* Click on current segment in Preview */ |
|
950 |
906 $(".mashup-description .edit").click(function() { |
951 $(".mashup-description .edit").click(function() { |
907 if (mashupCurrentAnnotation) { |
952 if (mashupCurrentAnnotation) { |
908 currentSegment = mashupCurrentAnnotation.annotation; |
953 currentSegment = mashupCurrentAnnotation.annotation; |
909 setMedia(mashupCurrentAnnotation.getMedia()); |
954 setMedia(mashupCurrentAnnotation.getMedia()); |
910 } |
955 } |
911 }) |
956 }); |
|
957 |
|
958 /* Handling related segments */ |
|
959 |
|
960 $(".media-segments-list").on("mouseover", ".media-segment", function() { |
|
961 $(this).find(".media-segment-popin").show(); |
|
962 }).on("mouseout", ".media-segment", function() { |
|
963 $(this).find(".media-segment-popin").hide(); |
|
964 }).on("click", ".reprendre-segment", function() { |
|
965 var s = project.getElement($(this).attr("data-segment-id")); |
|
966 currentSegment.title = s.title; |
|
967 currentSegment.description = s.description; |
|
968 $("#segment-title").val(s.title); |
|
969 $("#segment-description").val(s.description); |
|
970 currentSegment.setBegin(s.begin); |
|
971 currentSegment.setEnd(s.end); |
|
972 return false; |
|
973 }); |
|
974 |
912 } |
975 } |