2 |
2 |
3 var myMedia = undefined, |
3 var myMedia = undefined, |
4 currentChapter = undefined, |
4 currentChapter = undefined, |
5 currentAnnotation = undefined, |
5 currentAnnotation = undefined, |
6 currentSlider = undefined, |
6 currentSlider = undefined, |
7 secMiniChapter = 10; |
7 secMiniChapter = 10, |
|
8 lengthStringDiapo = 40; |
8 |
9 |
9 /* Colors */ |
10 /* Colors */ |
10 var annotationsColors = { |
11 var annotationsColors = { |
11 'video' : '#BE4477', |
12 'video' : '#BE4477', |
12 'text' : '#5E90CB', |
13 'text' : '#5E90CB', |
218 |
219 |
219 /* Title project */ |
220 /* Title project */ |
220 |
221 |
221 $(document).on('click', '.project-title-editor i, .project-title', function () { |
222 $(document).on('click', '.project-title-editor i, .project-title', function () { |
222 |
223 |
223 var html = $('.project-title').html(); |
224 var html = myProject.title; |
224 var input = $('<input type="text" />'); |
225 var input = $('<input type="text" />'); |
225 input.val(html); |
226 input.val(html); |
226 $('.project-title').replaceWith(input); |
227 $('.project-title').replaceWith(input); |
227 input.focus().keypress(function(e){ |
228 input.focus().keypress(function(e){ |
228 code = (e.keyCode ? e.keyCode : e.which); |
229 code = (e.keyCode ? e.keyCode : e.which); |
700 addLinkRow(tbody); |
701 addLinkRow(tbody); |
701 } |
702 } |
702 break; |
703 break; |
703 |
704 |
704 case 'slideshow': |
705 case 'slideshow': |
705 console.log(currentAnnotation) |
706 |
706 $(tabContent).find('.number-spin').val(dataView.content.slideduration/1000); |
707 $(tabContent).find('.number-spin').val(dataView.content.slideduration/1000); |
707 $(tabContent).find('.number-spin').spin(spinParam); |
708 $(tabContent).find('.number-spin').spin(spinParam); |
708 $(tabContent).find('.ui-sortable').sortable({ |
709 $(tabContent).find('.ui-sortable').sortable({ |
709 start: function (event, ui) { |
710 start: function (event, ui) { |
710 $(ui.item).data("startindex", ui.item.index()); |
711 $(ui.item).data("startindex", ui.item.index()); |
852 disabledPreview(); |
853 disabledPreview(); |
853 }); |
854 }); |
854 |
855 |
855 function addImageToSlideshow(slideshow, dataView){ |
856 function addImageToSlideshow(slideshow, dataView){ |
856 var tplDiapo = getTemplate('#tpl-slideshow-row'); |
857 var tplDiapo = getTemplate('#tpl-slideshow-row'); |
|
858 dataView.limitLength = function(){ |
|
859 return function(text, render) { |
|
860 if(render(text).length > lengthStringDiapo){ |
|
861 return render(text).substr(0,lengthStringDiapo) + '...'; |
|
862 }else{ |
|
863 return render(text); |
|
864 } |
|
865 } |
|
866 } |
857 tplDiapo = Mustache.render(tplDiapo, dataView); |
867 tplDiapo = Mustache.render(tplDiapo, dataView); |
858 slideshow.append(tplDiapo); |
868 slideshow.append(tplDiapo); |
859 disabledBtnSortable(slideshow); |
869 disabledBtnSortable(slideshow); |
860 }; |
870 }; |
861 |
871 |
862 //edit |
872 //edit |
863 $('.tab-content').on('click', '.title-slideshow-row, .description-slideshow-row, .video-title-edit, .video-description-edit', function(){ |
873 $('.tab-content').on('click', '.title-slideshow-row, .description-slideshow-row', function(){ |
864 if($(this).find('input').length) return; |
874 if($(this).find('input').length) return; |
865 var html = $(this).find('span').html(), |
875 var index = $(this).parents('.row-image-slideshow').index(), |
866 inputType = $(this).attr('data-input'), |
876 inputType = $(this).attr('data-input'), |
867 name = $(this).attr('data-name'), |
877 name = $(this).attr('data-name'), |
868 input = $('<'+inputType+'>').attr('name', name); |
878 input = $('<'+inputType+'>').attr('name', name), |
|
879 html = currentAnnotation.content.images[index][name]; |
869 input.val(html); |
880 input.val(html); |
870 $(this).find('span').replaceWith(input); |
881 $(this).find('span').replaceWith(input); |
871 input.focus().keypress(function(e){ |
882 input.focus().keypress(function(e){ |
872 code = (e.keyCode ? e.keyCode : e.which); |
883 code = (e.keyCode ? e.keyCode : e.which); |
873 if (code == 13) $(this).blur(); |
884 if (code == 13) $(this).blur(); |
875 }); |
886 }); |
876 |
887 |
877 $(document).on('blur', '.title-slideshow-row input, .description-slideshow-row textarea', function(){ |
888 $(document).on('blur', '.title-slideshow-row input, .description-slideshow-row textarea', function(){ |
878 var newValue = $(this).val(), |
889 var newValue = $(this).val(), |
879 name = $(this).attr('name'), |
890 name = $(this).attr('name'), |
880 span = $('<span>').html(newValue), |
|
881 indexRow = $(this).parents('.row-image-slideshow').index(); |
891 indexRow = $(this).parents('.row-image-slideshow').index(); |
|
892 currentAnnotation.content.images[indexRow][name] = newValue; |
|
893 if(newValue.length>lengthStringDiapo){ |
|
894 newValue = newValue.substr(0,lengthStringDiapo) + '...'; |
|
895 } |
|
896 var span = $('<span>').html(newValue); |
882 $(this).replaceWith(span); |
897 $(this).replaceWith(span); |
883 currentAnnotation.content.images[indexRow][name] = newValue; |
898 |
884 disabledPreview(); |
|
885 }); |
|
886 |
|
887 $(document).on('blur', '.video-title-edit input, .video-description-edit textarea', function(){ |
|
888 var newValue = $(this).val(), |
|
889 name = $(this).attr('name'), |
|
890 span = $('<span>').html(newValue); |
|
891 $(this).replaceWith(span); |
|
892 currentAnnotation.content[name] = newValue; |
|
893 disabledPreview(); |
899 disabledPreview(); |
894 }); |
900 }); |
895 |
901 |
896 //button up / down |
902 //button up / down |
897 $(document).on('click', '.ui-sortable .btn-sort', function(e){ |
903 $(document).on('click', '.ui-sortable .btn-sort', function(e){ |