18 serializer: IriSP.serializers.medialist |
24 serializer: IriSP.serializers.medialist |
19 }), |
25 }), |
20 mashup = new IriSP.Model.Mashup(false, project), |
26 mashup = new IriSP.Model.Mashup(false, project), |
21 mediatemplate = _.template('<li class="item-video" data-media-id="<%= id %>"><img src="<%= thumbnail %>" alt="<%= title %>" />' |
27 mediatemplate = _.template('<li class="item-video" data-media-id="<%= id %>"><img src="<%= thumbnail %>" alt="<%= title %>" />' |
22 + '<span class="video-info"><span class="title-video"><%= title %></span><span class="author"><%= description %></span>' |
28 + '<span class="video-info"><span class="title-video"><%= title %></span><span class="author"><%= description %></span>' |
23 + '<span class="time-length"><%= IriSP.hc_messages.duration_ %> <span><%= duration.toString() %></span></span></span></li>'), |
29 + '<span class="time-length"><%= IriSP.hc_messages.Duration_ %> <span><%= duration.toString() %></span></span></span></li>'), |
24 segmenttemplate = _.template('<li class="item-video" data-segment-id="<%= annotation.id %>" data-media-id="<%= annotation.getMedia().id %>">' |
30 segmenttemplate = _.template('<li class="item-video" data-segment-id="<%= annotation.id %>" data-media-id="<%= annotation.getMedia().id %>">' |
25 + '<img src="<%= annotation.getMedia().thumbnail %>" alt="<%= annotation.getMedia().title %>" />' |
31 + '<img src="<%= annotation.getMedia().thumbnail %>" alt="<%= annotation.getMedia().title %>" />' |
26 + '<span class="video-info"><span class="title-video"><%= annotation.getMedia().title %></span>' |
32 + '<div class="validate <%= annotation.status %>"><div class="validate-tooltip"><ul><li><%= annotation.status_messages.join("</li><li>") %></li></ul></div></div><span class="video-info"><span class="title-video"><%= annotation.getMedia().title %></span>' |
27 + '<span class="subtitle"><%= annotation.title %></span><span class="duration"><%= annotation.begin.toString() %> - <%= annotation.end.toString() %> (<%= annotation.getDuration().toString() %>)</span>' |
33 + '<span class="subtitle"><%= annotation.title %></span><span class="duration"><%= annotation.begin.toString() %> - <%= annotation.end.toString() %> (<%= annotation.getDuration().toString() %>)</span>' |
28 + '<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>' |
34 + '<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>' |
29 + '<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></span></li>'), |
35 + '<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></span></li>'), |
30 viztemplate = _.template('<div class="frise-segment" data-segment-id="<%= segmentid %>" style="background-color:<%= color %>; left:<%= left %>%; width:<%= width %>%;"></div>'), |
36 viztemplate = _.template('<div class="frise-segment" data-segment-id="<%= segmentid %>" style="background-color:<%= color %>; left:<%= left %>%; width:<%= width %>%;"></div>'), |
31 intervaltemplate = _.template('<span class="frise-indication" style="left:<%= left %>%;"><%= time.toString() %></span>'), |
37 intervaltemplate = _.template('<span class="frise-indication" style="left:<%= left %>%;"><%= time.toString() %></span>'), |
32 mediasegmenttemplate = _.template('<div class="media-segments-list"><div class="media-segment">' |
38 mediasegmenttemplate = _.template('<div class="media-segments-list"><div class="media-segment">' |
33 + '<div class="media-section media-segment-section" style="left:<%= left %>px; width:<%= width %>px; background:<%= annotation.getMedia().color %>"></div>' |
39 + '<div class="media-section media-segment-section" style="left:<%= left %>px; width:<%= width %>px; background:<%= annotation.getMedia().color %>"></div>' |
34 + '<div class="media-section media-current-section" style="left:<%= currentleft %>px; width:<%= currentwidth %>px;"><div class="media-current-section-inner"></div></div>' |
40 + '<div class="media-section media-current-section" style="left:<%= currentleft %>px; width:<%= currentwidth %>px;"><div class="media-current-section-inner"></div></div>' |
35 + '<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">' |
41 + '<div class="popin media-segment-popin" style="left:<%= popleft %>px"><img style="left:<%= pointerpos %>px;" class="pointer" src="img/popin-triangle.png" alt="" /><div class="popin-content">' |
36 + '<h3><%= annotation.title %></h3><a href="#" class="button reprendre-segment" data-segment-id="<%= annotation.id %>">Cloner le segment</a>' |
42 + '<h3><%= annotation.title %></h3><a href="#" class="button reprendre-segment" data-segment-id="<%= annotation.id %>"><%= IriSP.hc_messages.clone_segment %></a>' |
37 + '<p>De: <span><%= annotation.begin.toString() %></span> à <span><%= annotation.end.toString() %></span> (durée: <span><%= annotation.getDuration().toString() %></span>)</p>' |
43 + '<p><%= IriSP.hc_messages.From_ %> <span><%= annotation.begin.toString() %></span> <%= IriSP.hc_messages.to_ %> <span><%= annotation.end.toString() %></span> (<%= IriSP.hc_messages.duration_ %> <span><%= annotation.getDuration().toString() %></span>)</p>' |
38 + '</div></div></div></div>'); |
44 + '</div></div></div></div>'); |
|
45 |
|
46 /* Validation of segments and mashup */ |
|
47 |
|
48 var segmentcritical = [ |
|
49 { |
|
50 validate: function(_s) { |
|
51 var _d = _s.getDuration(); |
|
52 return (_d > 1000 && _d < 180000); |
|
53 }, |
|
54 message: "La durée du segment doit être comprise entre 1 seconde et trois minutes" |
|
55 }, |
|
56 { |
|
57 validate: function(_s) { |
|
58 return (!!_s.title && _s.title !== IriSP.hc_messages.segment_title_placeholder); |
|
59 }, |
|
60 message: "Un titre doit être donné au segment" |
|
61 } |
|
62 ]; |
|
63 var segmentwarning = [ |
|
64 { |
|
65 validate: function(_s) { |
|
66 return (_s.description); |
|
67 }, |
|
68 message: "Il est recommandé de donner une description au segment" |
|
69 } |
|
70 ]; |
|
71 |
|
72 var mashupcritical = [ |
|
73 { |
|
74 validate: function(_m) { |
|
75 return _m.segments.length > 2; |
|
76 }, |
|
77 message: "Un hashcut doit être composé d'au moins trois segments" |
|
78 }, |
|
79 { |
|
80 validate: function(_m) { |
|
81 return (!!_m.title && _m.title !== IriSP.hc_messages.mashup_title_placeholder); |
|
82 }, |
|
83 message: "Un titre doit être donné au hashcut" |
|
84 } |
|
85 ]; |
|
86 var mashupwarning = [ |
|
87 { |
|
88 validate: function(_m) { |
|
89 return !!_m.description |
|
90 }, |
|
91 message: "Il est recommandé de donner une description au hashcut" |
|
92 } |
|
93 ]; |
39 |
94 |
40 /* Fill left column with Media List */ |
95 /* Fill left column with Media List */ |
41 |
96 |
42 project.onLoad(function() { |
97 project.onLoad(function() { |
43 var html = ''; |
98 var html = ''; |
82 } |
137 } |
83 } |
138 } |
84 |
139 |
85 function updateMashupUI() { |
140 function updateMashupUI() { |
86 var listhtml = '', vizhtml = '', t = 0, k = mashup.duration ? (100 / mashup.duration) : 0; |
141 var listhtml = '', vizhtml = '', t = 0, k = mashup.duration ? (100 / mashup.duration) : 0; |
|
142 var critical = false, warning = false, messages = []; |
87 mashup.segments.forEach(function(_s) { |
143 mashup.segments.forEach(function(_s) { |
88 listhtml += segmenttemplate(_s); |
144 listhtml += segmenttemplate(_s); |
89 var vizdata = { |
145 var vizdata = { |
90 left: k * t, |
146 left: k * t, |
91 width: k * _s.duration, |
147 width: k * _s.duration, |
92 color: _s.getMedia().color, |
148 color: _s.getMedia().color, |
93 segmentid: _s.annotation.id |
149 segmentid: _s.annotation.id |
94 } |
150 } |
95 vizhtml += viztemplate(vizdata); |
151 vizhtml += viztemplate(vizdata); |
|
152 if (_s.annotation.status === "critical") { |
|
153 critical = true; |
|
154 } |
96 t += _s.duration.milliseconds; |
155 t += _s.duration.milliseconds; |
97 }); |
156 }); |
|
157 if (critical) { |
|
158 messages.push("Certains segments ne sont pas valides"); |
|
159 } |
|
160 |
|
161 _(mashupcritical).each(function(sc) { |
|
162 if (!sc.validate(mashup)) { |
|
163 critical = true; |
|
164 messages.push(sc.message); |
|
165 } |
|
166 }); |
|
167 _(mashupwarning).each(function(sc) { |
|
168 if (!sc.validate(mashup)) { |
|
169 warning = true; |
|
170 messages.push(sc.message); |
|
171 } |
|
172 }); |
|
173 mashup.status = critical ? "critical" : (warning ? "warning" : "valid"); |
|
174 if (!messages.length) { |
|
175 messages.push("Le hashcut est valide !"); |
|
176 } |
|
177 $(".publier-button").toggleClass("disable", critical); |
|
178 |
|
179 $(".liste-segment .validate").removeClass("critical warning valid").addClass(mashup.status); |
|
180 $(".liste-segment .validate-tooltip").html("<ul><li>" + messages.join("</li><li>")+"</li></ul>"); |
98 |
181 |
99 var intervals = [ 1000, 2000, 5000, 10000, 30000, 60000, 120000, 300000, 600000, 900000, 1800000, 3600000, 7200000 ]; |
182 var intervals = [ 1000, 2000, 5000, 10000, 30000, 60000, 120000, 300000, 600000, 900000, 1800000, 3600000, 7200000 ]; |
100 |
183 |
101 function createIntervals(maxn) { |
184 function createIntervals(maxn) { |
102 for (var i = 0; i < intervals.length; i++) { |
185 for (var i = 0; i < intervals.length; i++) { |
433 |
516 |
434 /* Set current Media */ |
517 /* Set current Media */ |
435 |
518 |
436 var currentMedia, currentSegment; |
519 var currentMedia, currentSegment; |
437 |
520 |
438 function updateSliderAndTangles() { |
521 function updateSegmentUI() { |
439 if (currentMedia && currentSegment) { |
522 if (currentMedia && currentSegment) { |
440 var start = currentSegment.begin, |
523 var start = currentSegment.begin, |
441 end = currentSegment.end, |
524 end = currentSegment.end, |
442 dur = currentSegment.getDuration(), |
525 dur = currentSegment.getDuration(), |
443 f = slidersRange / currentMedia.duration, |
526 f = slidersRange / currentMedia.duration, |
448 p = k * (start + end) / 2; |
531 p = k * (start + end) / 2; |
449 sliceSlider.slider( "values", [ f * start, f * end ] ); |
532 sliceSlider.slider( "values", [ f * start, f * end ] ); |
450 tangleStart.text(start.toString(tangleStart.hasClass("active"))).attr("data-milliseconds",start.milliseconds); |
533 tangleStart.text(start.toString(tangleStart.hasClass("active"))).attr("data-milliseconds",start.milliseconds); |
451 tangleEnd.text(end.toString(tangleEnd.hasClass("active"))).attr("data-milliseconds",end.milliseconds); |
534 tangleEnd.text(end.toString(tangleEnd.hasClass("active"))).attr("data-milliseconds",end.milliseconds); |
452 tangleDuration.text(dur.toString(tangleDuration.hasClass("active"))).attr("data-milliseconds",dur.milliseconds); |
535 tangleDuration.text(dur.toString(tangleDuration.hasClass("active"))).attr("data-milliseconds",dur.milliseconds); |
453 $(".segment-info .pointer").css("left", p + "%"); |
536 $(".segmentation .pointer").css("left", p + "%"); |
454 $(".media-current-section").css({ |
537 $(".media-current-section").css({ |
455 left: (k * start) + "%", |
538 left: (k * start) + "%", |
456 width: (k * dur) + "%" |
539 width: (k * dur) + "%" |
457 }) |
540 }); |
|
541 var messages = [], |
|
542 critical = false, |
|
543 warning = false; |
|
544 _(segmentcritical).each(function(sc) { |
|
545 if (!sc.validate(currentSegment)) { |
|
546 critical = true; |
|
547 messages.push(sc.message); |
|
548 } |
|
549 }); |
|
550 _(segmentwarning).each(function(sc) { |
|
551 if (!sc.validate(currentSegment)) { |
|
552 warning = true; |
|
553 messages.push(sc.message); |
|
554 } |
|
555 }); |
|
556 currentSegment.status = critical ? "critical" : (warning ? "warning" : "valid"); |
|
557 if (!messages.length) { |
|
558 messages.push("Le segment est valide !") |
|
559 } |
|
560 currentSegment.status_messages = messages; |
|
561 |
|
562 $(".segmentation .validate").removeClass("critical warning valid").addClass(currentSegment.status); |
|
563 $(".segmentation .validate-tooltip").html("<ul><li>" + currentSegment.status_messages.join("</li><li>")+"</li></ul>"); |
458 } |
564 } |
459 } |
565 } |
460 |
566 |
461 var addMode; |
567 var addMode; |
462 |
568 |
482 if (!currentSegment) { |
588 if (!currentSegment) { |
483 currentSegment = new IriSP.Model.Annotation(false, project); |
589 currentSegment = new IriSP.Model.Annotation(false, project); |
484 currentSegment.setMedia(currentMedia.id); |
590 currentSegment.setMedia(currentMedia.id); |
485 currentSegment.setBegin(0); |
591 currentSegment.setBegin(0); |
486 currentSegment.setEnd(currentMedia.duration); |
592 currentSegment.setEnd(currentMedia.duration); |
487 currentSegment.title = "Segment sans titre"; |
593 currentSegment.title = IriSP.hc_messages.segment_title_placeholder; |
488 currentSegment.description = "Extrait de « " + currentMedia.title + " »"; |
594 currentSegment.description = ""; |
489 currentSegment.on("change-begin", function() { |
595 currentSegment.on("change-begin", function() { |
490 if (currentMedia && currentSegment === this) { |
596 if (currentMedia && currentSegment === this) { |
491 currentMedia.setCurrentTime(this.begin); |
597 currentMedia.setCurrentTime(this.begin); |
492 updateSliderAndTangles(); |
598 updateSegmentUI(); |
493 } |
599 } |
494 }); |
600 }); |
495 currentSegment.on("change-end", function() { |
601 currentSegment.on("change-end", function() { |
496 if (currentMedia && currentSegment === this) { |
602 if (currentMedia && currentSegment === this) { |
497 currentMedia.setCurrentTime(this.end); |
603 currentMedia.setCurrentTime(this.end); |
498 updateSliderAndTangles(); |
604 updateSegmentUI(); |
499 } |
605 } |
500 }); |
606 }); |
501 currentSegment.on("enter", function() { |
607 currentSegment.on("enter", function() { |
502 if (currentMedia === mashup) { |
608 if (currentMedia === mashup) { |
503 $(".annotation-title").text(this.title); |
609 $(".annotation-title").text(this.title); |
798 /* Segment Form interaction */ |
904 /* Segment Form interaction */ |
799 |
905 |
800 $("#segment-title").on("keyup change input paste", function() { |
906 $("#segment-title").on("keyup change input paste", function() { |
801 if (currentMedia && currentSegment) { |
907 if (currentMedia && currentSegment) { |
802 currentSegment.title = $(this).val(); |
908 currentSegment.title = $(this).val(); |
|
909 updateSegmentUI(); |
803 updateMashupUI(); |
910 updateMashupUI(); |
804 } |
911 } |
805 }); |
912 }); |
806 $("#segment-description").on("keyup change input paste", function() { |
913 $("#segment-description").on("keyup change input paste", function() { |
807 if (currentMedia && currentSegment) { |
914 if (currentMedia && currentSegment) { |
808 currentSegment.description = $(this).val(); |
915 currentSegment.description = $(this).val(); |
|
916 updateSegmentUI(); |
809 } |
917 } |
810 }); |
918 }); |
811 $("#segment-form").submit(function() { |
919 $("#segment-form").submit(function() { |
812 if (addMode) { |
920 if (addMode) { |
813 mashup.addAnnotation(currentSegment); |
921 mashup.addAnnotation(currentSegment); |