integration/js/edition.js
changeset 74 22aca5b735a2
parent 70 2542e988f80c
child 79 5dfa74fcec4b
equal deleted inserted replaced
71:79974d302930 74:22aca5b735a2
   179     
   179     
   180     
   180     
   181 
   181 
   182     //confirmation suppression
   182     //confirmation suppression
   183     $("#modal-confirm").on('click', '#btn-delete-modal', function(e){
   183     $("#modal-confirm").on('click', '#btn-delete-modal', function(e){
   184 
   184         
   185     });
   185         var typeDelete = $(this).attr('data-type-delete'),
       
   186             idAnnotation = $(this).attr('data-id');
       
   187 
       
   188         if(typeDelete == 'chapter' || typeDelete == 'annotation'){
       
   189             e.preventDefault();
       
   190             if(typeDelete == 'chapter') deleteChapter(idAnnotation);
       
   191             if(typeDelete == 'annotation') deleteAnnotation(idAnnotation);
       
   192         }
       
   193     });
       
   194 
       
   195 //--apercu projet
       
   196 $(document).on('click', '.btn-apercu-projet.disabled', function(e){
       
   197     e.preventDefault();
       
   198 });
   186 
   199 
   187 //--title-editor
   200 //--title-editor
   188     $(document).on('click', '.project-title-editor i, .project-title', function () {
   201     $(document).on('click', '.project-title-editor i, .project-title', function () {
   189         var html = $('.project-title').html();
   202         var html = $('.project-title').html();
   190         var input = $('<input type="text" />');
   203         var input = $('<input type="text" />');
   254 //supprimer
   267 //supprimer
   255 $('.list-chapter-wrap').on('click', '.btn-delete-chapter', function(e){
   268 $('.list-chapter-wrap').on('click', '.btn-delete-chapter', function(e){
   256     e.preventDefault();
   269     e.preventDefault();
   257 
   270 
   258     if(chapters.length == 1){alert('Le projet doit contenir au moins un chapitre.'); return;}
   271     if(chapters.length == 1){alert('Le projet doit contenir au moins un chapitre.'); return;}
   259 
   272     var idChapter = $(this).attr('data-chapter-id'),
       
   273         btnDeleteModal = $("#modal-confirm #btn-delete-modal");
       
   274     btnDeleteModal.attr('data-type-delete', 'chapter');
       
   275     btnDeleteModal.attr('data-id', idChapter);
       
   276    // $("#modal-confirm #btn-delete-modal").attr('onclick', 'deleteChapter("'+idChapter+'")')
       
   277 /*
   260     var idChapter = $(this).attr('data-chapter-id'),
   278     var idChapter = $(this).attr('data-chapter-id'),
   261         chapter = _.find(chapters, function(c){ return c.id == idChapter; }),
   279         chapter = _.find(chapters, function(c){ return c.id == idChapter; }),
   262         indexChapter = _.indexOf(chapters, chapter),
   280         indexChapter = _.indexOf(chapters, chapter),
   263         chapterModify;
   281         chapterModify;
   264     if(indexChapter == 0){
   282     if(indexChapter == 0){
   273     renderChapter();
   291     renderChapter();
   274     //si le formulaire est visible
   292     //si le formulaire est visible
   275     if($('#form-chapter-edit-'+idChapter).length){
   293     if($('#form-chapter-edit-'+idChapter).length){
   276         $('#form-chapter-edit-'+idChapter).remove();
   294         $('#form-chapter-edit-'+idChapter).remove();
   277     }
   295     }
   278 });
   296 */
       
   297 
       
   298 });
       
   299 
       
   300 function deleteChapter(idChapter){
       
   301     $("#modal-confirm").modal('hide')
       
   302     var chapter = _.find(chapters, function(c){ return c.id == idChapter; }),
       
   303         indexChapter = _.indexOf(chapters, chapter),
       
   304         chapterModify;
       
   305     if(indexChapter == 0){
       
   306         chapterModify = chapters[1];
       
   307         chapterModify.setBegin(0);
       
   308     }else{
       
   309         chapterModify = chapters[indexChapter-1];
       
   310         //var newEnd = new IriSP.Model.Time(chapter.end)
       
   311         chapterModify.setEnd(chapter.end);
       
   312     }
       
   313     chapters = _(chapters).reject(function(c) { return c.id == idChapter; });
       
   314     renderChapter();
       
   315     //si le formulaire est visible
       
   316     if($('#form-chapter-edit-'+idChapter).length){
       
   317         $('#form-chapter-edit-'+idChapter).remove();
       
   318     }
       
   319 }
   279 
   320 
   280 function getRandomColor(){
   321 function getRandomColor(){
   281     return global.colors[(global.colorsIndex<global.colors.length) ? global.colorsIndex++ : (global.colorsIndex=0)];
   322     return global.colors[(global.colorsIndex<global.colors.length) ? global.colorsIndex++ : (global.colorsIndex=0)];
   282 }
   323 }
   283 //nouveau chapitre
   324 //nouveau chapitre
   339         chapterList.empty();
   380         chapterList.empty();
   340        
   381        
   341             $.each(chapters, function(k, v){
   382             $.each(chapters, function(k, v){
   342 
   383 
   343                 //segments
   384                 //segments
   344                 var width = Math.floor(v.getDuration() * wChapterSegmentWrap / myMedia.duration),
   385                 var width = v.getDuration() * wChapterSegmentWrap / myMedia.duration,
       
   386                     left = v.begin * wChapterSegmentWrap / myMedia.duration,
   345                     segment = $('<li>'+v.title+'</li>').css({
   387                     segment = $('<li>'+v.title+'</li>').css({
       
   388                         left : left,
   346                         width : width,
   389                         width : width,
   347                         backgroundColor : v.color
   390                         backgroundColor : v.color
   348                     }).attr('id', v.id);
   391                     }).attr('id', v.id);
   349         
   392         
   350                 chapterSegmentWrap.append(segment);
   393                 chapterSegmentWrap.append(segment);
   431                 timeline.find('li:last-child').append(segment);
   474                 timeline.find('li:last-child').append(segment);
   432             }
   475             }
   433             
   476             
   434            
   477            
   435             //liste
   478             //liste
       
   479                 v.iconTab = getIcon(v.type);
   436                 var tplAnnotationRow = getTemplate('#tpl-list-annotation-row');
   480                 var tplAnnotationRow = getTemplate('#tpl-list-annotation-row');
   437                 tplAnnotationRow = Mustache.render(tplAnnotationRow, v);
   481                 tplAnnotationRow = Mustache.render(tplAnnotationRow, v);
   438                 annotationList.append(tplAnnotationRow);
   482                 annotationList.append(tplAnnotationRow);
   439 
   483 
   440         });
   484         });
   467     });
   511     });
   468 
   512 
   469     //delete annotation
   513     //delete annotation
   470     $(document).on('click','.btn-delete-annotation', function(e){
   514     $(document).on('click','.btn-delete-annotation', function(e){
   471         e.preventDefault();
   515         e.preventDefault();
   472 
   516         /*
   473         var idAnnotation = $(this).attr('data-id');
   517         var idAnnotation = $(this).attr('data-id');
   474         annotations = _(annotations).reject(function(c) { return c.id == idAnnotation; });
   518         annotations = _(annotations).reject(function(c) { return c.id == idAnnotation; });
   475         closeTab(idAnnotation);
   519         closeTab(idAnnotation);
   476         if(!$(this).hasAttr('data-no-render'))//si on ferme à partir de la tab renderAnnotation sera appelé 2 fois
   520         if(!$(this).hasAttr('data-no-render'))//si on ferme à partir de la tab renderAnnotation sera appelé 2 fois
   477             renderAnnotation();
   521             renderAnnotation();
   478 
   522         */
   479     });
   523         var idAnnotation = $(this).attr('data-id'),
       
   524             btnDeleteModal = $("#modal-confirm #btn-delete-modal");
       
   525         btnDeleteModal.attr('data-type-delete', 'annotation');
       
   526         btnDeleteModal.attr('data-id', idAnnotation);
       
   527     });
       
   528 
       
   529     function deleteAnnotation(idAnnotation){
       
   530         $("#modal-confirm").modal('hide');
       
   531         annotations = _(annotations).reject(function(c) { return c.id == idAnnotation; });
       
   532         closeTab(idAnnotation);
       
   533         renderAnnotation();
       
   534     }
   480 
   535 
   481 //tab
   536 //tab
   482     $('#onglet-annotations').on('click', 'a', function(e){
   537     $('#onglet-annotations').on('click', 'a', function(e){
   483         e.preventDefault();
   538         e.preventDefault();
   484         $(this).tab('show');
   539         $(this).tab('show');