1 |
|
2 IriSP.hc_messages = { |
|
3 Duration_ : "Durée :", |
|
4 duration_ : "durée :", |
|
5 edit_segment: "Éditer le segment", |
|
6 segment_down: "Descendre le segment", |
|
7 segment_up: "Remonter le segment", |
|
8 delete_segment: "Supprimer le segment", |
|
9 clone_segment: "Cloner le segment", |
|
10 From_: "De :", |
|
11 to_: "à :", |
|
12 segment_title_placeholder: "Segment sans titre", |
|
13 mashup_title_placeholder: "Hashcut sans titre", |
|
14 copy_of_: "Copie de ", |
|
15 } |
|
16 |
|
17 IriSP.editor = function(options) { |
1 IriSP.editor = function(options) { |
18 |
2 |
19 /* Load Media List */ |
3 /* Load Media List */ |
20 |
4 |
21 var directory = new IriSP.Model.Directory(), |
5 var directory = new IriSP.Model.Directory(), |
22 apidirectory = new IriSP.Model.Directory(), |
6 apidirectory = new IriSP.Model.Directory(), |
23 project = directory.remoteSource({ |
7 project = directory.remoteSource({ |
|
8 url: IriSP.endpoints.content, |
|
9 url_params: _({}).extend(options.filter), |
|
10 serializer: IriSP.serializers.content |
|
11 }), |
|
12 /* project = directory.remoteSource({ |
24 url: options.url, |
13 url: options.url, |
25 serializer: IriSP.serializers.medialist |
14 serializer: IriSP.serializers.medialist |
26 }), |
15 }), |
|
16 */ |
27 mashup = new IriSP.Model.Mashup(false, project), |
17 mashup = new IriSP.Model.Mashup(false, project), |
28 mediatemplate = _.template( |
18 mediatemplate = _.template( |
29 '<li class="item-video media" data-media-id="<%= id %>"><div class="media-count-wrap"><span class="media-count"></span></div>' |
19 '<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 %>" />' |
20 + '<img class="thumbnail" src="<%= thumbnail %>" alt="<%= title %>" />' |
31 + '<div class="video-info"><h3 class="title-video"><%= title %></h3><p class="description"><%= description %></p>' |
21 + '<div class="video-info"><h3 class="title-video"><%= title %></h3><p class="description"><%= description %></p>' |
32 + '<p class="time-length"><%= IriSP.hc_messages.Duration_ %> <span><%= duration.toString() %></span></p></div><div class="media-found-segments"></div></li>' |
22 + '<p class="time-length"><%= IriSP.translate("Duration:") %> <span><%= duration.toString() %></span></p></div><div class="media-found-segments"></div></li>' |
33 ), |
23 ), |
34 segmenttemplate = _.template( |
24 segmenttemplate = _.template( |
35 '<li class="item-video annotation" data-segment-id="<%= annotation.id %>" data-media-id="<%= annotation.getMedia().id %>">' |
25 '<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 %>" />' |
26 + '<img class="thumbnail" src="<%= annotation.thumbnail %>" alt="<%= annotation.getMedia().title %>" />' |
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>' |
27 + '<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>' |
28 + '<p class="subtitle"><%= annotation.title %></p><p class="duration"><%= annotation.begin.toString() %> - <%= annotation.end.toString() %> (<%= annotation.getDuration().toString() %>)</p>' |
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>' |
29 + '<ul class="tools"><li><a class="edit" href="#" title="<%= IriSP.translate("Edit segment") %>"></a></li><li><a class="bottom" href="#" title="<%= IriSP.translate("Move segment down") %>"></a></li>' |
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>' |
30 + '<li><a class="top" href="#" title="<%= IriSP.translate("Move segment up") %>"></a></li><li><a class="delete" href="#" title="<%= IriSP.translate("Delete segment") %>"></a></li></ul></div></li>' |
41 ), |
31 ), |
42 mediasegmenttemplate = _.template( |
32 mediasegmenttemplate = _.template( |
43 '<div class="media-segment">' |
33 '<div class="media-segment">' |
44 + '<div class="media-segment-section" style="left:<%= left %>px; width:<%= width %>px; background:<%= color %>; top: <%= top %>px;"></div>' |
34 + '<div class="media-segment-section" style="left:<%= left %>px; width:<%= width %>px; background:<%= color %>; top: <%= top %>px;" data-segment-id="<%= annotation.id %>"></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">' |
35 + '<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">' |
46 + '<h3><%= annotation.title %></h3><a href="#" class="button reprendre-segment" data-segment-id="<%= annotation.id %>"><%= IriSP.hc_messages.clone_segment %></a>' |
36 + '<h3><%= annotation.title %></h3><a href="#" class="button reprendre-segment" data-segment-id="<%= annotation.id %>"><%= IriSP.translate("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>' |
37 + '<p><%= IriSP.translate("From:") %> <span><%= annotation.begin.toString() %></span> <%= IriSP.translate("to:") %> <span><%= annotation.end.toString() %></span> (<%= IriSP.translate("duration:") %> <span><%= annotation.getDuration().toString() %></span>)</p>' |
48 + '</div></div></div>' |
38 + '</div></div></div>' |
49 ), |
39 ), |
50 mediasegmentlisttemplate = _.template( |
40 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>' |
41 '<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 ), |
42 ), |
53 mediafoundtemplate = _.template( |
43 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>' |
44 '<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">' |
45 + '<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>' |
46 + '<h3><%= title %></h3><a href="#" class="button clone-segment" data-segment-id="<%= annotation.id %>"><%= IriSP.translate("Clone segment") %></a>' |
57 + '</div></div></div>' |
47 + '</div></div></div>' |
58 ), |
48 ), |
59 mediafoundlisttemplate = _.template( |
49 mediafoundlisttemplate = _.template( |
60 '<div class="media-found-list" style="height: <%= height %>px"><div class="media-segment-list-inner"></div><%= segments %></div>' |
50 '<div class="media-found-list" style="height: <%= height %>px"><div class="media-segment-list-inner"></div><%= segments %></div>' |
61 ), |
51 ), |
71 var segmentcritical = [ |
61 var segmentcritical = [ |
72 { |
62 { |
73 validate: function(_s) { |
63 validate: function(_s) { |
74 return (_s.getDuration() >= 1000); |
64 return (_s.getDuration() >= 1000); |
75 }, |
65 }, |
76 message: "Le segment doit durer au moins une seconde" |
66 message: "A segment must be at least one second long" |
77 }, |
67 }, |
78 { |
68 { |
79 validate: function(_s) { |
69 validate: function(_s) { |
80 return (_s.getDuration() < 180000); |
70 return (_s.getDuration() < 180000); |
81 }, |
71 }, |
82 message: "Le segment doit durer moins de trois minutes" |
72 message: "A segment must be at most three minutes long" |
83 }, |
73 }, |
84 { |
74 { |
85 validate: function(_s) { |
75 validate: function(_s) { |
86 return (!!_s.title && _s.title !== IriSP.hc_messages.segment_title_placeholder); |
76 return (!!_s.title && _s.title !== IriSP.translate("Untitled segment")); |
87 }, |
77 }, |
88 message: "Le segment doit avoir un titre" |
78 message: "A segment must have a title" |
89 } |
79 } |
90 ]; |
80 ]; |
91 var segmentwarning = [ |
81 var segmentwarning = [ |
92 { |
82 { |
93 validate: function(_s) { |
83 validate: function(_s) { |
94 return (!!_s.description); |
84 return (!!_s.description); |
95 }, |
85 }, |
96 message: "Il est recommandé de donner une description au segment" |
86 message: "A segment should have a description" |
97 }, |
87 }, |
98 { |
88 { |
99 validate: function(_s) { |
89 validate: function(_s) { |
100 return (!!_s.keywords.length); |
90 return (!!_s.keywords.length); |
101 }, |
91 }, |
102 message: "Il est recommandé de tagguer le segment" |
92 message: "A segment should have tags" |
103 } |
93 } |
104 ]; |
94 ]; |
105 |
95 |
106 var mashupcritical = [ |
96 var mashupcritical = [ |
107 { |
97 { |
108 validate: function(_m) { |
98 validate: function(_m) { |
109 return _m.segments.length > 2; |
99 return _m.segments.length > 2; |
110 }, |
100 }, |
111 message: "Un hashcut doit être composé d'au moins trois segments" |
101 message: "A hashcut must be made from at least three segments" |
112 }, |
102 }, |
113 { |
103 { |
114 validate: function(_m) { |
104 validate: function(_m) { |
115 return (!!_m.title && _m.title !== IriSP.hc_messages.mashup_title_placeholder); |
105 return (!!_m.title && _m.title !== IriSP.translate("Untitled Hashcut")); |
116 }, |
106 }, |
117 message: "Un titre doit être donné au hashcut" |
107 message: "A hashcut must have a title" |
118 } |
108 } |
119 ]; |
109 ]; |
120 var mashupwarning = [ |
110 var mashupwarning = [ |
121 { |
111 { |
122 validate: function(_m) { |
112 validate: function(_m) { |
123 return !!_m.description |
113 return !!_m.description |
124 }, |
114 }, |
125 message: "Il est recommandé de donner une description au hashcut" |
115 message: "A hashcut should have a description" |
126 } |
116 } |
127 ]; |
117 ]; |
128 |
118 |
129 /* Fill left column with Media List */ |
119 /* Fill left column with Media List */ |
130 |
120 |
386 if (!currentSegment) { |
376 if (!currentSegment) { |
387 currentSegment = new IriSP.Model.Annotation(false, project); |
377 currentSegment = new IriSP.Model.Annotation(false, project); |
388 currentSegment.setMedia(currentMedia.id); |
378 currentSegment.setMedia(currentMedia.id); |
389 currentSegment.setBegin(currentMedia.getCurrentTime()); |
379 currentSegment.setBegin(currentMedia.getCurrentTime()); |
390 currentSegment.setEnd(Math.min(currentMedia.getCurrentTime() + 180000, currentMedia.duration)); |
380 currentSegment.setEnd(Math.min(currentMedia.getCurrentTime() + 180000, currentMedia.duration)); |
391 currentSegment.title = IriSP.hc_messages.segment_title_placeholder; |
381 currentSegment.title = IriSP.translate("Untitled segment"); |
392 currentSegment.color = currentMedia.color; |
382 currentSegment.color = currentMedia.color; |
393 currentSegment.thumbnail = currentMedia.thumbnail; |
383 currentSegment.thumbnail = currentMedia.thumbnail; |
394 currentSegment.created = new Date(); |
384 currentSegment.created = new Date(); |
395 currentSegment.keywords = []; |
385 currentSegment.keywords = []; |
396 currentSegment.description = ""; |
386 currentSegment.description = ""; |
761 }).on("mouseout", ".media-segment", function() { |
752 }).on("mouseout", ".media-segment", function() { |
762 $(this).find(".media-segment-popin").hide(); |
753 $(this).find(".media-segment-popin").hide(); |
763 }).on("click", ".reprendre-segment", function() { |
754 }).on("click", ".reprendre-segment", function() { |
764 cloneSegment($(this).attr("data-segment-id")); |
755 cloneSegment($(this).attr("data-segment-id")); |
765 return false; |
756 return false; |
|
757 }).on("click", ".media-segment-section", function() { |
|
758 var sid = $(this).attr("data-segment-id"), |
|
759 s = directory.getElement(sid) || apidirectory.getElement(sid); |
|
760 if (s.media.id === currentMedia.id) { |
|
761 currentMedia.setCurrentTime(s.begin); |
|
762 } |
766 }); |
763 }); |
767 |
764 |
768 $(".col-left").on("mouseover", ".media-segment", function() { |
765 $(".col-left").on("mouseover", ".media-segment", function() { |
769 $(this).find(".media-found-popin").show(); |
766 $(this).find(".media-found-popin").show(); |
770 }).on("mouseout", ".media-segment", function() { |
767 }).on("mouseout", ".media-segment", function() { |
773 cloneSegment($(this).attr("data-segment-id")); |
770 cloneSegment($(this).attr("data-segment-id")); |
774 return false; |
771 return false; |
775 }); |
772 }); |
776 /* Changing Hashcut Title and description */ |
773 /* Changing Hashcut Title and description */ |
777 |
774 |
778 mashup.title = IriSP.hc_messages.mashup_title_placeholder; |
775 mashup.title = IriSP.translate("Untitled Hashcut"); |
779 $(".title-video-wrap a").text(mashup.title); |
776 $(".title-video-wrap a").text(mashup.title); |
780 $("#hashcut-title").val(mashup.title); |
777 $("#hashcut-title").val(mashup.title); |
781 |
778 |
782 $("#hashcut-title").on("keyup change input paste", function() { |
779 $("#hashcut-title").on("keyup change input paste", function() { |
783 mashup.title = $(this).val(); |
780 mashup.title = $(this).val(); |
784 $(".title-video-wrap a").text(mashup.title); |
781 $(".title-video-wrap a").text(mashup.title); |
785 mashup.trigger("change"); |
782 mashup.trigger("change"); |
786 }); |
783 }); |
787 $("#hashcut-title").on("focus click", function() { |
784 $("#hashcut-title").on("focus click", function() { |
788 if ($(this).val() === IriSP.hc_messages.mashup_title_placeholder) { |
785 if ($(this).val() === IriSP.translate("Untitled Hashcut")) { |
789 $(this).val(""); |
786 $(this).val(""); |
790 } |
787 } |
791 }); |
788 }); |
792 |
789 |
793 $("#hashcut-description").on("keyup change input paste", function() { |
790 $("#hashcut-description").on("keyup change input paste", function() { |
845 postproject.modified = new Date(); |
848 postproject.modified = new Date(); |
846 postproject.title = mashup.title; |
849 postproject.title = mashup.title; |
847 postproject.description = mashup.description; |
850 postproject.description = mashup.description; |
848 $.ajax({ |
851 $.ajax({ |
849 type: "POST", |
852 type: "POST", |
850 url: options.project_api_endpoint, |
853 url: IriSP.endpoints.project, |
851 data: IriSP.serializers.ldt.serialize(postproject), |
854 data: IriSP.serializers.ldt.serialize(postproject), |
852 contentType: "application/cinelab", |
855 contentType: "application/cinelab", |
853 // headers: {"X-CSRFToken": "{{csrf_token}}"}, |
856 // headers: {"X-CSRFToken": "{{csrf_token}}"}, |
854 success: function(data, status, request){ |
857 success: function(data, status, request){ |
855 console.log(request.getResponseHeader("Location")); |
858 var location = request.getResponseHeader("Location"), |
|
859 projid = location.match(/([^/]+)\/?$/)[1], |
|
860 destination = IriSP.endpoints.hashcut_page + projid; |
|
861 $(window).off("beforeunload", onLeave); |
|
862 document.location.href = destination; |
856 }, |
863 }, |
857 error: function(jqXHR, textStatus, errorThrown){ |
864 error: function(jqXHR, textStatus, errorThrown){ |
858 alert(errorThrown); |
865 console.log(arguments); |
859 } |
866 alert(IriSP.translate("Server error\nYour hashcut couldn't be published")); |
860 }); |
867 } |
|
868 }); |
|
869 //TODO: ADD WAITING SCREEN |
|
870 |
861 return false; |
871 return false; |
862 }); |
872 }); |
863 |
873 |
864 mashup.trigger("change"); |
874 mashup.trigger("change"); |
865 } |
875 } |