integration/js/edition.js
changeset 83 8f954a0d6031
parent 79 5dfa74fcec4b
child 84 9f481f896e60
--- a/integration/js/edition.js	Wed Jun 05 12:05:53 2013 +0200
+++ b/integration/js/edition.js	Thu Jun 06 12:35:59 2013 +0200
@@ -102,6 +102,7 @@
         }else{
             btnCutChapter.css("left",pos);
         }
+        $('.info-time').text(t)
         //annotations view
         refreshAnnotationDisplay(t);
 
@@ -151,7 +152,7 @@
 
 function showCurrentAnnotationInTimeline(idAnnotation){
     $('.timeline-annotations .annotation').empty();
-    $('#annotation-timeline-'+idAnnotation).text('en cours');
+    $('#annotation-timeline-'+idAnnotation).html('<i class="icon-pencil"></i> '+textCurrentAnnotationEditT);
 }
 //display annotation view
 $('.list-current-annotations').on('click', 'a', function(e){
@@ -166,7 +167,7 @@
         annotationDisplayView
             .attr('data-id', idAnnotation)
             .css('backgroundColor', annotation.color)
-            .text(annotation.type)
+            .text(annotation.type+' : '+annotation.title)
             .show();
     }
 });
@@ -177,13 +178,6 @@
 
     });
 
-//edition image
-    $('.popup').on('change', '#media-type-select', function(e){
-        var typeImage = $(this).val();
-        $('.input-image-url, .input-image-upload').hide();
-        $('.input-image-'+typeImage).show();
-    });
-
 //select on bibliotheque
 
     //confirmation suppression
@@ -206,6 +200,7 @@
 
 //--title-editor
     $(document).on('click', '.project-title-editor i, .project-title', function () {
+        disabledPreview();
         var html = $('.project-title').html();
         var input = $('<input type="text" />');
         input.val(html);
@@ -238,6 +233,8 @@
     });
 
     $('.chapter-widget-info').on('keyup', 'input[name=title], textarea', function(e){
+        disabledPreview();
+
         var name = $(this).attr('name'),
             value = $(this).val();
         currentChapter[name] = value;
@@ -252,6 +249,7 @@
 
     function loadFormChapter(idChapter){
 
+        disabledPreview();
         
 
         currentChapter = _.find(chapters, function(c){ return c.id == idChapter; });
@@ -283,32 +281,12 @@
         btnDeleteModal = $("#modal-confirm #btn-delete-modal");
     btnDeleteModal.attr('data-type-delete', 'chapter');
     btnDeleteModal.attr('data-id', idChapter);
-   // $("#modal-confirm #btn-delete-modal").attr('onclick', 'deleteChapter("'+idChapter+'")')
-/*
-    var idChapter = $(this).attr('data-chapter-id'),
-        chapter = _.find(chapters, function(c){ return c.id == idChapter; }),
-        indexChapter = _.indexOf(chapters, chapter),
-        chapterModify;
-    if(indexChapter == 0){
-        chapterModify = chapters[1];
-        chapterModify.setBegin(0);
-    }else{
-        chapterModify = chapters[indexChapter-1];
-        //var newEnd = new IriSP.Model.Time(chapter.end)
-        chapterModify.setEnd(chapter.end);
-    }
-    chapters = _(chapters).reject(function(c) { return c.id == idChapter; });
-    renderChapter();
-    //si le formulaire est visible
-    if($('#form-chapter-edit-'+idChapter).length){
-        $('#form-chapter-edit-'+idChapter).remove();
-    }
-*/
 
 });
 
 function deleteChapter(idChapter){
-    $("#modal-confirm").modal('hide')
+    disabledPreview();
+    $("#modal-confirm").modal('hide');
     var chapter = _.find(chapters, function(c){ return c.id == idChapter; }),
         indexChapter = _.indexOf(chapters, chapter),
         chapterModify;
@@ -378,6 +356,8 @@
     }
     
     function renderChapter(){
+        disabledPreview();
+
         var chapterSegmentWrap = $('.chapter-segments'),
             wChapterSegmentWrap = chapterSegmentWrap.width(),
             chapterList = $('.list-chapter-rows-wrap');
@@ -433,6 +413,8 @@
     }
 
     function renderAnnotation(){
+        disabledPreview();
+
         var timeline = $('.timeline-annotations'),
             wTimeline = timeline.width(),
             annotationList = $('#list-annotations-rows');
@@ -499,7 +481,7 @@
     //edit annotation
     $('#list-annotations').on('click', 'a.btn-edit-annotation', function(e){
         e.preventDefault();
-
+        disabledPreview();
         var idAnnotation = $(this).attr('data-id');
         //si il est déjà ouvert
         if($('#tab-annotation-'+idAnnotation).length){
@@ -511,6 +493,7 @@
     });
 
     $('.tab-content').on('keyup', '.form-info-general-annotation input[name=title], .form-info-general-annotation textarea', function(e){
+        disabledPreview();
         var name = $(this).attr('name'),
             value = $(this).val();
         currentAnnotation[name] = value;
@@ -523,13 +506,7 @@
     //delete annotation
     $(document).on('click','.btn-delete-annotation', function(e){
         e.preventDefault();
-        /*
-        var idAnnotation = $(this).attr('data-id');
-        annotations = _(annotations).reject(function(c) { return c.id == idAnnotation; });
-        closeTab(idAnnotation);
-        if(!$(this).hasAttr('data-no-render'))//si on ferme à partir de la tab renderAnnotation sera appelé 2 fois
-            renderAnnotation();
-        */
+
         var idAnnotation = $(this).attr('data-id'),
             btnDeleteModal = $("#modal-confirm #btn-delete-modal");
         btnDeleteModal.attr('data-type-delete', 'annotation');
@@ -537,6 +514,7 @@
     });
 
     function deleteAnnotation(idAnnotation){
+        disabledPreview();
         $("#modal-confirm").modal('hide');
         annotations = _(annotations).reject(function(c) { return c.id == idAnnotation; });
         closeTab(idAnnotation);
@@ -557,7 +535,7 @@
     });
 
     function openTab(type, data){
-
+        
         var dataView;
         if(_.isUndefined(data)){//nouveau
             var currentTimePlusUnMin = 60 * 1000 + myMedia.currentTime,
@@ -605,16 +583,10 @@
                 case 'audio':
                     break;
                 case 'video':
-                    
                     if(viewType.content.url != ""){
-
                         var videoWrap = $(tabContent).find('.annotation-video-content');
                         renderVideoInfo(videoWrap, viewType.content);
-   
                     }
-
-                    
-
                     break;
                 case 'text': 
                     var cledit = $(tabContent).find('.wysiwyg').cleditor(wysiwygConfig)[0];
@@ -632,7 +604,7 @@
                     break;
 
                 case 'slideshow': 
-
+                    $(tabContent).find('.number-spin').val(dataView.content.slideduration/1000);
                     $(tabContent).find('.number-spin').spin(spinParam);
                     $(tabContent).find('.ui-sortable').sortable({
                         start: function (event, ui) {
@@ -780,22 +752,12 @@
     };
 
     //edit title / description
-    $('.tab-content').on('click', '.title-slideshow-row', function(){
+    $('.tab-content').on('click', '.title-slideshow-row, .description-slideshow-row, .video-title-edit, .video-description-edit', function(){
         if($(this).find('input').length) return;
-        var html = $(this).find('span').html();
-        var input = $('<input type="text" />').addClass('input-mini').attr('name', 'title');
-        input.val(html);
-        $(this).find('span').replaceWith(input);
-        input.focus().keypress(function(e){
-            code = (e.keyCode ? e.keyCode : e.which);
-            if (code == 13) $(this).blur();
-        });
-    });
-
-    $('.tab-content').on('click', '.description-slideshow-row', function(){
-        if($(this).find('textarea').length) return;
-        var html = $(this).find('span').html();
-        var input = $('<textarea>').attr('name', 'description');
+        var html = $(this).find('span').html(),
+            inputType = $(this).attr('data-input'),
+            name = $(this).attr('data-name'),
+            input = $('<'+inputType+'>').attr('name', name);
         input.val(html);
         $(this).find('span').replaceWith(input);
         input.focus().keypress(function(e){
@@ -810,8 +772,15 @@
             span = $('<span>').html(newValue),
             indexRow = $(this).parents('.row-image-diaporama').index();
         $(this).replaceWith(span);
+        currentAnnotation.content.images[indexRow][name] = newValue;
+    });
 
-        currentAnnotation.content.images[indexRow][name] = newValue;
+    $(document).on('blur', '.video-title-edit input, .video-description-edit textarea', function(){
+        var newValue = $(this).val(),
+            name = $(this).attr('name'),
+            span = $('<span>').html(newValue);
+        $(this).replaceWith(span);
+        currentAnnotation.content[name] = newValue;
     });
 
     //bouton up / down
@@ -909,10 +878,20 @@
 $('.tab-content').on('change keyup', '.config-diaporama input[name=duration]', function(){
     var value = $(this).val();
     if(!isNaN(value)){
-        currentAnnotation.content.duration = value;
+        currentAnnotation.content.slideduration = value * 1000;
     }
 });
 
+//save project
+$('.btn-save-project').bind('click', function(e){
+    $('.btn-apercu-projet').removeClass('disabled');
+
+});
+
+function disabledPreview(){
+    if(!$('.btn-apercu-projet').hasClass('disabled'))$('.btn-apercu-projet').addClass('disabled');
+}
+
 //################ config
 //tagit
 function onTagItChange(e, ui) {
@@ -937,7 +916,7 @@
 //CLEditor annotation > text (wysiwyg)
 //http://premiumsoftware.net/cleditor/docs/GettingStarted.html#optionalParameters
 var wysiwygConfig = {
-    width:        456, 
+    width:        450, 
     height:       250, 
     controls:     "bold italic underline strikethrough | font size " +
                     "style | color highlight removeformat | bullets numbering | source",
@@ -1032,7 +1011,7 @@
         case 'slideshow': 
             content = {
                 mimetype : "application/x-ldt-slideshow",
-                duration : 1,
+                slideduration : 1000,
                 autostart : false,
                 images : []
             };
@@ -1070,7 +1049,6 @@
     return this; 
 };
 
-
 function getVideoPlayer(src, videoWrap){
 
     var youtubeTemplate = _.template(