27 $('.timeline-annotations').on('click', '.annotation', function(e){ |
27 $('.timeline-annotations').on('click', '.annotation', function(e){ |
28 e.preventDefault(); |
28 e.preventDefault(); |
29 var idAnnotation = $(this).attr('data-id'), |
29 var idAnnotation = $(this).attr('data-id'), |
30 annotation = _.find(annotations, function(c){ return c.id == idAnnotation; }); |
30 annotation = _.find(annotations, function(c){ return c.id == idAnnotation; }); |
31 myMedia.setCurrentTime(annotation.begin); |
31 myMedia.setCurrentTime(annotation.begin); |
32 openTab(annotation.type, annotation); |
32 if($('#tab-annotation-'+idAnnotation).length){ |
|
33 $('a[href=#tab-annotation-'+idAnnotation+']').tab('show'); |
|
34 }else{ |
|
35 openTab(annotation.type, annotation); |
|
36 } |
33 }); |
37 }); |
34 |
38 |
35 myProject.onLoad(function() { |
39 myProject.onLoad(function() { |
36 myProject.regenerateTags = true; |
40 myProject.regenerateTags = true; |
37 |
41 |
84 controls: true, |
88 controls: true, |
85 autostart: true, |
89 autostart: true, |
86 url_transform: function(src) { |
90 url_transform: function(src) { |
87 return [{ |
91 return [{ |
88 type: "video/mp4", |
92 type: "video/mp4", |
89 src: src.replace(/\.[\d\w]+$/,'.mp4') |
93 src: src.replace(/\.[\d\w]+$/,'.mp4').replace('rtmp://media.iri.centrepompidou.fr/ddc_player', 'http://media.iri.centrepompidou.fr') |
90 }, { |
94 }, { |
91 type: "video/webm", |
95 type: "video/webm", |
92 src: src.replace(/\.[\d\w]+$/,'.webm') |
96 src: src.replace(/\.[\d\w]+$/,'.webm').replace('rtmp://media.iri.centrepompidou.fr/ddc_player', 'http://media.iri.centrepompidou.fr') |
93 }]; |
97 }]; |
94 } |
98 } |
95 } |
99 } |
96 ); |
100 ); |
97 |
101 |
123 $.each(annotations, function(k, v){ |
127 $.each(annotations, function(k, v){ |
124 |
128 |
125 if(v.begin <= t && v.end >= t){ |
129 if(v.begin <= t && v.end >= t){ |
126 currentAnnotationsDisplay.push(v.id); |
130 currentAnnotationsDisplay.push(v.id); |
127 if(!$('#item-current-annotation-'+v.id).length){ |
131 if(!$('#item-current-annotation-'+v.id).length){ |
128 var itemAnnotation = |
132 var itemAnnotation = getTemplate('#tpl-item-annotation-display'); |
129 $('<li>') |
133 itemAnnotation = Mustache.render(itemAnnotation, v); |
130 .attr('id', 'item-current-annotation-'+v.id) |
|
131 .attr('data-id', v.id) |
|
132 .append( |
|
133 $('<a>') |
|
134 .css('backgroundColor', v.color) |
|
135 .attr('data-id', v.id) |
|
136 .attr('href', '#') |
|
137 .append( |
|
138 $('<i>').addClass('icon-'+getIcon(v.type)) |
|
139 ) |
|
140 ); |
|
141 $('.list-current-annotations').append(itemAnnotation) |
134 $('.list-current-annotations').append(itemAnnotation) |
142 } |
135 } |
143 } |
136 } |
144 }); |
137 }); |
145 $.each($('.list-current-annotations li'), function(k, v){ |
138 $.each($('.list-current-annotations li'), function(k, v){ |
156 showCurrentAnnotationInTimeline(currentAnnotation.id); |
149 showCurrentAnnotationInTimeline(currentAnnotation.id); |
157 } |
150 } |
158 } |
151 } |
159 |
152 |
160 function showCurrentAnnotationInTimeline(idAnnotation){ |
153 function showCurrentAnnotationInTimeline(idAnnotation){ |
161 $('.timeline-annotations .annotation span').hide(); |
154 $('.annotation').removeClass('editing'); |
162 $('#annotation-timeline-'+idAnnotation+' span').show(); |
155 $('#annotation-timeline-'+idAnnotation).addClass('editing'); |
163 } |
156 } |
164 //display annotation view |
157 //display annotation view |
165 $('.list-current-annotations').on('click', 'a', function(e){ |
158 $('.list-current-annotations').on('click', 'a', function(e){ |
166 e.preventDefault(); |
159 e.preventDefault(); |
167 var annotationDisplayView = $('.annotation-display-view'), |
160 var annotationDisplayView = $('.annotation-display-view'), |
247 currentChapter[name] = value; |
240 currentChapter[name] = value; |
248 if(name == 'title'){ |
241 if(name == 'title'){ |
249 var idChapter = $(this).parents('form').attr('data-chapter-id'); |
242 var idChapter = $(this).parents('form').attr('data-chapter-id'); |
250 $('.chapter-segments').find('#'+idChapter).text(value); |
243 $('.chapter-segments').find('#'+idChapter).text(value); |
251 $('#row-list-chapter-'+idChapter).find('td:first').text(value); |
244 $('#row-list-chapter-'+idChapter).find('td:first').text(value); |
|
245 $(this).parents('form').find('.btn-delete-chapter').attr('data-title', value); |
252 } |
246 } |
253 }); |
247 }); |
254 |
248 |
255 |
249 |
256 |
250 |
278 |
272 |
279 function getTemplate(idTpl){ |
273 function getTemplate(idTpl){ |
280 return $('#templates').find(idTpl).html(); |
274 return $('#templates').find(idTpl).html(); |
281 } |
275 } |
282 //supprimer |
276 //supprimer |
283 $('.list-chapter-wrap').on('click', '.btn-delete-chapter', function(e){ |
277 $(document).on('click', '.btn-delete-chapter', function(e){ |
284 e.preventDefault(); |
278 e.preventDefault(); |
285 |
279 |
286 if(chapters.length == 1){alert('Le projet doit contenir au moins un chapitre.'); return;} |
280 if(chapters.length == 1){alert('Le projet doit contenir au moins un chapitre.'); return;} |
287 var idChapter = $(this).attr('data-chapter-id'), |
281 var idChapter = $(this).attr('data-chapter-id'), |
288 btnDeleteModal = $("#modal-confirm #btn-delete-modal"); |
282 btnDeleteModal = $("#modal-confirm #btn-delete-modal"); |
289 btnDeleteModal.attr('data-type-delete', 'chapter'); |
283 btnDeleteModal.attr('data-type-delete', 'chapter'); |
290 btnDeleteModal.attr('data-id', idChapter); |
284 btnDeleteModal.attr('data-id', idChapter); |
291 |
285 |
292 }); |
286 }); |
|
287 $(document).on('click', '.btn-ok-chapter', function(e){ |
|
288 e.preventDefault(); |
|
289 $('.form-chapter-edit').remove(); |
|
290 }) |
293 |
291 |
294 function deleteChapter(idChapter){ |
292 function deleteChapter(idChapter){ |
295 disabledPreview(); |
293 disabledPreview(); |
296 $("#modal-confirm").modal('hide'); |
294 $("#modal-confirm").modal('hide'); |
297 var chapter = _.find(chapters, function(c){ return c.id == idChapter; }), |
295 var chapter = _.find(chapters, function(c){ return c.id == idChapter; }), |
337 |
335 |
338 $('.chapter-widget').on('click', '.btn-cut-chapter', function(e){ |
336 $('.chapter-widget').on('click', '.btn-cut-chapter', function(e){ |
339 e.preventDefault(); |
337 e.preventDefault(); |
340 |
338 |
341 var dataChapter = { |
339 var dataChapter = { |
342 title : 'New', |
340 title : 'New', |
343 begin : myMedia.currentTime, |
341 begin : myMedia.currentTime, |
344 end : organizeNewChapter(myMedia.currentTime), |
342 end : organizeNewChapter(myMedia.currentTime), |
345 description : 'description', |
343 description : 'description', |
346 keywords : ['tag1','tag2'] |
344 keywords : ['tag1','tag2'] |
347 }; |
345 }; |
348 |
346 |
349 newChapter(dataChapter, true); |
347 newChapter(dataChapter, true); |
350 |
348 |
351 }); |
349 }); |
352 |
350 |
445 left = Math.floor(v.begin * wTimeline / myMedia.duration), |
443 left = Math.floor(v.begin * wTimeline / myMedia.duration), |
446 dataAnntim = { |
444 dataAnntim = { |
447 left : left, |
445 left : left, |
448 width : width, |
446 width : width, |
449 color : v.color, |
447 color : v.color, |
450 id : v.id |
448 id : v.id, |
|
449 title : v.title |
451 }, |
450 }, |
452 segment = getTemplate('#tpl-annotation-in-timeline'); |
451 segment = getTemplate('#tpl-annotation-in-timeline'); |
453 segment = Mustache.render(segment, dataAnntim); |
452 segment = Mustache.render(segment, dataAnntim); |
454 |
453 |
455 /* |
454 |
456 segment = $('<a>').css({ |
|
457 left : left, |
|
458 width : width, |
|
459 backgroundColor : v.color |
|
460 }).addClass('annotation') |
|
461 .attr('data-id', v.id) |
|
462 .attr('id', 'annotation-timeline-'+v.id); |
|
463 */ |
|
464 var isInTimeline = false; |
455 var isInTimeline = false; |
465 $.each(timeline.find('li'), function(a, b){ |
456 $.each(timeline.find('li'), function(a, b){ |
466 if(isInTimeline) return; |
457 if(isInTimeline) return; |
467 var row = $(this); |
458 var row = $(this); |
468 if(row.children().length){ |
459 if(row.children().length){ |
523 currentAnnotation[name] = value; |
514 currentAnnotation[name] = value; |
524 if(name == 'title'){ |
515 if(name == 'title'){ |
525 var idAnnotation = $(this).parents('form').attr('data-id'); |
516 var idAnnotation = $(this).parents('form').attr('data-id'); |
526 $('#onglet-title-'+idAnnotation).text(value); |
517 $('#onglet-title-'+idAnnotation).text(value); |
527 $(this).parents('form').find('.btn-delete-annotation').attr('data-title', value); |
518 $(this).parents('form').find('.btn-delete-annotation').attr('data-title', value); |
|
519 $('#annotation-timeline-'+ idAnnotation+' span').text(value); |
528 } |
520 } |
529 }); |
521 }); |
530 |
522 |
531 //delete annotation |
523 //delete annotation |
532 $(document).on('click','.btn-delete-annotation', function(e){ |
524 $(document).on('click','.btn-delete-annotation', function(e){ |
562 |
554 |
563 function openTab(type, data){ |
555 function openTab(type, data){ |
564 |
556 |
565 var dataView; |
557 var dataView; |
566 if(_.isUndefined(data)){//nouveau |
558 if(_.isUndefined(data)){//nouveau |
|
559 |
567 var currentTimePlusUnMin = 60 * 1000 + myMedia.currentTime, |
560 var currentTimePlusUnMin = 60 * 1000 + myMedia.currentTime, |
568 endAnnotation = (currentTimePlusUnMin<myMedia.duration) ? currentTimePlusUnMin : myMedia.duration; |
561 endAnnotation = (currentTimePlusUnMin<myMedia.duration) ? currentTimePlusUnMin : myMedia.duration; |
569 var dataAnnotation = { |
562 var dataAnnotation = { |
570 title : '', |
563 title : '', |
571 begin : myMedia.currentTime, |
564 begin : myMedia.currentTime, |
633 addLinkRow(tbody); |
626 addLinkRow(tbody); |
634 } |
627 } |
635 break; |
628 break; |
636 |
629 |
637 case 'slideshow': |
630 case 'slideshow': |
|
631 console.log(currentAnnotation) |
638 $(tabContent).find('.number-spin').val(dataView.content.slideduration/1000); |
632 $(tabContent).find('.number-spin').val(dataView.content.slideduration/1000); |
639 $(tabContent).find('.number-spin').spin(spinParam); |
633 $(tabContent).find('.number-spin').spin(spinParam); |
640 $(tabContent).find('.ui-sortable').sortable({ |
634 $(tabContent).find('.ui-sortable').sortable({ |
641 start: function (event, ui) { |
635 start: function (event, ui) { |
642 $(ui.item).data("startindex", ui.item.index()); |
636 $(ui.item).data("startindex", ui.item.index()); |
867 row.remove(); |
861 row.remove(); |
868 updateLinks(tbody); |
862 updateLinks(tbody); |
869 }); |
863 }); |
870 function addLinkRow(tbody, dataView){ |
864 function addLinkRow(tbody, dataView){ |
871 |
865 |
872 //head commun à tous |
866 //head commun à tous |
873 var tplLinkRow = getTemplate('#tpl-links-row'); |
867 var tplLinkRow = getTemplate('#tpl-links-row'); |
874 var output = Mustache.render(tplLinkRow, dataView); |
868 var output = Mustache.render(tplLinkRow, dataView); |
875 tbody.append(output); |
869 tbody.append(output); |
876 |
870 |
877 } |
871 } |
878 $('.tab-content').on('keyup', '.links-rows input', function(e){ |
872 $('.tab-content').on('keyup', '.links-rows input', function(e){ |
879 var tbody = $(this).parents('.links-rows'); |
873 var tbody = $(this).parents('.links-rows'); |
880 updateLinks(tbody); |
874 updateLinks(tbody); |
920 |
914 |
921 //save project |
915 //save project |
922 $('.btn-save-project').bind('click', function(e){ |
916 $('.btn-save-project').bind('click', function(e){ |
923 $('.btn-apercu-projet').removeClass('disabled'); |
917 $('.btn-apercu-projet').removeClass('disabled'); |
924 |
918 |
925 console.log(JSON.parse(myProject.serialize())); |
919 console.log(myProject.serialize()); |
926 /* |
920 |
927 $.ajax({ |
921 $.ajax({ |
928 type: "POST", |
922 type: "POST", |
929 url: urlSaveProject, |
923 url: urlSaveProject, |
930 data: myProject.serialize(), |
924 data: myProject.serialize(), |
931 contentType: "application/cinelab", |
925 contentType: "application/cinelab", |
932 headers: { |
926 headers: { |
933 //"X-CSRFToken": options.csrf_token |
927 "X-CSRFToken": tokenSaveProject |
934 }, |
928 }, |
935 success: function(data, status, request){ |
929 success: function(data, status, request){ |
936 console.log('data : ', data); |
930 console.log('data : ', data); |
937 console.log('status : ', status); |
931 console.log('status : ', status); |
938 console.log('request : ', request); |
932 console.log('request : ', request); |
940 }, |
934 }, |
941 error: function(jqXHR, textStatus, errorThrown){ |
935 error: function(jqXHR, textStatus, errorThrown){ |
942 alert(gettext("Server error\nYour hashcut couldn't be published")); |
936 alert(gettext("Server error\nYour hashcut couldn't be published")); |
943 } |
937 } |
944 }); |
938 }); |
945 */ |
939 |
946 |
940 |
947 }); |
941 }); |
948 |
942 |
949 function disabledPreview(){ |
943 function disabledPreview(){ |
950 if(!$('.btn-apercu-projet').hasClass('disabled'))$('.btn-apercu-projet').addClass('disabled'); |
944 if(!$('.btn-apercu-projet').hasClass('disabled'))$('.btn-apercu-projet').addClass('disabled'); |