diff -r 7a5de13173b1 -r e3d551eda5a6 integration/js/edition.js --- a/integration/js/edition.js Thu May 16 13:08:20 2013 +0200 +++ b/integration/js/edition.js Thu May 16 14:00:50 2013 +0200 @@ -1,4 +1,4 @@ -(function(){ +$(function(){ var global = { diaporama : null, @@ -6,16 +6,17 @@ }; //modal - $('.popup').on('click', '.popup-content a', function(e){ - e.preventDefault(); - if($(this).hasClass('btn-cancel')){ - $(this).parents('.popup').modal('hide'); - } - if($(this).hasClass('btn-previsualisation')){ - var imgPrev = $(''); - $('.previsualisation').empty().append(imgPrev); - } - }); + $(document).on('click', 'a.open-modal', function(e){ + var diaporama = $(this).attr('data-diaporama'), + idAnnotation = $(this).attr('data-id'); + + if(diaporama !== undefined){ + global.diaporama = diaporama; + } + if(idAnnotation !== undefined){ + global.idAnnotation = idAnnotation; + } + }) //edition image $('.popup').on('change', '#media-type-select', function(e){ var typeImage = $(this).val(); @@ -44,13 +45,6 @@ $(document).on('click','.btn-delete', function(e){ e.preventDefault(); - var titleMedia = $(this).attr('data-title'), - textModal = $('

Êtes-vous sûr de vouloir supprimer '+titleMedia+' ?

'), - eltDelete = $(this).attr('href'); - $("#modal-confirm #btn-delete-modal").attr('data-id-elt-delete', eltDelete); - $("#modal-confirm .modal-body").empty().append(textModal); - $("#modal-confirm").modal('show'); - //si c'est une annotation et que la tab est ouverte, on la ferme var type = $(this).attr('data-type'); if(type == 'annotation'){ @@ -63,16 +57,9 @@ //confirmation suppression $("#modal-confirm").on('click', '#btn-delete-modal', function(e){ - e.preventDefault(); - var idEltDelete = $(this).attr('data-id-elt-delete'); - $(idEltDelete).remove(); - $("#modal-confirm").modal('hide'); + }); - - -//page edition - //title-editor $('.project-title-editor ._popover').bind('click',function(e){e.preventDefault()}); $('.project-title-editor ._popover').popover({ @@ -103,6 +90,7 @@ $(document).on('keyup', '.project-title-editor-input', function() { $('.project-title').html($(this).val()); }); + //chapter $('.list-chapter-wrap').on('click', '.edit-chapter', function(e){ e.preventDefault(); @@ -131,30 +119,8 @@ $('.list-chapter-rows-wrap').append(tpl); }); }); -//tab - $('#annotation-tab').on('click', 'a', function(e){ - e.preventDefault(); - $(this).tab('show'); - }); - $('#annotation-tab a:last-child').tab('show'); - //fermer tab - $('#annotation-tab').on('click', 'span.close-tab', function(e){ - e.preventDefault();e.stopPropagation(); - var idTab = $(this).parents('a').attr('href'); - $(this).closest('li').remove(); - $('.tab-content '+idTab).remove(); - $('#tab-list-annotation').tab('show'); - }); - //ouvrir tab - $(document).on('click', '.open-tab', function(e){ - e.preventDefault(); - var type = $(this).attr('data-type'); - var data = $(this).attr('data-data'); // à définir - openNewTab(type); - }); - //edit annotation $('#list-annotations').on('click', 'a.btn-edit-annotation', function(e){ e.preventDefault(); @@ -170,6 +136,20 @@ } }); +//tab + $('#annotation-tab').on('click', 'a', function(e){ + e.preventDefault(); + $(this).tab('show'); + }); + + //ouvrir tab + $(document).on('click', '.open-tab', function(e){ + e.preventDefault(); + var type = $(this).attr('data-type'); + var data = $(this).attr('data-data'); // à définir + openNewTab(type); + }); + function openNewTab(type, data){ var uniqId = 'id' + (new Date()).getTime(), @@ -220,8 +200,18 @@ }); }//openNewTab() + //fermer tab + $('#annotation-tab').on('click', 'span.close-tab', function(e){ + e.preventDefault();e.stopPropagation(); + var idTab = $(this).parents('a').attr('href'); + $(this).closest('li').remove(); + $('.tab-content '+idTab).remove(); + $('#tab-list-annotation').tab('show'); + }); + + //diaporama -function addImageToDiaporama(diaporama){ + function addImageToDiaporama(diaporama){ $.get('template.html', function(templates){ var tplDiapo = $(templates).filter('#tpl-diaporama-row').html(), uniqId = 'id' + (new Date()).getTime(), @@ -232,6 +222,7 @@ }); }; + //bouton up / down $(document).on('click', '.ui-sortable .btn-sort', function(e){ e.preventDefault(); var row = $(this).parents('tr.row-image-diaporama'), @@ -251,33 +242,7 @@ listDiaporama.find('tr.row-image-diaporama:last-child').find('.btn-sort.down').addClass('disabled'); } - $(document).on('click', 'a.open-modal', function(e){ - e.preventDefault(); - var modalRemote = $(this).attr('href'), - typeMedia = $(this).attr('data-type-media'), - modalTitleInfo = $(this).attr('data-title'), - diaporama = $(this).attr('data-diaporama'), - idAnnotation = $(this).attr('data-id'), - titleFront; - - if(diaporama !== undefined){ - global.diaporama = diaporama; - } - if(idAnnotation !== undefined){ - global.idAnnotation = idAnnotation; - } - - switch(typeMedia){ - case 'video' : titleFront = ' Vidéo - '+modalTitleInfo; break; - case 'image' : titleFront = ' Image - '+modalTitleInfo; break; - } - $('#modal-template .modal-header h3').html(titleFront); - - $("#modal-template .modal-body").load(modalRemote, function() { - $("#modal-template").modal("show"); - }); - - }); + //sauvegarder annotation $('.tab-content').on('click', '.btn-save-annotation', function(e){ @@ -341,29 +306,7 @@ } }; - -//test -if($(".wysiwyg").length){ - $(".wysiwyg").cleditor(wysiwygConfig); -} - -if($(".number-spin").length){ - $('.number-spin').spin(spinParam); -} - - -disabledBtnSortable($('.ui-sortable')) -$('.ui-sortable').sortable({ - stop : function(event, ui){ - disabledBtnSortable($(this)); - } -}); - - - - -$('.slider-duration').slider(configSlider); - +//milliseconds To 12h12m12s function millisecondsToString(milliseconds) { var oneHour = 3600000; var oneMinute = 60000; @@ -408,14 +351,24 @@ } else { result += "00s"; } -/* - if (milliseconds > 0) { - result += (milliseconds > 9 ? milliseconds : "0" + milliseconds); - } else { - result += "00"; - } -*/ return result; } -})(jQuery); \ No newline at end of file + +//test +$(".wysiwyg").cleditor(wysiwygConfig); + +$('.number-spin').spin(spinParam); + +disabledBtnSortable($('.ui-sortable')) +$('.ui-sortable').sortable({ + stop : function(event, ui){ + disabledBtnSortable($(this)); + } +}); + +$('.slider-duration').slider(configSlider); + +$('#annotation-tab a:last-child').tab('show'); + +}); \ No newline at end of file