integration/js/edition.js
changeset 88 c91124908cd1
parent 86 e61b3adf46f2
child 89 99d281de4f31
equal deleted inserted replaced
87:4b37ee07374d 88:c91124908cd1
   299     }else{
   299     }else{
   300         chapterModify = chapters[indexChapter-1];
   300         chapterModify = chapters[indexChapter-1];
   301         //var newEnd = new IriSP.Model.Time(chapter.end)
   301         //var newEnd = new IriSP.Model.Time(chapter.end)
   302         chapterModify.setEnd(chapter.end);
   302         chapterModify.setEnd(chapter.end);
   303     }
   303     }
   304     chapters = _(chapters).reject(function(c) { return c.id == idChapter; });
   304     chapters.removeId(idChapter);
       
   305     myProject.getAnnotations().removeId(idChapter, true);
   305     renderChapter();
   306     renderChapter();
   306     //si le formulaire est visible
   307     //si le formulaire est visible
   307     if($('#form-chapter-edit-'+idChapter).length){
   308     if($('#form-chapter-edit-'+idChapter).length){
   308         $('#form-chapter-edit-'+idChapter).remove();
   309         $('#form-chapter-edit-'+idChapter).remove();
   309     }
   310     }
   323             chapter.description = dataChapter.description;
   324             chapter.description = dataChapter.description;
   324             chapter.keywords = dataChapter.keywords;
   325             chapter.keywords = dataChapter.keywords;
   325             chapter.color = getRandomColor();
   326             chapter.color = getRandomColor();
   326     
   327     
   327         chapters.push(chapter);
   328         chapters.push(chapter);
       
   329         myProject.getAnnotations().push(chapter);
   328         renderChapter();
   330         renderChapter();
   329         loadFormChapter(chapter.id);
   331         loadFormChapter(chapter.id);
   330     }
   332     }
   331 
   333 
   332     $('.chapter-widget').on('click', '.btn-cut-chapter', function(e){
   334     $('.chapter-widget').on('click', '.btn-cut-chapter', function(e){
   364 
   366 
   365         var chapterSegmentWrap = $('.chapter-segments'),
   367         var chapterSegmentWrap = $('.chapter-segments'),
   366             wChapterSegmentWrap = chapterSegmentWrap.width(),
   368             wChapterSegmentWrap = chapterSegmentWrap.width(),
   367             chapterList = $('.list-chapter-rows-wrap');
   369             chapterList = $('.list-chapter-rows-wrap');
   368 
   370 
   369         chapters = _.sortBy(chapters, function(c){
   371         chapters = chapters.sortBy(function(c){
   370             return c.begin;
   372             return c.begin;
   371         });
   373         });
   372 
   374 
   373         chapterSegmentWrap.empty();
   375         chapterSegmentWrap.empty();
   374         chapterList.empty();
   376         chapterList.empty();
   410             annotation.type = dataAnnotation.type;
   412             annotation.type = dataAnnotation.type;
   411             annotation.color = global.colors[(global.colorsIndex<global.colors.length) ? global.colorsIndex++ : (global.colorsIndex=0)];
   413             annotation.color = global.colors[(global.colorsIndex<global.colors.length) ? global.colorsIndex++ : (global.colorsIndex=0)];
   412             annotation.keywords = dataAnnotation.keywords;
   414             annotation.keywords = dataAnnotation.keywords;
   413             annotation.content = getContentAnnotationByType(dataAnnotation.type);
   415             annotation.content = getContentAnnotationByType(dataAnnotation.type);
   414 
   416 
       
   417         myProject.getAnnotations().push(annotation);
   415         annotations.push(annotation);
   418         annotations.push(annotation);
   416         
   419         
   417         return annotation;
   420         return annotation;
   418     }
   421     }
   419 
   422 
   422 
   425 
   423         var timeline = $('.timeline-annotations'),
   426         var timeline = $('.timeline-annotations'),
   424             wTimeline = timeline.width(),
   427             wTimeline = timeline.width(),
   425             annotationList = $('#list-annotations-rows');
   428             annotationList = $('#list-annotations-rows');
   426 
   429 
   427         annotations = _.sortBy(annotations, function(c){
   430         annotations = annotations.sortBy(function(c){
   428             return c.begin;
   431             return c.begin;
   429         });
   432         });
   430 
   433 
   431         timeline.empty().append('<li>');
   434         timeline.empty().append('<li>');
   432         annotationList.empty();
   435         annotationList.empty();
   519     });
   522     });
   520 
   523 
   521     function deleteAnnotation(idAnnotation){
   524     function deleteAnnotation(idAnnotation){
   522         disabledPreview();
   525         disabledPreview();
   523         $("#modal-confirm").modal('hide');
   526         $("#modal-confirm").modal('hide');
   524         annotations = _(annotations).reject(function(c) { return c.id == idAnnotation; });
   527         annotations.removeId(idAnnotation);
       
   528         myProject.getAnnotations().removeId(idAnnotation, true);
   525         closeTab(idAnnotation);
   529         closeTab(idAnnotation);
   526         renderAnnotation();
   530         renderAnnotation();
   527     }
   531     }
   528 
   532 
   529 //tab
   533 //tab
   889 
   893 
   890 //save project
   894 //save project
   891 $('.btn-save-project').bind('click', function(e){
   895 $('.btn-save-project').bind('click', function(e){
   892     $('.btn-apercu-projet').removeClass('disabled');
   896     $('.btn-apercu-projet').removeClass('disabled');
   893 
   897 
   894     console.log(myProject.serialize());
   898     console.log(JSON.parse(myProject.serialize()));
   895 /*
   899 /*
   896     $.ajax({
   900     $.ajax({
   897         type: "POST",
   901         type: "POST",
   898         url: urlSaveProject,
   902         url: urlSaveProject,
   899         data: myProject.serialize(),
   903         data: myProject.serialize(),