--- a/src/metadatacomposer/static/metadatacomposer/js/edition.js Tue May 28 18:51:57 2013 +0200
+++ b/src/metadatacomposer/static/metadatacomposer/js/edition.js Wed May 29 11:39:49 2013 +0200
@@ -7,7 +7,6 @@
$(function(){
var global = {
- diaporama : null,
idAnnotation : null,
colorsIndex : 0,
colors :
@@ -18,15 +17,39 @@
};
+
+
myProject.onLoad(function() {
+
+
+
+//load Annotations
+myProject.getAnnotationsByTypeTitle("annotations");
+
+
$(".project-title").text(myProject.title);
myMedia = myProject.getCurrentMedia();
-
+
+//load Chapitre
+var _chapters = myProject.getAnnotationsByTypeTitle("chapitrage");
+if(_chapters.length){
+ $.each(_chapters, function(k, v){
+ var render = false;
+ if((k+1) == _chapters.length){
+ render = true;
+ }
+ newChapter(v, render);
+ });
+}
+
+
+
+
//chargement des chapitres et annotations existants
- loadInitChapters();
- loadInitAnnotation()
+ // loadInitChapters();
+ loadInitAnnotation();
IriSP.htmlPlayer(
myMedia,
@@ -35,7 +58,16 @@
width: 460,
height: 345,
controls: true,
- autostart: true
+ autostart: true,
+ url_transform: function(src) {
+ return [{
+ type: "video/mp4",
+ src: src.replace(/\.[\d\w]+$/,'.mp4')
+ }, {
+ type: "video/webm",
+ src: src.replace(/\.[\d\w]+$/,'.webm')
+ }];
+ }
}
);
@@ -115,12 +147,9 @@
//########### modal
$(document).on('click', 'a.open-modal', function(e){
- var diaporama = $(this).attr('data-diaporama'),
- idAnnotation = $(this).attr('data-id');
+ var idAnnotation = $(this).attr('data-id');
- if(diaporama !== undefined){
- global.diaporama = diaporama;
- }
+
if(idAnnotation !== undefined){
global.idAnnotation = idAnnotation;
}
@@ -133,27 +162,23 @@
$('.input-image-'+typeImage).show();
});
-//bibliotheque
+//select on bibliotheque
+
//video
$('.popup').on('click', '.bibliotheque-video a', function(e){
e.preventDefault();
+
+ var url = $(this).attr('href');
+ currentAnnotation.content.url = url;
+
$('.popup').modal('hide');
$.get('template.html', function(templates){
var videoWrap = $('#tab-'+global.idAnnotation).find('.annotation-video-content'),
tplVideo = $(templates).filter('#tpl-video-row').html();
- console.log(videoWrap)
videoWrap.empty().append(tplVideo);
});
});
- //image
- $('.popup').on('click', '.bibliotheque-image a', function(e){
- e.preventDefault();
- var listDiaporama = $('#'+global.diaporama);
- addImageToDiaporama(listDiaporama);
- $('.popup').modal('hide');
- });
-
//confirmation suppression
@@ -265,7 +290,7 @@
});
//nouveau chapitre
- function newChapter(dataChapter){
+ function newChapter(dataChapter, render){
var chapter = new IriSP.Model.Annotation(false, myProject);
chapter.setMedia(myMedia.id);
chapter.setBegin(dataChapter.begin);
@@ -276,7 +301,7 @@
chapter.color = global.colors[(global.colorsIndex<global.colors.length) ? global.colorsIndex++ : (global.colorsIndex=0)];
chapters.push(chapter);
- renderChapter();
+ if(render){renderChapter();}
loadFormChapter(chapter.id);
}
@@ -291,7 +316,7 @@
keywords : ['tag1','tag2']
};
- newChapter(dataChapter);
+ newChapter(dataChapter, true);
});
@@ -505,6 +530,7 @@
currentAnnotation = _.find(annotations, function(c){ return c.id == idAnnotation; });
$.get('template.html', function(templates){
+
//head commun à tous
var tplHead = $(templates).filter('#tpl-head').html();
var output = Mustache.render(tplHead, dataView);
@@ -512,30 +538,59 @@
$(tabContent).find(".slider-duration").slider(configSlider(dataView));
$(tabContent).find('.tag-it').tagit(tagitParam);
//type
- var viewType = {id : idAnnotation};
+ var viewType = {
+ id : idAnnotation,
+ content : dataView.content
+ };
var tpl = $(templates).filter('#tpl-'+type).html();
+
tpl = Mustache.render(tpl, viewType);
$(tabContent).append(tpl);
$('.tab-content').append(tabContent);
//particularité selon type
switch(type){
- case 'sound':
+ case 'audio':
break;
case 'video':
+
+ if(viewType.content.url != ""){
+ var videoWrap = $(tabContent).find('.annotation-video-content'),
+ tplVideo = $(templates).filter('#tpl-video-row').html();
+ videoWrap.empty().append(tplVideo);
+ }
+
break;
case 'text':
var cledit = $(tabContent).find('.wysiwyg').cleditor(wysiwygConfig)[0];
break;
case 'links':
+ var tbody = $(tabContent).find('tbody.links-rows'),
+ links = viewType.content.links;
+ if(links.length){
+ $.each(links, function(k,v){
+ addLinkRow(tbody, v);
+ });
+ }else{//il n'y a pas de lien on en ajoute 1
+ addLinkRow(tbody);
+ }
break;
+
case 'slideshow':
+
$(tabContent).find('.number-spin').spin(spinParam);
$(tabContent).find('.ui-sortable').sortable({
stop : function(event, ui){
disabledBtnSortable($(this));
}
});
+ var diaporama = $(tabContent).find('#diaporama-'+idAnnotation),
+ images = viewType.content.images;
+ if(images.length){
+ $.each(images, function(k,v){
+ addImageToDiaporama(diaporama, v);
+ });
+ }
break;
}
@@ -551,7 +606,7 @@
function getIcon(type){
var icon;
switch(type){
- case 'sound': icon = 'volume-up';
+ case 'audio': icon = 'volume-up';
break;
case 'video': icon = 'film';
break;
@@ -599,12 +654,29 @@
}
//diaporama
- function addImageToDiaporama(diaporama){
+
+ //bibliotheque
+ $('.popup').on('click', '.bibliotheque-image a', function(e){
+ e.preventDefault();
+
+ var url = $(this).attr('href'),
+ image = {
+ id : currentAnnotation.id,
+ url : url,
+ title : 'titre image',
+ description : 'description azerty'
+ };
+ currentAnnotation.content.images.push(image);
+
+ var listDiaporama = $('#diaporama-'+currentAnnotation.id);
+ addImageToDiaporama(listDiaporama, image);
+ $('.popup').modal('hide');
+ });
+
+ function addImageToDiaporama(diaporama, dataView){
$.get('template.html', function(templates){
- var tplDiapo = $(templates).filter('#tpl-diaporama-row').html(),
- uniqId = 'id' + (new Date()).getTime(),
- viewDiapo = { ridid : uniqId};
- tplDiapo = Mustache.render(tplDiapo, viewDiapo);
+ var tplDiapo = $(templates).filter('#tpl-diaporama-row').html();
+ tplDiapo = Mustache.render(tplDiapo, dataView);
diaporama.append(tplDiapo);
disabledBtnSortable(diaporama);
});
@@ -631,10 +703,48 @@
}
-
+//links
+$('.tab-content').on('click', '.add-link', function(e){
+ e.preventDefault();
+ var tbody = $(this).parents('tfoot').siblings('tbody');
+ addLinkRow(tbody);
+});
+$('.tab-content').on('click', '.delete-link', function(e){
+ e.preventDefault();
+ var row = $(this).parents('tr'),
+ tbody = $(this).find('tbody');
+ row.remove();
+ updateLinks(tbody);
+});
+function addLinkRow(tbody, dataView){
+ $.get('template.html', function(templates){
+ //head commun à tous
+ var tplLinkRow = $(templates).filter('#tpl-links-row').html();
+ var output = Mustache.render(tplLinkRow, dataView);
+ tbody.append(output);
+ });
+}
+$('.tab-content').on('keyup', '.links-rows input', function(e){
+ var tbody = $(this).parents('.links-rows');
+ updateLinks(tbody);
+});
+function updateLinks(tbody){
+ links = new Array();
+ $.each(tbody.find('tr'), function(k, v){
+ var urlLink = $(v).find('.url-link').val(),
+ titleLink = $(v).find('.title-link').val(),
+ link = {
+ uri : urlLink,
+ title : titleLink
+ };
+ links.push(link);
+ });
+ currentAnnotation.content.links = links;
+}
//annotation html
+/*
$('.tab-content').on('click', '.btn-html-apercu', function(e){
e.preventDefault();
@@ -643,18 +753,33 @@
apercuWrap.empty().html(htmlTextarea.val());
});
+*/
-//annotation texte
-$(document).on('keyup', ".cleditorMain iframe", function(){
+//annotation audio
+$('.tab-content').on('keyup', '.annotation-audio-content input, .annotation-audio-content textarea', function(){
+ var name = $(this).attr('name'),
+ value = $(this).val();
- var v = $(this).text(); // or .html() if desired
- $('#x').html(v);
+ currentAnnotation.content[name] = value;
});
-//annotation > diaporama (spin)
+
+//annotation slideshow
+$('.tab-content').on('click', '.btn-autostart', function(){
+ var autostart = $(this).attr('data-autostart');
+ if(autostart == "true"){ autostart = true;}
+ else {autostart = false;}
+ currentAnnotation.content.autostart = autostart;
+});
+$('.tab-content').on('change keyup', '.config-diaporama input[name=duration]', function(){
+ var value = $(this).val();
+ if(!isNaN(value)){
+ currentAnnotation.content.duration = value;
+ }
+});
+
//################ config
-
//tagit
function onTagItChange(e, ui) {
var tagitType = $(this).attr('data-type'),
@@ -691,11 +816,11 @@
docType: '<!DOCTYPE HTML>',
bodyStyle: "margin:0; font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif;",
updateTextArea : function(text){
-
+ currentAnnotation.content.text = text;
return text;
},
updateFrame: function(text){
-
+ currentAnnotation.content.text = text;
return text;
}
};
@@ -736,9 +861,9 @@
function getContentAnnotationByType(type){
var content;
switch(type){
- case 'sound':
+ case 'audio':
content = {
- mimetype : "application/x-ldt-sound",
+ mimetype : "application/x-ldt-audio",
url : "",
embedcode : ""
};
@@ -754,13 +879,12 @@
content = {
mimetype : "application/x-ldt-text",
markup : "html",
- text : ""
+ text : "azerty"
};
break;
case 'links':
content = {
mimetype : "application/x-ldt-links",
- markup : "html",
links : []
};
break;
@@ -778,7 +902,7 @@
//test
-a = $(".wysiwyg").cleditor(wysiwygConfig);
+//a = $(".wysiwyg").cleditor(wysiwygConfig);
$('.number-spin').spin(spinParam);
@@ -794,4 +918,13 @@
$(".tag-it").tagit();
+$('.log-annotations').bind('click', function(e){
+ e.preventDefault();
+ console.log(annotations.length + ' annotations', annotations);
+});
+
+$('.log-chapters').bind('click', function(e){
+ e.preventDefault();
+ console.log(chapters.length + ' chapitres',chapters);
+});
});//ready
\ No newline at end of file
--- a/src/metadatacomposer/static/metadatacomposer/js/ldt-serializer.js Tue May 28 18:51:57 2013 +0200
+++ b/src/metadatacomposer/static/metadatacomposer/js/ldt-serializer.js Wed May 29 11:39:49 2013 +0200
@@ -131,6 +131,7 @@
}
_res.color = '#' + _c;
}
+ _res.content = _data.content;
_res.setMedia(_data.media);
_res.setAnnotationType(_data.meta["id-ref"]);
_res.setTags(IriSP._(_data.tags).pluck("id-ref"));
@@ -153,14 +154,22 @@
id : _data.id,
begin : _data.begin.milliseconds,
end : _data.end.milliseconds,
- content : {
- title : _data.title || "",
- description : _data.description || "",
- audio : _data.audio,
- img: {
- src: _data.thumbnail
+ content : IriSP._.defaults(
+ {},
+ {
+ title : _data.title,
+ description : _data.description,
+ audio : _data.audio,
+ img: {
+ src: _data.thumbnail
+ }
+ },
+ _data.content,
+ {
+ title: "",
+ description: ""
}
- },
+ ),
color: _color,
media : _data.media.id,
meta : {
@@ -177,6 +186,7 @@
}
})
}
+ _res.content.title = _data.title || _res.content.title || "";
_dest.annotations.push(_res);
}
},