# HG changeset patch
# User veltr
# Date 1342797353 -7200
# Node ID 5aadbc9f27cd98d26c2015603987fcfd2dcbca25
# Parent 977a39c4ee80280ca19884768391ac29f9c43135
First tests before allowing mashup annotation
diff -r 977a39c4ee80 -r 5aadbc9f27cd assets/psd/socialbuttons.psd
Binary file assets/psd/socialbuttons.psd has changed
diff -r 977a39c4ee80 -r 5aadbc9f27cd src/widgets/CreateAnnotation.js
--- a/src/widgets/CreateAnnotation.js Thu Jul 12 15:30:34 2012 +0200
+++ b/src/widgets/CreateAnnotation.js Fri Jul 20 17:15:53 2012 +0200
@@ -135,7 +135,7 @@
.map(function(_tag) {
return _tag;
});
- // We have to use the map function because Mustache doesn't like our tags object
+ /* We have to use the map function because Mustache doesn't like our tags object */
}
this.renderTemplate();
this.$.find(".Ldt-CreateAnnotation-Close").click(function() {
@@ -272,52 +272,66 @@
return !!_contents;
}
+/* Fonction effectuant l'envoi des annotations */
IriSP.Widgets.CreateAnnotation.prototype.onSubmit = function() {
+ /* Si les champs obligatoires sont vides, on annule l'envoi */
if (!this.onDescriptionChange() || (this.show_title_field && !this.onTitleChange()) || (this.show_creator_field && !this.onCreatorChange())) {
return;
}
- var _exportedAnnotations = new IriSP.Model.List(this.player.sourceManager);
- _export = this.player.sourceManager.newLocalSource({serializer: IriSP.serializers[this.api_serializer]}),
- _annotation = new IriSP.Model.Annotation(false, _export),
- _annotationTypes = this.source.getAnnotationTypes().searchByTitle(this.annotation_type),
- _annotationType = (_annotationTypes.length ? _annotationTypes[0] : new IriSP.Model.AnnotationType(false, _export)),
- _url = Mustache.to_html(this.api_endpoint_template, {id: this.source.projectId});
-
+ var _exportedAnnotations = new IriSP.Model.List(this.player.sourceManager), /* Création d'une liste d'annotations contenant une annotation afin de l'envoyer au serveur */
+ _export = this.player.sourceManager.newLocalSource({serializer: IriSP.serializers[this.api_serializer]}), /* Création d'un objet source utilisant un sérialiseur spécifique pour l'export */
+ _annotation = new IriSP.Model.Annotation(false, _export), /* Création d'une annotation dans cette source avec un ID généré à la volée (param. false) */
+ _annotationTypes = this.source.getAnnotationTypes().searchByTitle(this.annotation_type), /* Récupération du type d'annotation dans lequel l'annotation doit être ajoutée */
+ _annotationType = (_annotationTypes.length ? _annotationTypes[0] : new IriSP.Model.AnnotationType(false, _export)), /* Si le Type d'Annotation n'existe pas, il est créé à la volée */
+ _url = Mustache.to_html(this.api_endpoint_template, {id: this.source.projectId}); /* Génération de l'URL à laquelle l'annotation doit être envoyée, qui doit inclure l'ID du projet */
+
+ /* Si nous avons dû générer un ID d'annotationType à la volée... */
if (!_annotationTypes.length) {
+ /* Il ne faudra pas envoyer l'ID généré au serveur */
_annotationType.dont_send_id = true;
+ /* Il faut inclure le titre dans le type d'annotation */
+ _annotationType.title = this.annotation_type;
}
- _annotationType.title = this.annotation_type;
- _annotation.setBegin(this.begin);
- _annotation.setEnd(this.end);
- _annotation.setMedia(this.source.currentMedia.id);
- _annotation.setAnnotationType(_annotationType.id);
+ /*
+ * Nous remplissons les données de l'annotation générée à la volée
+ * ATTENTION: Si nous sommes sur un MASHUP, ces éléments doivent se référer AU MEDIA D'ORIGINE
+ * */
+ _annotation.setBegin(this.begin); /*Timecode de début */
+ _annotation.setEnd(this.end); /* Timecode de fin */
+ _annotation.setMedia(this.source.currentMedia.id); /* Id du média annoté */
+
+ _annotation.setAnnotationType(_annotationType.id); /* Id du type d'annotation */
if (this.show_title_field) {
+ /* Champ titre, seulement s'il est visible */
_annotation.title = this.$.find(".Ldt-CreateAnnotation-Title").val();
}
- _annotation.created = new Date();
- _annotation.description = this.$.find(".Ldt-CreateAnnotation-Description").val();
- _annotation.setTags(this.$.find(".Ldt-CreateAnnotation-TagLi.selected").map(function() { return IriSP.jQuery(this).attr("tag-id")}));
+ _annotation.created = new Date(); /* Date de création de l'annotation */
+ _annotation.description = this.$.find(".Ldt-CreateAnnotation-Description").val(); /* Champ description */
+ _annotation.setTags(this.$.find(".Ldt-CreateAnnotation-TagLi.selected")
+ .map(function() { return IriSP.jQuery(this).attr("tag-id")})); /*Liste des ids de tags */
+ /* Les données créateur/date de création sont envoyées non pas dans l'annotation, mais dans le projet */
if (this.show_creator_field) {
_export.creator = this.$.find(".Ldt-CreateAnnotation-Creator").val();
} else {
_export.creator = this.creator_name;
}
_export.created = new Date();
- _exportedAnnotations.push(_annotation);
- _export.addList("annotation",_exportedAnnotations);
+ _exportedAnnotations.push(_annotation); /* Ajout de l'annotation à la liste à exporter */
+ _export.addList("annotation",_exportedAnnotations); /* Ajout de la liste à exporter à l'objet Source */
var _this = this;
+ /* Envoi de l'annotation via AJAX au serveur ! */
IriSP.jQuery.ajax({
url: _url,
type: this.api_method,
contentType: 'application/json',
- data: _export.serialize(),
+ data: _export.serialize(), /* L'objet Source est sérialisé */
success: function(_data) {
- _this.showScreen('Saved');
- if (_this.after_send_timeout) {
+ _this.showScreen('Saved'); /* Si l'appel a fonctionné, on affiche l'écran "Annotation enregistrée" */
+ if (_this.after_send_timeout) { /* Selon les options de configuration, on revient à l'écran principal ou on ferme le widget, ou rien */
window.setTimeout(
function() {
_this.close_after_send
@@ -327,13 +341,13 @@
_this.after_send_timeout
);
}
- _export.getAnnotations().removeElement(_annotation, true);
- _export.deSerialize(_data);
- _this.source.merge(_export);
+ _export.getAnnotations().removeElement(_annotation, true); /* Pour éviter les doublons, on supprime l'annotation qui a été envoyée */
+ _export.deSerialize(_data); /* On désérialise les données reçues pour les réinjecter */
+ _this.source.merge(_export); /* On récupère les données réimportées dans l'espace global des données */
if (this.pause_on_write && this.player.popcorn.media.paused) {
this.player.popcorn.play();
}
- _this.player.popcorn.trigger("IriSP.AnnotationsList.refresh");
+ _this.player.popcorn.trigger("IriSP.AnnotationsList.refresh"); /* On force le rafraîchissement du widget AnnotationsList */
},
error: function(_xhr, _error, _thrown) {
IriSP.log("Error when sending annotation", _thrown);
diff -r 977a39c4ee80 -r 5aadbc9f27cd src/widgets/Segments.js
--- a/src/widgets/Segments.js Thu Jul 12 15:30:34 2012 +0200
+++ b/src/widgets/Segments.js Fri Jul 20 17:15:53 2012 +0200
@@ -41,7 +41,7 @@
_center = _left + _width / 2,
_fulltext = _annotation.title + ( _annotation.description ? ( '
' + _annotation.description ) : '' );
return {
- text : _fulltext.replace(/(^.{120,140})[\s].+$/m,'$1…'),
+ text : _fulltext.replace(/(\n|\r|\r\n)/mg,' ').replace(/(^.{120,140})[\s].+$/m,'$1…'),
color : ( typeof _annotation.color !== "undefined" && _annotation.color ? _annotation.color : _this.colors[_k % _this.colors.length] ),
beginseconds : _annotation.begin.getSeconds() ,
left : Math.floor( _left ),
diff -r 977a39c4ee80 -r 5aadbc9f27cd src/widgets/Slice.js
--- a/src/widgets/Slice.js Thu Jul 12 15:30:34 2012 +0200
+++ b/src/widgets/Slice.js Fri Jul 20 17:15:53 2012 +0200
@@ -11,12 +11,14 @@
IriSP.Widgets.Slice.prototype.defaults = {
start_visible : false,
- live_update : true
+ live_update : true,
/* Shall the bounds change each time
the Annotation Widget sends an update (true)
or only when "show" is triggered (false) ?
- true is to be recommended when the widget is permanently displayed.
*/
+ override_bounds : true
+ /* Can the Annotation Widget bounds be overriden ? */
};
IriSP.Widgets.Slice.prototype.draw = function() {
@@ -52,6 +54,9 @@
_currentTime = _this.player.popcorn.currentTime();
},
slide: function(event, ui) {
+ if (!_this.override_bounds && (ui.value < _this.min || ui.value > _this.max)) {
+ return false;
+ }
_this.player.popcorn.currentTime(ui.value / 1000);
},
stop: function() {
@@ -69,7 +74,7 @@
this.bindPopcorn("IriSP.Slice.show","show");
this.bindPopcorn("IriSP.Slice.hide","hide");
this.bindPopcorn("IriSP.Annotation.boundsChanged","storeBounds");
- this.trigger("IriSP.Annotation.getBounds");
+ this.player.popcorn.trigger("IriSP.Annotation.getBounds");
};
IriSP.Widgets.Slice.prototype.show = function() {
@@ -84,10 +89,10 @@
}
IriSP.Widgets.Slice.prototype.storeBounds = function(_values) {
- if (!this.sliding && !this.player.popcorn.media.paused && (this.min != _values[0] || this.max != _values[1])) {
+ if (!this.player.popcorn.media.paused && (this.min != _values[0] || this.max != _values[1])) {
this.min = _values[0];
this.max = _values[1];
- if (this.live_update) {
+ if (this.live_update && !this.sliding) {
this.$slider.slider("values", [this.min, this.max]);
}
}
diff -r 977a39c4ee80 -r 5aadbc9f27cd src/widgets/Trace.js
--- a/src/widgets/Trace.js Thu Jul 12 15:30:34 2012 +0200
+++ b/src/widgets/Trace.js Fri Jul 20 17:15:53 2012 +0200
@@ -11,7 +11,8 @@
requestmode: 'GET',
syncmode: "sync",
default_subject: "IRI",
- tracer: null
+ tracer: null,
+ extend: false
}
IriSP.Widgets.Trace.prototype.draw = function() {
@@ -145,6 +146,9 @@
_traceName += _listener.replace('IriSP.','').replace('.','_');
}
this.lastEvent = _traceName;
+ if (typeof this.extend === "object" && this.extend) {
+ IriSP._(_arg).extend(this.extend);
+ }
this.tracer.trace(_traceName, _arg);
if (this.js_console) {
console.log("tracer.trace('" + _traceName + "', " + JSON.stringify(_arg) + ");");
diff -r 977a39c4ee80 -r 5aadbc9f27cd test/jwplayer.htm
--- a/test/jwplayer.htm Thu Jul 12 15:30:34 2012 +0200
+++ b/test/jwplayer.htm Fri Jul 20 17:15:53 2012 +0200
@@ -45,7 +45,8 @@
{ type: "Annotation" },
{
type: "CreateAnnotation",
- api_endpoint_template: "http://192.168.56.101/pf/ldtplatform/api/ldt/annotations/{{id}}.json",
+ api_endpoint_template: "post-test.php",
+ api_method: "POST",
creator_name: "Metadataplayer",
creator_avatar: "https://si0.twimg.com/sticky/default_profile_images/default_profile_1_normal.png",
tag_titles: ["#amateur", "#digital-humanities"]
diff -r 977a39c4ee80 -r 5aadbc9f27cd test/mashup/moon.htm
--- a/test/mashup/moon.htm Thu Jul 12 15:30:34 2012 +0200
+++ b/test/mashup/moon.htm Fri Jul 20 17:15:53 2012 +0200
@@ -37,6 +37,7 @@