149 } |
150 } |
150 } |
151 } |
151 |
152 |
152 function showCurrentAnnotationInTimeline(idAnnotation){ |
153 function showCurrentAnnotationInTimeline(idAnnotation){ |
153 $('.timeline-annotations .annotation').empty(); |
154 $('.timeline-annotations .annotation').empty(); |
154 $('#annotation-timeline-'+idAnnotation).text('en cours'); |
155 $('#annotation-timeline-'+idAnnotation).html('<i class="icon-pencil"></i> '+textCurrentAnnotationEditT); |
155 } |
156 } |
156 //display annotation view |
157 //display annotation view |
157 $('.list-current-annotations').on('click', 'a', function(e){ |
158 $('.list-current-annotations').on('click', 'a', function(e){ |
158 e.preventDefault(); |
159 e.preventDefault(); |
159 var annotationDisplayView = $('.annotation-display-view'), |
160 var annotationDisplayView = $('.annotation-display-view'), |
164 annotationDisplayView.hide(); |
165 annotationDisplayView.hide(); |
165 }else{ |
166 }else{ |
166 annotationDisplayView |
167 annotationDisplayView |
167 .attr('data-id', idAnnotation) |
168 .attr('data-id', idAnnotation) |
168 .css('backgroundColor', annotation.color) |
169 .css('backgroundColor', annotation.color) |
169 .text(annotation.type) |
170 .text(annotation.type+' : '+annotation.title) |
170 .show(); |
171 .show(); |
171 } |
172 } |
172 }); |
173 }); |
173 |
174 |
174 //########### modal |
175 //########### modal |
175 |
176 |
176 $(document).on('click', 'a.open-modal', function(e){ |
177 $(document).on('click', 'a.open-modal', function(e){ |
177 |
178 |
178 }); |
|
179 |
|
180 //edition image |
|
181 $('.popup').on('change', '#media-type-select', function(e){ |
|
182 var typeImage = $(this).val(); |
|
183 $('.input-image-url, .input-image-upload').hide(); |
|
184 $('.input-image-'+typeImage).show(); |
|
185 }); |
179 }); |
186 |
180 |
187 //select on bibliotheque |
181 //select on bibliotheque |
188 |
182 |
189 //confirmation suppression |
183 //confirmation suppression |
236 var idChapter = $(this).attr('id'); |
231 var idChapter = $(this).attr('id'); |
237 loadFormChapter(idChapter); |
232 loadFormChapter(idChapter); |
238 }); |
233 }); |
239 |
234 |
240 $('.chapter-widget-info').on('keyup', 'input[name=title], textarea', function(e){ |
235 $('.chapter-widget-info').on('keyup', 'input[name=title], textarea', function(e){ |
|
236 disabledPreview(); |
|
237 |
241 var name = $(this).attr('name'), |
238 var name = $(this).attr('name'), |
242 value = $(this).val(); |
239 value = $(this).val(); |
243 currentChapter[name] = value; |
240 currentChapter[name] = value; |
244 if(name == 'title'){ |
241 if(name == 'title'){ |
245 var idChapter = $(this).parents('form').attr('data-chapter-id'); |
242 var idChapter = $(this).parents('form').attr('data-chapter-id'); |
281 if(chapters.length == 1){alert('Le projet doit contenir au moins un chapitre.'); return;} |
279 if(chapters.length == 1){alert('Le projet doit contenir au moins un chapitre.'); return;} |
282 var idChapter = $(this).attr('data-chapter-id'), |
280 var idChapter = $(this).attr('data-chapter-id'), |
283 btnDeleteModal = $("#modal-confirm #btn-delete-modal"); |
281 btnDeleteModal = $("#modal-confirm #btn-delete-modal"); |
284 btnDeleteModal.attr('data-type-delete', 'chapter'); |
282 btnDeleteModal.attr('data-type-delete', 'chapter'); |
285 btnDeleteModal.attr('data-id', idChapter); |
283 btnDeleteModal.attr('data-id', idChapter); |
286 // $("#modal-confirm #btn-delete-modal").attr('onclick', 'deleteChapter("'+idChapter+'")') |
|
287 /* |
|
288 var idChapter = $(this).attr('data-chapter-id'), |
|
289 chapter = _.find(chapters, function(c){ return c.id == idChapter; }), |
|
290 indexChapter = _.indexOf(chapters, chapter), |
|
291 chapterModify; |
|
292 if(indexChapter == 0){ |
|
293 chapterModify = chapters[1]; |
|
294 chapterModify.setBegin(0); |
|
295 }else{ |
|
296 chapterModify = chapters[indexChapter-1]; |
|
297 //var newEnd = new IriSP.Model.Time(chapter.end) |
|
298 chapterModify.setEnd(chapter.end); |
|
299 } |
|
300 chapters = _(chapters).reject(function(c) { return c.id == idChapter; }); |
|
301 renderChapter(); |
|
302 //si le formulaire est visible |
|
303 if($('#form-chapter-edit-'+idChapter).length){ |
|
304 $('#form-chapter-edit-'+idChapter).remove(); |
|
305 } |
|
306 */ |
|
307 |
284 |
308 }); |
285 }); |
309 |
286 |
310 function deleteChapter(idChapter){ |
287 function deleteChapter(idChapter){ |
311 $("#modal-confirm").modal('hide') |
288 disabledPreview(); |
|
289 $("#modal-confirm").modal('hide'); |
312 var chapter = _.find(chapters, function(c){ return c.id == idChapter; }), |
290 var chapter = _.find(chapters, function(c){ return c.id == idChapter; }), |
313 indexChapter = _.indexOf(chapters, chapter), |
291 indexChapter = _.indexOf(chapters, chapter), |
314 chapterModify; |
292 chapterModify; |
315 if(indexChapter == 0){ |
293 if(indexChapter == 0){ |
316 chapterModify = chapters[1]; |
294 chapterModify = chapters[1]; |
509 openTab(data.type, data); |
491 openTab(data.type, data); |
510 } |
492 } |
511 }); |
493 }); |
512 |
494 |
513 $('.tab-content').on('keyup', '.form-info-general-annotation input[name=title], .form-info-general-annotation textarea', function(e){ |
495 $('.tab-content').on('keyup', '.form-info-general-annotation input[name=title], .form-info-general-annotation textarea', function(e){ |
|
496 disabledPreview(); |
514 var name = $(this).attr('name'), |
497 var name = $(this).attr('name'), |
515 value = $(this).val(); |
498 value = $(this).val(); |
516 currentAnnotation[name] = value; |
499 currentAnnotation[name] = value; |
517 if(name == 'title'){ |
500 if(name == 'title'){ |
518 var idAnnotation = $(this).parents('form').attr('data-id'); |
501 var idAnnotation = $(this).parents('form').attr('data-id'); |
521 }); |
504 }); |
522 |
505 |
523 //delete annotation |
506 //delete annotation |
524 $(document).on('click','.btn-delete-annotation', function(e){ |
507 $(document).on('click','.btn-delete-annotation', function(e){ |
525 e.preventDefault(); |
508 e.preventDefault(); |
526 /* |
509 |
527 var idAnnotation = $(this).attr('data-id'); |
|
528 annotations = _(annotations).reject(function(c) { return c.id == idAnnotation; }); |
|
529 closeTab(idAnnotation); |
|
530 if(!$(this).hasAttr('data-no-render'))//si on ferme à partir de la tab renderAnnotation sera appelé 2 fois |
|
531 renderAnnotation(); |
|
532 */ |
|
533 var idAnnotation = $(this).attr('data-id'), |
510 var idAnnotation = $(this).attr('data-id'), |
534 btnDeleteModal = $("#modal-confirm #btn-delete-modal"); |
511 btnDeleteModal = $("#modal-confirm #btn-delete-modal"); |
535 btnDeleteModal.attr('data-type-delete', 'annotation'); |
512 btnDeleteModal.attr('data-type-delete', 'annotation'); |
536 btnDeleteModal.attr('data-id', idAnnotation); |
513 btnDeleteModal.attr('data-id', idAnnotation); |
537 }); |
514 }); |
538 |
515 |
539 function deleteAnnotation(idAnnotation){ |
516 function deleteAnnotation(idAnnotation){ |
|
517 disabledPreview(); |
540 $("#modal-confirm").modal('hide'); |
518 $("#modal-confirm").modal('hide'); |
541 annotations = _(annotations).reject(function(c) { return c.id == idAnnotation; }); |
519 annotations = _(annotations).reject(function(c) { return c.id == idAnnotation; }); |
542 closeTab(idAnnotation); |
520 closeTab(idAnnotation); |
543 renderAnnotation(); |
521 renderAnnotation(); |
544 } |
522 } |
555 var type = $(this).attr('data-type'); |
533 var type = $(this).attr('data-type'); |
556 openTab(type); |
534 openTab(type); |
557 }); |
535 }); |
558 |
536 |
559 function openTab(type, data){ |
537 function openTab(type, data){ |
560 |
538 |
561 var dataView; |
539 var dataView; |
562 if(_.isUndefined(data)){//nouveau |
540 if(_.isUndefined(data)){//nouveau |
563 var currentTimePlusUnMin = 60 * 1000 + myMedia.currentTime, |
541 var currentTimePlusUnMin = 60 * 1000 + myMedia.currentTime, |
564 endAnnotation = (currentTimePlusUnMin<myMedia.duration) ? currentTimePlusUnMin : myMedia.duration; |
542 endAnnotation = (currentTimePlusUnMin<myMedia.duration) ? currentTimePlusUnMin : myMedia.duration; |
565 var dataAnnotation = { |
543 var dataAnnotation = { |
778 disabledBtnSortable(diaporama); |
750 disabledBtnSortable(diaporama); |
779 |
751 |
780 }; |
752 }; |
781 |
753 |
782 //edit title / description |
754 //edit title / description |
783 $('.tab-content').on('click', '.title-slideshow-row', function(){ |
755 $('.tab-content').on('click', '.title-slideshow-row, .description-slideshow-row, .video-title-edit, .video-description-edit', function(){ |
784 if($(this).find('input').length) return; |
756 if($(this).find('input').length) return; |
785 var html = $(this).find('span').html(); |
757 var html = $(this).find('span').html(), |
786 var input = $('<input type="text" />').addClass('input-mini').attr('name', 'title'); |
758 inputType = $(this).attr('data-input'), |
|
759 name = $(this).attr('data-name'), |
|
760 input = $('<'+inputType+'>').attr('name', name); |
787 input.val(html); |
761 input.val(html); |
788 $(this).find('span').replaceWith(input); |
762 $(this).find('span').replaceWith(input); |
789 input.focus().keypress(function(e){ |
763 input.focus().keypress(function(e){ |
790 code = (e.keyCode ? e.keyCode : e.which); |
764 code = (e.keyCode ? e.keyCode : e.which); |
791 if (code == 13) $(this).blur(); |
765 if (code == 13) $(this).blur(); |
792 }); |
766 }); |
793 }); |
767 }); |
794 |
768 |
795 $('.tab-content').on('click', '.description-slideshow-row', function(){ |
|
796 if($(this).find('textarea').length) return; |
|
797 var html = $(this).find('span').html(); |
|
798 var input = $('<textarea>').attr('name', 'description'); |
|
799 input.val(html); |
|
800 $(this).find('span').replaceWith(input); |
|
801 input.focus().keypress(function(e){ |
|
802 code = (e.keyCode ? e.keyCode : e.which); |
|
803 if (code == 13) $(this).blur(); |
|
804 }); |
|
805 }); |
|
806 |
|
807 $(document).on('blur', '.title-slideshow-row input, .description-slideshow-row textarea', function(){ |
769 $(document).on('blur', '.title-slideshow-row input, .description-slideshow-row textarea', function(){ |
808 var newValue = $(this).val(), |
770 var newValue = $(this).val(), |
809 name = $(this).attr('name'), |
771 name = $(this).attr('name'), |
810 span = $('<span>').html(newValue), |
772 span = $('<span>').html(newValue), |
811 indexRow = $(this).parents('.row-image-diaporama').index(); |
773 indexRow = $(this).parents('.row-image-diaporama').index(); |
812 $(this).replaceWith(span); |
774 $(this).replaceWith(span); |
813 |
|
814 currentAnnotation.content.images[indexRow][name] = newValue; |
775 currentAnnotation.content.images[indexRow][name] = newValue; |
|
776 }); |
|
777 |
|
778 $(document).on('blur', '.video-title-edit input, .video-description-edit textarea', function(){ |
|
779 var newValue = $(this).val(), |
|
780 name = $(this).attr('name'), |
|
781 span = $('<span>').html(newValue); |
|
782 $(this).replaceWith(span); |
|
783 currentAnnotation.content[name] = newValue; |
815 }); |
784 }); |
816 |
785 |
817 //bouton up / down |
786 //bouton up / down |
818 $(document).on('click', '.ui-sortable .btn-sort', function(e){ |
787 $(document).on('click', '.ui-sortable .btn-sort', function(e){ |
819 e.preventDefault(); |
788 e.preventDefault(); |
907 }); |
876 }); |
908 |
877 |
909 $('.tab-content').on('change keyup', '.config-diaporama input[name=duration]', function(){ |
878 $('.tab-content').on('change keyup', '.config-diaporama input[name=duration]', function(){ |
910 var value = $(this).val(); |
879 var value = $(this).val(); |
911 if(!isNaN(value)){ |
880 if(!isNaN(value)){ |
912 currentAnnotation.content.duration = value; |
881 currentAnnotation.content.slideduration = value * 1000; |
913 } |
882 } |
914 }); |
883 }); |
|
884 |
|
885 //save project |
|
886 $('.btn-save-project').bind('click', function(e){ |
|
887 $('.btn-apercu-projet').removeClass('disabled'); |
|
888 |
|
889 }); |
|
890 |
|
891 function disabledPreview(){ |
|
892 if(!$('.btn-apercu-projet').hasClass('disabled'))$('.btn-apercu-projet').addClass('disabled'); |
|
893 } |
915 |
894 |
916 //################ config |
895 //################ config |
917 //tagit |
896 //tagit |
918 function onTagItChange(e, ui) { |
897 function onTagItChange(e, ui) { |
919 var tagitType = $(this).attr('data-type'), |
898 var tagitType = $(this).attr('data-type'), |
935 } |
914 } |
936 |
915 |
937 //CLEditor annotation > text (wysiwyg) |
916 //CLEditor annotation > text (wysiwyg) |
938 //http://premiumsoftware.net/cleditor/docs/GettingStarted.html#optionalParameters |
917 //http://premiumsoftware.net/cleditor/docs/GettingStarted.html#optionalParameters |
939 var wysiwygConfig = { |
918 var wysiwygConfig = { |
940 width: 456, |
919 width: 450, |
941 height: 250, |
920 height: 250, |
942 controls: "bold italic underline strikethrough | font size " + |
921 controls: "bold italic underline strikethrough | font size " + |
943 "style | color highlight removeformat | bullets numbering | source", |
922 "style | color highlight removeformat | bullets numbering | source", |
944 fonts: "Arial,Arial Black,Comic Sans MS,Courier New,Narrow,Garamond," + |
923 fonts: "Arial,Arial Black,Comic Sans MS,Courier New,Narrow,Garamond," + |
945 "Georgia,Impact,Sans Serif,Serif,Tahoma,Trebuchet MS,Verdana", |
924 "Georgia,Impact,Sans Serif,Serif,Tahoma,Trebuchet MS,Verdana", |