integration/js/edition.js
changeset 101 e40637c085b0
parent 95 5f42ac58d262
child 102 172abe53cf6c
--- a/integration/js/edition.js	Fri Jun 07 12:41:45 2013 +0200
+++ b/integration/js/edition.js	Fri Jun 07 16:31:42 2013 +0200
@@ -1,6 +1,7 @@
 var myMedia = undefined,
     currentChapter = undefined,
-    currentAnnotation = undefined;
+    currentAnnotation = undefined,
+    secMiniChapter = 10;
 
 $(function(){
 
@@ -24,7 +25,27 @@
     }
 });
 
-$('.timeline-annotations').on('click', '.annotation', function(e){
+//survol
+$(document).on('mouseover', '.timeline-annotations .annotation, #list-annotations-rows tr, .item-display-annotation' , function(){
+    if(!$(this).hasClass('shadow')) {
+        var idAnnotation = $(this).attr('data-id');
+        $('#annotation-timeline-'+idAnnotation+', #row-list-annotation-'+idAnnotation+', #item-current-annotation-'+idAnnotation).addClass('shadow');
+    }
+});
+
+$(document).on('mouseover', '.chapter-segment, .row-list-chapter' , function(){
+    if(!$(this).hasClass('shadow')) {
+        var idChapter = $(this).attr('data-id');
+        $('#row-list-chapter-'+idChapter+', #'+idChapter).addClass('shadow');
+    }
+});
+
+$(document).on('mouseout', '.shadow' , function(){
+    $('.shadow').removeClass('shadow');
+});
+
+
+$(document).on('click', '.annotation, .item-display-annotation', function(e){
     e.preventDefault();
     var idAnnotation = $(this).attr('data-id'),
         annotation = _.find(annotations, function(c){ return c.id == idAnnotation; });
@@ -130,6 +151,7 @@
             currentAnnotationsDisplay.push(v.id);
             if(!$('#item-current-annotation-'+v.id).length){
                 var itemAnnotation = getTemplate('#tpl-item-annotation-display');
+                v.iconTab = getIcon(v.type);
                 itemAnnotation = Mustache.render(itemAnnotation, v);
                 $('.list-current-annotations').append(itemAnnotation)
             }
@@ -157,6 +179,7 @@
 //display annotation view
 $('.list-current-annotations').on('click', 'a', function(e){
     e.preventDefault();
+    /*
     var annotationDisplayView = $('.annotation-display-view'),
         idAnnotation = $(this).attr('data-id');
     var annotation = _.find(annotations, function(c){ return c.id == idAnnotation; });
@@ -170,6 +193,7 @@
             .text(annotation.type+' : '+annotation.title)
             .show();
     }
+    */
 });
 
 //########### modal
@@ -335,11 +359,16 @@
 
     $('.chapter-widget').on('click', '.btn-cut-chapter', function(e){
         e.preventDefault();
-
+        var begin = myMedia.currentTime,
+            end = organizeNewChapter(myMedia.currentTime);
+        if(!end){
+            alert('Les chapitres doivent durer au moins '+secMiniChapter+' secondes');
+            return;
+        }
         var dataChapter = {
             title : 'New',
-            begin : myMedia.currentTime,
-            end : organizeNewChapter(myMedia.currentTime),
+            begin : begin,
+            end : end,
             description : 'description',
             keywords : ['tag1','tag2']
         };
@@ -350,11 +379,12 @@
     
     function organizeNewChapter(beginNew){
 
-        var returnEnd;
+        var returnEnd = false;
         $.each(chapters, function(k, v){
             var begin = v.begin,
                 end = v.end;
-            if(beginNew>=begin && beginNew<=end){
+
+            if(beginNew>=begin && beginNew<=end && end-beginNew>secMiniChapter*1000 && beginNew-begin>secMiniChapter*1000){
                 returnEnd = new IriSP.Model.Time(end);
                 v.setEnd(beginNew); 
             }
@@ -386,7 +416,9 @@
                         left : left,
                         width : width,
                         backgroundColor : v.color
-                    }).attr('id', v.id);
+                    }).attr('id', v.id)
+                    .attr('data-id', v.id)
+                    .addClass('chapter-segment');
         
                 chapterSegmentWrap.append(segment);
 
@@ -516,6 +548,7 @@
             var idAnnotation = $(this).parents('form').attr('data-id');
             $('#onglet-title-'+idAnnotation).text(value);
             $(this).parents('form').find('.btn-delete-annotation').attr('data-title', value);
+            $('#annotation-timeline-'+ idAnnotation).attr('title', value);
             $('#annotation-timeline-'+ idAnnotation+' span').text(value);
         }
     });