--- a/integration/js/edition.js Mon Jun 03 17:47:15 2013 +0200
+++ b/integration/js/edition.js Tue Jun 04 12:50:33 2013 +0200
@@ -181,9 +181,22 @@
//confirmation suppression
$("#modal-confirm").on('click', '#btn-delete-modal', function(e){
+
+ var typeDelete = $(this).attr('data-type-delete'),
+ idAnnotation = $(this).attr('data-id');
+ if(typeDelete == 'chapter' || typeDelete == 'annotation'){
+ e.preventDefault();
+ if(typeDelete == 'chapter') deleteChapter(idAnnotation);
+ if(typeDelete == 'annotation') deleteAnnotation(idAnnotation);
+ }
});
+//--apercu projet
+$(document).on('click', '.btn-apercu-projet.disabled', function(e){
+ e.preventDefault();
+});
+
//--title-editor
$(document).on('click', '.project-title-editor i, .project-title', function () {
var html = $('.project-title').html();
@@ -256,7 +269,12 @@
e.preventDefault();
if(chapters.length == 1){alert('Le projet doit contenir au moins un chapitre.'); return;}
-
+ var idChapter = $(this).attr('data-chapter-id'),
+ 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),
@@ -275,8 +293,31 @@
if($('#form-chapter-edit-'+idChapter).length){
$('#form-chapter-edit-'+idChapter).remove();
}
+*/
+
});
+function deleteChapter(idChapter){
+ $("#modal-confirm").modal('hide')
+ var 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 getRandomColor(){
return global.colors[(global.colorsIndex<global.colors.length) ? global.colorsIndex++ : (global.colorsIndex=0)];
}
@@ -341,8 +382,10 @@
$.each(chapters, function(k, v){
//segments
- var width = Math.floor(v.getDuration() * wChapterSegmentWrap / myMedia.duration),
+ var width = v.getDuration() * wChapterSegmentWrap / myMedia.duration,
+ left = v.begin * wChapterSegmentWrap / myMedia.duration,
segment = $('<li>'+v.title+'</li>').css({
+ left : left,
width : width,
backgroundColor : v.color
}).attr('id', v.id);
@@ -433,6 +476,7 @@
//liste
+ v.iconTab = getIcon(v.type);
var tplAnnotationRow = getTemplate('#tpl-list-annotation-row');
tplAnnotationRow = Mustache.render(tplAnnotationRow, v);
annotationList.append(tplAnnotationRow);
@@ -469,14 +513,25 @@
//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');
+ btnDeleteModal.attr('data-id', idAnnotation);
+ });
- });
+ function deleteAnnotation(idAnnotation){
+ $("#modal-confirm").modal('hide');
+ annotations = _(annotations).reject(function(c) { return c.id == idAnnotation; });
+ closeTab(idAnnotation);
+ renderAnnotation();
+ }
//tab
$('#onglet-annotations').on('click', 'a', function(e){