--- a/src/metadatacomposer/static/metadatacomposer/js/edition.js Fri Jun 07 13:02:19 2013 +0200
+++ b/src/metadatacomposer/static/metadatacomposer/js/edition.js Fri Jun 07 15:41:12 2013 +0200
@@ -24,12 +24,20 @@
}
});
-$('.timeline-annotations').bind('click', function(e){
- var x = e.pageX - $(this).offset().left;
- myMedia.setCurrentTime(myMedia.duration * x / $(this).width());
+$('.timeline-annotations').on('click', '.annotation', function(e){
+ e.preventDefault();
+ var idAnnotation = $(this).attr('data-id'),
+ annotation = _.find(annotations, function(c){ return c.id == idAnnotation; });
+ myMedia.setCurrentTime(annotation.begin);
+ if($('#tab-annotation-'+idAnnotation).length){
+ $('a[href=#tab-annotation-'+idAnnotation+']').tab('show');
+ }else{
+ openTab(annotation.type, annotation);
+ }
});
myProject.onLoad(function() {
+ myProject.regenerateTags = true;
$(".project-title").text(myProject.title);
$('.project-title-nav').text(myProject.title);
@@ -121,19 +129,8 @@
if(v.begin <= t && v.end >= t){
currentAnnotationsDisplay.push(v.id);
if(!$('#item-current-annotation-'+v.id).length){
- var itemAnnotation =
- $('<li>')
- .attr('id', 'item-current-annotation-'+v.id)
- .attr('data-id', v.id)
- .append(
- $('<a>')
- .css('backgroundColor', v.color)
- .attr('data-id', v.id)
- .attr('href', '#')
- .append(
- $('<i>').addClass('icon-'+getIcon(v.type))
- )
- );
+ var itemAnnotation = getTemplate('#tpl-item-annotation-display');
+ itemAnnotation = Mustache.render(itemAnnotation, v);
$('.list-current-annotations').append(itemAnnotation)
}
}
@@ -154,8 +151,8 @@
}
function showCurrentAnnotationInTimeline(idAnnotation){
- $('.timeline-annotations .annotation').empty();
- $('#annotation-timeline-'+idAnnotation).html('<i class="icon-pencil"></i> '+textCurrentAnnotationEditT);
+ $('.annotation').removeClass('editing');
+ $('#annotation-timeline-'+idAnnotation).addClass('editing');
}
//display annotation view
$('.list-current-annotations').on('click', 'a', function(e){
@@ -245,6 +242,7 @@
var idChapter = $(this).parents('form').attr('data-chapter-id');
$('.chapter-segments').find('#'+idChapter).text(value);
$('#row-list-chapter-'+idChapter).find('td:first').text(value);
+ $(this).parents('form').find('.btn-delete-chapter').attr('data-title', value);
}
});
@@ -276,7 +274,7 @@
return $('#templates').find(idTpl).html();
}
//supprimer
-$('.list-chapter-wrap').on('click', '.btn-delete-chapter', function(e){
+$(document).on('click', '.btn-delete-chapter', function(e){
e.preventDefault();
if(chapters.length == 1){alert('Le projet doit contenir au moins un chapitre.'); return;}
@@ -286,6 +284,10 @@
btnDeleteModal.attr('data-id', idChapter);
});
+$(document).on('click', '.btn-ok-chapter', function(e){
+ e.preventDefault();
+ $('.form-chapter-edit').remove();
+})
function deleteChapter(idChapter){
disabledPreview();
@@ -301,7 +303,8 @@
//var newEnd = new IriSP.Model.Time(chapter.end)
chapterModify.setEnd(chapter.end);
}
- chapters = _(chapters).reject(function(c) { return c.id == idChapter; });
+ chapters.removeId(idChapter);
+ myProject.getAnnotations().removeId(idChapter, true);
renderChapter();
//si le formulaire est visible
if($('#form-chapter-edit-'+idChapter).length){
@@ -325,6 +328,7 @@
chapter.color = getRandomColor();
chapters.push(chapter);
+ myProject.getAnnotations().push(chapter);
renderChapter();
loadFormChapter(chapter.id);
}
@@ -333,12 +337,12 @@
e.preventDefault();
var dataChapter = {
- title : 'New',
- begin : myMedia.currentTime,
- end : organizeNewChapter(myMedia.currentTime),
- description : 'description',
- keywords : ['tag1','tag2']
- };
+ title : 'New',
+ begin : myMedia.currentTime,
+ end : organizeNewChapter(myMedia.currentTime),
+ description : 'description',
+ keywords : ['tag1','tag2']
+ };
newChapter(dataChapter, true);
@@ -366,7 +370,7 @@
wChapterSegmentWrap = chapterSegmentWrap.width(),
chapterList = $('.list-chapter-rows-wrap');
- chapters = _.sortBy(chapters, function(c){
+ chapters = chapters.sortBy(function(c){
return c.begin;
});
@@ -412,6 +416,7 @@
annotation.keywords = dataAnnotation.keywords;
annotation.content = getContentAnnotationByType(dataAnnotation.type);
+ myProject.getAnnotations().push(annotation);
annotations.push(annotation);
return annotation;
@@ -424,7 +429,7 @@
wTimeline = timeline.width(),
annotationList = $('#list-annotations-rows');
- annotations = _.sortBy(annotations, function(c){
+ annotations = annotations.sortBy(function(c){
return c.begin;
});
@@ -436,11 +441,16 @@
//timeline
var width = Math.floor(v.getDuration() * wTimeline / myMedia.duration),
left = Math.floor(v.begin * wTimeline / myMedia.duration),
- segment = $('<div>').css({
+ dataAnntim = {
left : left,
width : width,
- backgroundColor : v.color
- }).addClass('annotation').attr('id', 'annotation-timeline-'+v.id);
+ color : v.color,
+ id : v.id,
+ title : v.title
+ },
+ segment = getTemplate('#tpl-annotation-in-timeline');
+ segment = Mustache.render(segment, dataAnntim);
+
var isInTimeline = false;
$.each(timeline.find('li'), function(a, b){
@@ -505,6 +515,8 @@
if(name == 'title'){
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+' span').text(value);
}
});
@@ -521,7 +533,8 @@
function deleteAnnotation(idAnnotation){
disabledPreview();
$("#modal-confirm").modal('hide');
- annotations = _(annotations).reject(function(c) { return c.id == idAnnotation; });
+ annotations.removeId(idAnnotation);
+ myProject.getAnnotations().removeId(idAnnotation, true);
closeTab(idAnnotation);
renderAnnotation();
}
@@ -543,6 +556,7 @@
var dataView;
if(_.isUndefined(data)){//nouveau
+
var currentTimePlusUnMin = 60 * 1000 + myMedia.currentTime,
endAnnotation = (currentTimePlusUnMin<myMedia.duration) ? currentTimePlusUnMin : myMedia.duration;
var dataAnnotation = {
@@ -588,9 +602,14 @@
case 'audio':
break;
case 'video':
+ var labelModify = $(tabContent).find('.label-modify-video'),
+ labelAdd = $(tabContent).find('.label-add-video');
if(viewType.content.url != ""){
var videoWrap = $(tabContent).find('.annotation-video-content');
renderVideoInfo(videoWrap, viewType.content);
+ labelModify.show();
+ }else{
+ labelAdd.show();
}
break;
case 'text':
@@ -609,6 +628,7 @@
break;
case 'slideshow':
+ console.log(currentAnnotation)
$(tabContent).find('.number-spin').val(dataView.content.slideduration/1000);
$(tabContent).find('.number-spin').spin(spinParam);
$(tabContent).find('.ui-sortable').sortable({
@@ -706,7 +726,7 @@
getVideoPlayer(dataVideo.url, videoWrap);
}
- $('.popup').on('click', '.bibliotheque-video a', function(e){
+ $('.popup').on('click', '.bibliotheque-video a:not(.pagination a)', function(e){
e.preventDefault();
var url = $(this).attr('data-url'),
@@ -722,13 +742,18 @@
var videoWrap = $('#tab-annotation-'+currentAnnotation.id).find('.annotation-video-content');
renderVideoInfo(videoWrap, currentAnnotation.content);
+ var labelModify = $('#tab-annotation-'+currentAnnotation.id).find('.label-modify-video'),
+ labelAdd = $('#tab-annotation-'+currentAnnotation.id).find('.label-add-video');
+
+ labelModify.show();
+ labelAdd.hide();
});
//diaporama
//bibliotheque
- $('.popup').on('click', '.bibliotheque-image a', function(e){
+ $('.popup').on('click', '.bibliotheque-image a:not(.pagination a)', function(e){
e.preventDefault();
var url = $(this).attr('data-url'),
@@ -838,10 +863,10 @@
});
function addLinkRow(tbody, dataView){
- //head commun à tous
- var tplLinkRow = getTemplate('#tpl-links-row');
- var output = Mustache.render(tplLinkRow, dataView);
- tbody.append(output);
+ //head commun à tous
+ var tplLinkRow = getTemplate('#tpl-links-row');
+ var output = Mustache.render(tplLinkRow, dataView);
+ tbody.append(output);
}
$('.tab-content').on('keyup', '.links-rows input', function(e){
@@ -950,7 +975,7 @@
fonts: "Arial,Arial Black,Comic Sans MS,Courier New,Narrow,Garamond," +
"Georgia,Impact,Sans Serif,Serif,Tahoma,Trebuchet MS,Verdana",
sizes: "1,2,3,4,5,6,7",
- styles: [["Paragraph", "<p>"], ["Header 1", "<h1>"], ["Header 2", "<h2>"],
+ styles: [["Paragraph", "<p>"], ["Header 2", "<h2>"],
["Header 3", "<h3>"], ["Header 4","<h4>"], ["Header 5","<h5>"],
["Header 6","<h6>"]],
docType: '<!DOCTYPE HTML>',
@@ -1026,7 +1051,7 @@
content = {
mimetype : "application/x-ldt-text",
markup : "html",
- text : "azerty"
+ text : ""
};
break;
case 'links':
--- a/src/metadatacomposer/static/metadatacomposer/js/ldt-serializer.js Fri Jun 07 13:02:19 2013 +0200
+++ b/src/metadatacomposer/static/metadatacomposer/js/ldt-serializer.js Fri Jun 07 15:41:12 2013 +0200
@@ -58,7 +58,22 @@
"id-ref": _data.id
},
items: _source.getAnnotationTypes().filter(function(_at) {
- return _at.media === _data;
+ switch (typeof _at.media) {
+ case "object":
+ return (_at.media === _data);
+ case "string":
+ return (_at.media === _data.id);
+ default:
+ var _ann = _at.getAnnotations();
+ if (_ann) {
+ for (var i = 0; i < _ann.length; i++) {
+ if (_ann[i].getMedia() === _data) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
}).map(function(_at) {
return {
"id-ref": _at.id
@@ -78,6 +93,9 @@
return _res;
},
serializer : function(_data, _source, _dest) {
+ if (_source.regenerateTags && !_data.regenerated) {
+ return;
+ }
var _res = {
id : _data.id,
meta : {
@@ -179,12 +197,20 @@
"dc:creator" : _data.creator || _source.creator,
"dc:contributor" : _data.contributor || _source.contributor || _data.creator || _source.creator,
// project : _source.projectId
- },
- tags : IriSP._(_data.tag.id).map(function(_id) {
+ }
+ }
+ if (_source.regenerateTags) {
+ _res.tags = IriSP._(_data.keywords).map(function(_kw) {
+ return {
+ "id-ref": _source.__keywords[_kw.toLowerCase()].id
+ }
+ });
+ } else {
+ _res.tags = IriSP._(_data.tag.id).map(function(_id) {
return {
"id-ref" : _id
}
- })
+ });
}
_res.content.title = _data.title || _res.content.title || "";
_dest.annotations.push(_res);
@@ -248,6 +274,24 @@
annotations: []
},
_this = this;
+ if (_source.regenerateTags) {
+ _source.__keywords = {};
+ _source.getAnnotations().forEach(function(a) {
+ IriSP._(a.keywords).each(function(kw) {
+ var lkw = kw.toLowerCase();
+ if (typeof _source.__keywords[lkw] === "undefined") {
+ _source.__keywords[lkw] = {
+ id: IriSP.Model.getUID(),
+ title: kw,
+ regenerated: true
+ }
+ }
+ });
+ });
+ IriSP._(_source.__keywords).each(function(kw) {
+ _this.types.tag.serializer(kw, _source, _res);
+ })
+ }
_source.forEach(function(_list, _typename) {
if (typeof _this.types[_typename] !== "undefined") {
_list.forEach(function(_el) {
@@ -287,6 +331,9 @@
_source.projectId = _data.meta.id;
_source.title = _data.meta["dc:title"] || _data.meta.title || "";
_source.description = _data.meta["dc:description"] || _data.meta.description || "";
+ _source.creator = _data.meta["dc:creator"] || _data.meta.creator || "";
+ _source.contributor = _data.meta["dc:contributor"] || _data.meta.contributor || _source.creator;
+ _source.created = IriSP.Model.isoToDate(_data.meta["dc:created"] || _data.meta.created);
}
if (typeof _data.meta !== "undefined" && typeof _data.meta.main_media !== "undefined" && typeof _data.meta.main_media["id-ref"] !== "undefined") {