'
+ '{{#show_slice}}
{{/show_slice}}'
+ + '{{^show_slice}}{{#show_arrow}}
{{/show_arrow}}{{/show_slice}}'
+ + '
{{/tags.length}}'
+ '{{#polemics.length}}
{{l10n.add_polemic_keywords_}}
'
- + '{{#polemics}}- {{keyword}}
{{/polemics}}
{{/polemics.length}}'
+ + '{{#polemics}}
{{keyword}}{{/polemics}}
{{/polemics.length}}'
+ '
'
+ '
{{l10n.wait_while_processing}}
'
+ '
{{^always_visible}}
{{/always_visible}}
{{l10n.error_while_contacting}}
'
@@ -113,18 +143,31 @@
IriSP.Widgets.CreateAnnotation.prototype.draw = function() {
var _this = this;
+
+ this.begin = new IriSP.Model.Time();
+ this.end = this.source.getDuration();
+
+ this.tag_prefix = this.tag_prefix || "";
+
if (this.tag_titles && !this.tags) {
- this.tags = IriSP._(this.tag_titles).map(function(_tag_title) {
- var _tag,
- _tags = _this.source.getTags().searchByTitle(_tag_title);
- if (_tags.length) {
- _tag = _tags[0];
- } else {
- _tag = new IriSP.Model.Tag(false, _this.source);
- _tag.title = _tag_title;
- }
- return _tag;
- });
+ if(!(this.tag_titles.length==1 && this.tag_titles[0]=="")){
+ this.tags = IriSP._(this.tag_titles).map(function(_tag_title) {
+ var _tag,
+ _tags = _this.source.getTags().searchByTitle(_tag_title, true);
+ if (_tags.length) {
+ _tag = _tags[0];
+ } else {
+ _tag = new IriSP.Model.Tag(false, _this.source);
+ _this.source.getTags().push(_tag);
+ _tag.title = _tag_title;
+ }
+ return _tag;
+ });
+ }
+ else{
+ // we forced no tags if this.tag_titles = [''] (and not false)
+ this.tags = true;
+ }
}
if (!this.tags) {
this.tags = this.source.getTags()
@@ -137,7 +180,44 @@
});
/* We have to use the map function because Mustache doesn't like our tags object */
}
+ this.record_swf = IriSP.getLib("recordMicSwf");
this.renderTemplate();
+ if (this.show_mic_record) {
+ this.recorder = this.$.find("embed")[0];
+
+ window.setAudioUrl = function(_url) {
+ _this.audio_url = _url;
+ }
+ }
+ if (this.show_slice) {
+ this.insertSubwidget(
+ this.$.find(".Ldt-CreateAnnotation-Slice"),
+ {
+ type: "Slice",
+ show_arrow: this.show_arrow,
+ annotation_type: this.slice_annotation_type,
+ onBoundsChanged: function(_from, _to) {
+ _this.begin = new IriSP.Model.Time(_from || 0);
+ _this.end = new IriSP.Model.Time(_to || 0);
+ _this.$.find(".Ldt-CreateAnnotation-Begin").html(_this.begin.toString());
+ _this.$.find(".Ldt-CreateAnnotation-End").html(_this.end.toString());
+ }
+ },
+ "slice"
+ );
+ } else {
+ if (this.show_arrow) {
+ this.insertSubwidget(this.$.find(".Ldt-CreateAnnotation-Arrow"), {type: "Arrow"},"arrow");
+ }
+ this.onMediaEvent("timeupdate", function(_time) {
+ _this.begin = new IriSP.Model.Time(_time || 0);
+ _this.end = new IriSP.Model.Time(_time || 0);
+ _this.$.find(".Ldt-CreateAnnotation-Begin").html(_this.begin.toString());
+ if (_this.arrow) {
+ _this.arrow.moveToTime(_time);
+ }
+ });
+ }
this.$.find(".Ldt-CreateAnnotation-Close").click(function() {
_this.close_after_send
? _this.hide()
@@ -145,9 +225,17 @@
return false;
});
this.$.find(".Ldt-CreateAnnotation-TagLi, .Ldt-CreateAnnotation-PolemicLi").click(function() {
- _this.addKeyword(IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,''));
+ _this.addKeyword(IriSP.jQuery(this).attr("data-text"));
return false;
});
+ this.$.find(".Ldt-CreateAnnotation-PolemicLi").each(function() {
+ var _el = IriSP.jQuery(this),
+ _kw = _el.attr("data-text"),
+ _msg = _this.l10n["polemic" + _kw];
+ if (_msg) {
+ _el.attr("title",_msg);
+ }
+ });
this.$.find(".Ldt-CreateAnnotation-Description").bind("change keyup input paste", this.functionWrapper("onDescriptionChange"));
if (this.show_title_field) {
this.$.find(".Ldt-CreateAnnotation-Title").bind("change keyup input paste", this.functionWrapper("onTitleChange"));
@@ -163,12 +251,9 @@
this.hide();
}
- this.bindPopcorn("IriSP.CreateAnnotation.toggle","toggle");
- this.bindPopcorn("IriSP.Slice.boundsChanged","onBoundsChanged");
- this.begin = new IriSP.Model.Time();
- this.end = this.source.getDuration();
+ this.onMdpEvent("CreateAnnotation.toggle","toggle");
this.$.find("form").submit(this.functionWrapper("onSubmit"));
-}
+};
IriSP.Widgets.CreateAnnotation.prototype.showScreen = function(_screenName) {
this.$.find('.Ldt-CreateAnnotation-' + _screenName).show()
@@ -178,31 +263,35 @@
IriSP.Widgets.CreateAnnotation.prototype.show = function() {
this.visible = true;
this.showScreen('Main');
- this.$.find(".Ldt-CreateAnnotation-Description").val("").css("border-color", "#666666");
+ this.$.find(".Ldt-CreateAnnotation-Description").val("").css("border-color", "#666666").addClass("empty");
if (this.show_title_field) {
- this.$.find(".Ldt-CreateAnnotation-Title").val("").css("border-color", "#666666");
+ this.$.find(".Ldt-CreateAnnotation-Title").val("").css("border-color", "#666666").addClass("empty");
}
if (this.show_creator_field) {
this.$.find(".Ldt-CreateAnnotation-Creator").val(this.creator_name).css("border-color", "#666666");
+ if (!this.creator_name) {
+ this.$.find(".Ldt-CreateAnnotation-Creator").addClass("empty");
+ }
}
this.$.find(".Ldt-CreateAnnotation-TagLi, .Ldt-CreateAnnotation-PolemicLi").removeClass("selected");
this.$.slideDown();
if (this.minimize_annotation_widget) {
- this.player.popcorn.trigger("IriSP.Annotation.minimize");
+ this.player.trigger("Annotation.minimize");
}
- this.player.popcorn.trigger("IriSP.Slice.show");
-}
+};
IriSP.Widgets.CreateAnnotation.prototype.hide = function() {
+ if (this.recorder) {
+ this.recorder.stopRecord();
+ }
if (!this.always_visible) {
this.visible = false;
this.$.slideUp();
if (this.minimize_annotation_widget) {
- this.player.popcorn.trigger("IriSP.Annotation.maximize");
+ this.player.trigger("Annotation.maximize");
}
- this.player.popcorn.trigger("IriSP.Slice.hide");
}
-}
+};
IriSP.Widgets.CreateAnnotation.prototype.toggle = function() {
if (!this.always_visible) {
@@ -212,14 +301,7 @@
this.show();
}
}
-}
-
-IriSP.Widgets.CreateAnnotation.prototype.onBoundsChanged = function(_values) {
- this.begin = new IriSP.Model.Time(_values[0] || 0);
- this.end = new IriSP.Model.Time(_values[1] || 0);
- this.$.find(".Ldt-CreateAnnotation-Begin").html(this.begin.toString());
- this.$.find(".Ldt-CreateAnnotation-End").html(this.end.toString());
-}
+};
IriSP.Widgets.CreateAnnotation.prototype.addKeyword = function(_keyword) {
var _field = this.$.find(".Ldt-CreateAnnotation-Description"),
@@ -231,20 +313,25 @@
);
_field.val(_contents.replace(/\s{2,}/g,' ').replace(/(^\s+|\s+$)/g,''));
this.onDescriptionChange();
-}
+};
IriSP.Widgets.CreateAnnotation.prototype.pauseOnWrite = function() {
- if (this.pause_on_write && !this.player.popcorn.media.paused) {
- this.player.popcorn.pause();
+ if (this.pause_on_write && !this.media.getPaused()) {
+ this.media.pause();
}
-}
+};
IriSP.Widgets.CreateAnnotation.prototype.onDescriptionChange = function() {
var _field = this.$.find(".Ldt-CreateAnnotation-Description"),
_contents = _field.val();
_field.css("border-color", !!_contents ? "#666666" : "#ff0000");
+ if (!!_contents) {
+ _field.removeClass("empty");
+ } else {
+ _field.addClass("empty");
+ }
this.$.find(".Ldt-CreateAnnotation-TagLi, .Ldt-CreateAnnotation-PolemicLi").each(function() {
- var _rx = IriSP.Model.regexpFromTextOrArray(IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,''));
+ var _rx = IriSP.Model.regexpFromTextOrArray(IriSP.jQuery(this).attr("data-text"));
if (_contents.match(_rx)) {
IriSP.jQuery(this).addClass("selected");
} else {
@@ -253,36 +340,51 @@
});
this.pauseOnWrite();
return !!_contents;
-}
+};
IriSP.Widgets.CreateAnnotation.prototype.onTitleChange = function() {
var _field = this.$.find(".Ldt-CreateAnnotation-Title"),
_contents = _field.val();
_field.css("border-color", !!_contents ? "#666666" : "#ff0000");
+ if (!!_contents) {
+ _field.removeClass("empty");
+ } else {
+ _field.addClass("empty");
+ }
this.pauseOnWrite();
return !!_contents;
-}
+};
IriSP.Widgets.CreateAnnotation.prototype.onCreatorChange = function() {
var _field = this.$.find(".Ldt-CreateAnnotation-Creator"),
_contents = _field.val();
_field.css("border-color", !!_contents ? "#666666" : "#ff0000");
+ if (!!_contents) {
+ _field.removeClass("empty");
+ } else {
+ _field.addClass("empty");
+ }
this.pauseOnWrite();
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;
+ return false;
}
- 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 */
+ if (this.recorder) {
+ this.recorder.stopRecord();
+ }
+
+ var _this = this,
+ _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 */
+ _annotationTypes = this.source.getAnnotationTypes().searchByTitle(this.annotation_type, true), /* 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 */
@@ -298,9 +400,9 @@
* 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.setMedia(this.source.currentMedia.id); /* Id du média annoté */
_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) {
@@ -309,16 +411,42 @@
}
_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 */
+
+ var tagIds = Array.prototype.map.call(
+ this.$.find(".Ldt-CreateAnnotation-TagLi.selected"),
+ function(el) { return IriSP.jQuery(el).attr("tag-id")}
+ );
+
+ IriSP._(_annotation.description.match(/#[^\s#.,;]+/g)).each(function(_tt) {
+ var _tag,
+ _tag_title = _tt.replace(/^#/,''),
+ _tags = _this.source.getTags().searchByTitle(_tag_title, true);
+ if (_tags.length) {
+ _tag = _tags[0];
+ } else {
+ _tag = new IriSP.Model.Tag(false, _this.source);
+ _this.source.getTags().push(_tag);
+ _tag.title = _tag_title;
+ }
+ if (tagIds.indexOf(_tag.id) === -1) {
+ tagIds.push(_tag.id);
+ }
+
+ })
+
+ _annotation.setTags(IriSP._(tagIds).uniq()); /*Liste des ids de tags */
+ if (this.audio_url) {
+ _annotation.audio = {
+ src: "mic",
+ mimetype: "audio/mp3",
+ href: this.audio_url
+ };
+ }
if (this.show_creator_field) {
- _export.creator = this.$.find(".Ldt-CreateAnnotation-Creator").val();
+ _annotation.creator = this.$.find(".Ldt-CreateAnnotation-Creator").val();
} else {
- _export.creator = this.creator_name;
+ _annotation.creator = this.creator_name;
}
- _export.created = new Date();
_exportedAnnotations.push(_annotation); /* Ajout de l'annotation à la liste à exporter */
_export.addList("annotation",_exportedAnnotations); /* Ajout de la liste à exporter à l'objet Source */
@@ -336,7 +464,7 @@
function() {
_this.close_after_send
? _this.hide()
- : _this.showScreen("Main");
+ : _this.show();
},
_this.after_send_timeout
);
@@ -344,10 +472,10 @@
_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();
+ if (_this.pause_on_write && _this.media.getPaused()) {
+ _this.media.play();
}
- _this.player.popcorn.trigger("IriSP.AnnotationsList.refresh"); /* On force le rafraîchissement du widget AnnotationsList */
+ _this.player.trigger("AnnotationsList.refresh"); /* On force le rafraîchissement du widget AnnotationsList */
},
error: function(_xhr, _error, _thrown) {
IriSP.log("Error when sending annotation", _thrown);
@@ -362,5 +490,5 @@
this.showScreen('Wait');
return false;
-}
+};
diff -r 919e362b9db1 -r 3ab36f402b0c src/widgets/DailymotionPlayer.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/widgets/DailymotionPlayer.js Thu Jan 02 16:40:25 2014 +0100
@@ -0,0 +1,104 @@
+IriSP.Widgets.DailymotionPlayer = function(player, config) {
+ IriSP.Widgets.Widget.call(this, player, config);
+};
+
+IriSP.Widgets.DailymotionPlayer.prototype = new IriSP.Widgets.Widget();
+
+IriSP.Widgets.DailymotionPlayer.prototype.defaults = {
+ aspect_ratio: 14/9
+};
+
+IriSP.Widgets.DailymotionPlayer.prototype.draw = function() {
+
+ if (typeof this.video === "undefined") {
+ this.video = this.media.video;
+ }
+
+ this.height = this.height || Math.floor(this.width / this.aspect_ratio);
+
+ var _media = this.media,
+ _this = this,
+ _pauseState = true;
+
+ /* Dailymotion utilise un système de fonctions référencées dans
+ * des variables globales pour la gestion des événements.
+ */
+
+ window.onDailymotionPlayerReady = function() {
+
+ var _player = document.getElementById(_this.container);
+
+ _media.getCurrentTime = function() {
+ return new IriSP.Model.Time(1000*_player.getCurrentTime());
+ };
+ _media.getVolume = function() {
+ return _player.getVolume() / 100;
+ };
+ _media.getPaused = function() {
+ return _pauseState;
+ };
+ _media.getMuted = function() {
+ return _player.isMuted();
+ };
+ _media.setCurrentTime = function(_milliseconds) {
+ _seekPause = _pauseState;
+ return _player.seekTo(_milliseconds / 1000);
+ };
+ _media.setVolume = function(_vol) {
+ return _player.setVolume(Math.floor(_vol*100));
+ };
+ _media.mute = function() {
+ return _player.mute();
+ };
+ _media.unmute = function() {
+ return _player.unMute();
+ };
+ _media.play = function() {
+ return _player.playVideo();
+ };
+ _media.pause = function() {
+ return _player.pauseVideo();
+ };
+
+ _player.addEventListener("onStateChange", "onDailymotionStateChange");
+ _player.addEventListener("onVideoProgress", "onDailymotionVideoProgress");
+
+ _player.cueVideoByUrl(_this.video);
+
+ _media.trigger("loadedmetadata");
+ };
+
+ window.onDailymotionStateChange = function(_state) {
+ switch(_state) {
+ case 1:
+ _media.trigger("play");
+ _pauseState = false;
+ break;
+
+ case 2:
+ _media.trigger("pause");
+ _pauseState = true;
+ break;
+
+ case 3:
+ _media.trigger("seeked");
+ break;
+ }
+ };
+
+ window.onDailymotionVideoProgress = function(_progress) {
+ _media.trigger("timeupdate", new IriSP.Model.Time(_progress.mediaTime * 1000));
+ };
+
+ var params = {
+ "allowScriptAccess" : "always",
+ "wmode": "opaque"
+ };
+
+ var atts = {
+ id : this.container
+ };
+
+ swfobject.embedSWF("http://www.dailymotion.com/swf?chromeless=1&enableApi=1", this.container, this.width, this.height, "8", null, null, params, atts);
+
+};
\ No newline at end of file
diff -r 919e362b9db1 -r 3ab36f402b0c src/widgets/HelloWorld.js
--- a/src/widgets/HelloWorld.js Thu Aug 30 14:45:23 2012 +0200
+++ b/src/widgets/HelloWorld.js Thu Jan 02 16:40:25 2014 +0100
@@ -7,13 +7,13 @@
IriSP.Widgets.HelloWorld = function(player, config) {
console.log("Calling IriSP.Widget's constructor from IriSP.HelloWorldWidget");
IriSP.Widgets.Widget.call(this, player, config);
-}
+};
IriSP.Widgets.HelloWorld.prototype = new IriSP.Widgets.Widget();
IriSP.Widgets.HelloWorld.prototype.defaults = {
text: "world"
-}
+};
IriSP.Widgets.HelloWorld.prototype.template =
'
{{l10n.Hello}} {{text}}
Looks like we have {{source.contents.annotation.length}} annotations in this feed
';
@@ -25,9 +25,9 @@
"en" : {
"Hello" : "Hello,"
}
-}
+};
IriSP.Widgets.HelloWorld.prototype.draw = function() {
this.renderTemplate();
console.log("HelloWorldWidget was drawn");
-}
\ No newline at end of file
+};
\ No newline at end of file
diff -r 919e362b9db1 -r 3ab36f402b0c src/widgets/HtmlPlayer.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/widgets/HtmlPlayer.js Thu Jan 02 16:40:25 2014 +0100
@@ -0,0 +1,15 @@
+IriSP.Widgets.HtmlPlayer = function(player, config) {
+ IriSP.Widgets.Widget.call(this, player, config);
+};
+
+IriSP.Widgets.HtmlPlayer.prototype = new IriSP.Widgets.Widget();
+
+
+IriSP.Widgets.HtmlPlayer.prototype.defaults = {
+};
+
+IriSP.Widgets.HtmlPlayer.prototype.draw = function() {
+
+ IriSP.htmlPlayer(this.media, this.$, this);
+
+};
\ No newline at end of file
diff -r 919e362b9db1 -r 3ab36f402b0c src/widgets/JwpPlayer.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/widgets/JwpPlayer.js Thu Jan 02 16:40:25 2014 +0100
@@ -0,0 +1,122 @@
+IriSP.Widgets.JwpPlayer = function(player, config) {
+ IriSP.Widgets.Widget.call(this, player, config);
+};
+
+IriSP.Widgets.JwpPlayer.prototype = new IriSP.Widgets.Widget();
+
+IriSP.Widgets.JwpPlayer.prototype.defaults = {
+};
+
+IriSP.Widgets.JwpPlayer.prototype.draw = function() {
+
+ var _opts = {},
+ _player = jwplayer(this.$[0]),
+ _seekPause = false,
+ _pauseState = true;
+
+ if (typeof this.video === "undefined") {
+ this.video = this.media.video;
+ }
+
+ _opts.file = this.video;
+ _opts.flashplayer = IriSP.getLib("jwPlayerSWF");
+ _opts.primary = "flash";
+ _opts.fallback = false;
+ _opts.controls = false;
+ _opts.width = this.width;
+ if (this.height) {
+ _opts.height = this.height;
+ }
+
+ if (this.autostart) { // There seems to be an autostart bug
+ //_opts.autostart = true;
+ //_pauseState = false;
+ //this.media.trigger("play");
+ }
+
+ if (this.url_transform) {
+ _opts.file = this.url_transform(_opts.file);
+ }
+
+ // Binding functions to jwplayer
+
+ var _media = this.media;
+
+ _media.on("setcurrenttime", function(_milliseconds) {
+ _seekPause = _pauseState;
+ _player.seek(_milliseconds / 1000);
+ });
+
+ _media.on("setvolume", function(_vol) {
+ _player.setVolume(Math.floor(_vol*100));
+ _media.volume = _vol;
+ });
+
+ _media.on("setmuted", function(_muted) {
+ _player.setMute(_muted);
+ _media.muted = _muted;
+ });
+
+ _media.on("setplay", function() {
+ _player.play(true);
+ _media.paused = false;
+ });
+
+ _media.on("setpause", function() {
+ _player.pause(true);
+ _media.paused = true;
+ });
+
+ // Binding jwplater events to media
+
+ function getVolume() {
+ _media.muted = _player.getMute();
+ _media.volume = _player.getVolume() / 100;
+ }
+
+ _opts.events = {
+ onReady: function() {
+ getVolume();
+ _media.currentTime = new IriSP.Model.Time(1000*_player.getPosition() || 0);
+ _media.trigger("loadedmetadata");
+ },
+ onTime: function(_progress) {
+ if (_seekPause) {
+ _player.pause(true);
+ _seekPause = false;
+ } else {
+ if (_pauseState && _player.getState() === "PLAYING") {
+ _pauseState = false;
+ _media.trigger("play");
+ }
+ }
+ _media.trigger("timeupdate", new IriSP.Model.Time(_progress.position * 1000));
+ },
+ onPlay: function() {
+ if (!_seekPause) {
+ _pauseState = false;
+ _media.trigger("play");
+ }
+ },
+ onPause: function() {
+ _pauseState = true;
+ _media.trigger("pause");
+ },
+ onSeek: function() {
+ _media.trigger("seeked");
+ },
+ onMute: function(_event) {
+ _media.muted = _event.mute;
+ _media.trigger("volumechange");
+ },
+ onVolume: function(_event) {
+ _media.volume = _event.volume / 100;
+ _media.trigger("volumechange");
+ }
+ };
+
+ _player = _player.setup(_opts);
+
+ this.jwplayer = _player;
+
+};
\ No newline at end of file
diff -r 919e362b9db1 -r 3ab36f402b0c src/widgets/KnowledgeConcierge.css
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/widgets/KnowledgeConcierge.css Thu Jan 02 16:40:25 2014 +0100
@@ -0,0 +1,97 @@
+.Ldt-Kc-Slider {
+ width: 100%; height: 8px; margin: 3px 0; font-size: 8px;
+}
+
+.Ldt-Kc-Canvas {
+ border: 1px solid #999999;
+}
+
+.Ldt-Kc-Related {
+ display: none;
+}
+
+.Ldt-Kc-Related-Empty {
+ text-align: center; font-weight: bold; font-style: italic;
+ font-size: 14px; color: #999999; margin: 5px 0;
+}
+
+.Ldt-Kc-Related h2 {
+ border: none;
+ color: #330099;
+ font-size: 18px;
+ margin: 8px 0 2px;
+ padding: 0 5px;
+}
+
+h3.Ldt-Kc-For-Keywords {
+ border-bottom: 1px solid #666666;
+ color: #000000;
+ font-size: 12px;
+ margin: 2px 0 5px;
+ padding: 0 5px 5px;
+ text-align: right;
+}
+
+.Ldt-Kc-Keywords {
+ color: #d000c0; font-weight: bold;
+}
+
+.Ldt-Kc-Related-Item {
+ width: 235px; float: left; margin: 4px 0; padding: 4px 0;
+}
+
+.Ldt-Kc-Related-Item:hover {
+ background: #e8e8e8;
+}
+
+.Ldt-Kc-Related-Item:nth-child(even) {
+ margin-left: 10px;
+}
+
+.Ldt-Kc-Related-Item a {
+ text-decoration: none;
+}
+
+.Ldt-Kc-Related-Item img {
+ max-width: 80px; max-height: 60px; float: left;
+}
+
+.Ldt-Kc-Related-Item h3, .Ldt-Kc-Related-Item p {
+ margin: 0 0 5px 85px;
+}
+
+.Ldt-Kc-Related-Item h3 {
+ font-size: 14px; font-weight: 600;
+}
+
+.Ldt-Kc-Related-Item h3 a {
+ color: #330099;
+}
+
+.Ldt-Kc-Related-Item h3 a:hover {
+ text-decoration: underline;
+}
+
+.Ldt-Kc-Related-Item p {
+ font-size: 12px;
+}
+
+.Ldt-Kc-Item-Duration {
+ color: #c00000;
+}
+
+.Ldt-Kc-Row {
+ border-bottom: 1px solid #CCCCCC;
+ clear: both; float: left; width: 100%;
+}
+
+.Ldt-Kc-Clearer {
+ clear: both;
+}
+
+.Ldt-Kc-Waiting {
+ display: none;
+ height: 128px;
+ width: 100%;
+ background:url(img/loader.gif) center no-repeat;
+}
diff -r 919e362b9db1 -r 3ab36f402b0c src/widgets/KnowledgeConcierge.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/widgets/KnowledgeConcierge.js Thu Jan 02 16:40:25 2014 +0100
@@ -0,0 +1,333 @@
+IriSP.Widgets.KnowledgeConcierge = function(player, config) {
+ IriSP.Widgets.Widget.call(this, player, config);
+};
+
+IriSP.Widgets.KnowledgeConcierge.prototype = new IriSP.Widgets.Widget();
+
+IriSP.Widgets.KnowledgeConcierge.prototype.defaults = {
+ width: 600,
+ height: 500,
+ sketch_path: "tmgraph",
+ sketch_files: [ "tmgraph.pde", "physics.pde", "model.pde", "javascript.pde", "menu.pde", "event.pde", "constants.pde", "initialdata.pde"],
+ kc_api_root: "/kn-concierge/",
+ related_api_endpoint: "",
+ use_word_boundaries: false,
+ related_data_type: 'json', // SET TO "jsonp" FOR CROSS-DOMAIN OPERATION
+ related_count: 8,
+};
+
+IriSP.Widgets.KnowledgeConcierge.prototype.messages = {
+ "fr": {
+ related_videos: "Vidéos liées",
+ duration_: "Durée\u00a0:",
+ for_keywords_: "pour le(s) mots-clé(s)\u00a0:",
+ no_matching_videos: "Pas de vidéos correspondantes"
+ },
+ "en": {
+ related_videos: "Related Videos",
+ duration_: "Duration:",
+ for_keywords_: "for keyword(s):",
+ no_matching_videos: "No matching videos"
+ }
+};
+
+IriSP.Widgets.KnowledgeConcierge.prototype.template =
+ '
'
+ + '
';
+
+IriSP.Widgets.KnowledgeConcierge.prototype.draw = function() {
+ this.renderTemplate();
+ var _canvasHeight = this.height - 16,
+ _canvasWidth = this.width - 2,
+ _canvas = this.$.find(".Ldt-Kc-Canvas"),
+ _tmpId = IriSP._.uniqueId("Processing-"),
+ _slider = this.$.find(".Ldt-Kc-Slider"),
+ radius = .375 * Math.min(_canvasHeight, _canvasWidth);
+ _canvas.attr({
+ width: _canvasWidth,
+ height: _canvasHeight,
+ id: _tmpId
+ }).css({
+ width: _canvasWidth,
+ height: _canvasHeight
+ });
+ var _this = this,
+ _pjsfiles = IriSP._(this.sketch_files).map(function(_f) { return _this.sketch_path + "/" + _f; }),
+ _selectedText = "",
+ currentNodesList = "",
+ relatedCache = {},
+ relatedRequests = {},
+ relatedTemplate = '
';
+
+ Processing.loadSketchFromSources(_canvas[0],_pjsfiles);
+
+ function renderRelated() {
+ var keywords = currentNodesList;
+ _this.$.find(".Ldt-Kc-Related").show();
+ if (typeof relatedCache[keywords] === "undefined") {
+ return;
+ }
+ _this.$.find(".Ldt-Kc-Waiting").hide();
+ if (relatedCache[keywords].length) {
+ var _html = '
';
+ IriSP._(relatedCache[keywords]).each(function(media, i) {
+ var _tmpldata = {
+ widget: _this,
+ media: media,
+ description: media.description.replace(/(\n|\r|\r\n)/mg,' ').replace(/(^.{120,140})[\s].+$/m,'$1…'),
+ duration: new IriSP.Model.Time(media.duration).toString(),
+ escaped_keyword: encodeURIComponent(keywords.split(",")[0])
+ };
+ _html += Mustache.to_html(relatedTemplate, _tmpldata);
+ if (i % 2) {
+ _html += '
';
+ }
+ });
+ _html += '
';
+ _this.$.find(".Ldt-Kc-Related-List").html(_html);
+ } else {
+ _this.$.find(".Ldt-Kc-Related-List").html("
" + _this.l10n.no_matching_videos + "
");
+ }
+ }
+
+ function triggerSearch(text) {
+ if (_selectedText !== text) {
+ _selectedText = text;
+ _this.source.getAnnotations().search(text);
+ }
+ }
+
+ function searchNodes(tags) {
+ var _tlist = (_this.use_word_boundaries ? IriSP._(tags).map(function(t) { return "\\\\y" + t + "\\\\y" }) : tags),
+ _q = "(?i)(" + _tlist.join("|") + ")";
+ jQuery.getJSON(
+ _this.kc_api_root + "topics.jsp",
+ {
+ proj: _this.project_id,
+ q: _q
+ },
+ function(data) {
+ if (data && data.items && data.items.length) {
+ for (var i=0, l=data.items.length; i
1) {
+ node.position(Math.floor(radius*Math.sin(2 * Math.PI * i / l)),Math.floor(radius*Math.cos(2 * Math.PI * i / l)));
+ }
+ }
+ }
+ }
+ );
+ }
+
+ function showRelated(nodetexts) {
+ currentNodesList = nodetexts;
+ _this.$.find(".Ldt-Kc-Related-List").html("");
+ _this.$.find(".Ldt-Kc-Keywords").html(nodetexts.replace(/\,/g,", "));
+ if (typeof relatedCache[nodetexts] === "undefined") {
+ _this.$.find(".Ldt-Kc-Waiting").show();
+ if (relatedRequests[nodetexts]) {
+ return;
+ }
+ relatedRequests[nodetexts] = true;
+ IriSP.jQuery.ajax({
+ url: _this.related_api_endpoint,
+ data: {
+ format: _this.related_data_type,
+ keywords: nodetexts
+ },
+ dataType: _this.related_data_type,
+ success: function(data) {
+ relatedCache[nodetexts] = IriSP._(data.objects)
+ .chain()
+ .filter(function(o) {
+ return o.iri_id !== _this.media.id;
+ })
+ .sortBy(function(o) {
+ return - o.score;
+ })
+ .first(_this.related_count)
+ .value();
+ renderRelated();
+ }
+ });
+ } else {
+ renderRelated();
+ }
+ }
+
+ function rootNode(id, proj) {
+ jQuery.getJSON(
+ _this.kc_api_root + "topic.jsp",
+ {
+ id: id,
+ proj: proj
+ },
+ function(response) {
+ if (response != null && response.items.length > 0){
+ item = response.items[0];
+ _pjs.initNode(item.id, item.name, item.grp, item.uid, item.proj);
+ _fns.countassoc(item.id, item.proj);
+ }
+ }
+ );
+ }
+
+ function bindJavascript() {
+ _pjs = Processing.getInstanceById(_tmpId);
+ if (_pjs && typeof _pjs.bindJavascript === "function") {
+ setTimeout(function() {
+ _pjs.bindJavascript(_fns);
+ _pjs.setSize(_canvasWidth,_canvasHeight);
+ var _edit = false,
+ _teamMode = true;
+ _pjs.saveMode("en",false,_teamMode,false,"both",_edit);
+ rootNode(_this.topic_id, _this.project_id);
+ _slider.slider({
+ min: -20,
+ max: 20,
+ value: 0,
+ range: "min",
+ slide: function(event, ui) {
+ _pjs.zoom(Math.exp(ui.value / 10));
+ }
+ });
+ }, 1000);
+ } else {
+ setTimeout(bindJavascript, 1000);
+ }
+ }
+ var currentSelection = null;
+ var _fns = {
+ adjacentnodes: function(id, proj, adj, both) {
+ jQuery.ajax({
+ url: _this.kc_api_root + "associations-bd.jsp",
+ cache: false,
+ data: {
+ id: id,
+ proj: proj,
+ both: both,
+ adj: adj
+ },
+ success: function(response) {
+ if (response.items.length > 0){
+ for(i = 0, end = response.items.length; i < end; i++) {
+ item = response.items[i];
+ _pjs.addEdge(item.asc_id, item.id, item.from_proj, item.to_id, item.to_proj,
+ item.r_name, item.r_from, item.r_to, item.uid, item.proj);
+ _pjs.setNodeName( item.id, item.from_proj,item.name);
+ _pjs.setNodeValue(item.id, item.from_proj,item.name, item.grp, item.abst, item.from_uid);
+ if (item.from_assoc!=null) {
+ _pjs.setNodeAssoc(item.id, item.from_proj, item.from_assoc);
+ }
+ _pjs.setNodeName( item.to_id,item.to_proj, item.to_name);
+ _pjs.setNodeValue(item.to_id,item.to_proj, item.to_name,item.to_grp,item.to_abst,item.to_uid);
+ if (item.to_assoc!=null) {
+ _pjs.setNodeAssoc(item.to_id, item.to_proj, item.to_assoc);
+ }
+ }
+ return response;
+ } else {
+ //.debug('No such topic.');
+ return null;
+ }
+ }
+ });
+ },
+ setscale: function(scl){
+ _slider.slider("value", 10*Math.log(scl));
+ },
+ countassoc: function(id, proj) {
+ jQuery.ajax({
+ url: _this.kc_api_root + "count-assoc.jsp",
+ data: {
+ id: id,
+ proj: proj
+ },
+ success: function(response) {
+ if (response.items.length > 0){
+ for(i = 0, end = response.items.length; i < end; i++) {
+ item = response.items[i];
+ _pjs.setNodeValue(item.id, item.proj, item.name, item.grp, item.abst);
+ if (item.assoc!=null) _pjs.setNodeAssoc(item.id, item.proj, item.assoc);
+ if (item.mass!=null) _pjs.setNodeMass( item.id, item.proj, item.mass);
+ }
+ }
+ }
+ });
+ },
+ username: function() {
+ var nodes = _pjs.getNodes().values().toArray(),
+ nodetexts = IriSP._(nodes).chain().pluck("name").sortBy().value().join(",");
+ showRelated(nodetexts);
+ },
+ mousemove: function(selection) {
+ if (selection !== currentSelection) {
+ if (selection) {
+ triggerSearch(selection.name);
+ }
+ currentSelection = selection;
+ }
+ },
+ click: function(selection) {
+ if (selection) {
+ triggerSearch(selection.name);
+ showRelated(selection.name);
+ } else {
+ triggerSearch();
+ }
+ }
+ };
+ var uselessfuncts = [
+ "selectnode", "selectedge", "topicnode","group_shapes",
+ "allbackup", "allretrieve", "new_topic", "pedia", "set_mode",
+ "new_relation", "startexpand", "endexpand", "new_select" //, "mouseover" //, "username"
+ ];
+
+ IriSP._(uselessfuncts).each(function(funcname) {
+ _fns[funcname] = function() {
+// console.log("Function", funcname, "called with arguments", arguments);
+ }
+ });
+
+ this.getWidgetAnnotations().forEach(function(annotation) {
+ annotation.on("click", function() {
+ var _tags = annotation.getTagTexts();
+ if (_tags.length) {
+ searchNodes(_tags);
+ }
+ });
+ });
+
+ this.source.getTags().forEach(function(tag) {
+ tag.on("click", function() {
+ if (tag.title) {
+ searchNodes([tag.title]);
+ }
+ });
+ });
+
+ var keywmatch = document.location.hash.match(/keyword=([^#?&]+)/);
+ if (keywmatch) {
+ this.player.on("widgets-loaded", function() {
+ triggerSearch(decodeURIComponent(keywmatch[1]));
+ });
+ }
+
+ bindJavascript();
+
+};
diff -r 919e362b9db1 -r 3ab36f402b0c src/widgets/MediaList.js
--- a/src/widgets/MediaList.js Thu Aug 30 14:45:23 2012 +0200
+++ b/src/widgets/MediaList.js Thu Jan 02 16:40:25 2014 +0100
@@ -7,16 +7,16 @@
IriSP.Widgets.MediaList.prototype.messages = {
"fr": {
- now_playing: "Média en cours",
- all_media: "Tous les medias",
- other_media: "Autres médias"
+ now_playing: "Vidéo en cours",
+ all_media: "Toutes les vidéos",
+ other_media: "Autres vidéos"
},
"en": {
now_playing: "Now playing",
- all_media: "All media",
- other_media: "Other media"
+ all_media: "All videos",
+ other_media: "Other videos"
}
-}
+};
IriSP.Widgets.MediaList.prototype.defaults = {
default_thumbnail : "http://ldt.iri.centrepompidou.fr/static/site/ldt/css/imgs/video_sequence.png",
@@ -49,17 +49,22 @@
var _n = this.refresh(true);
if (this.searchString) {
if (_n) {
- this.player.popcorn.trigger("IriSP.search.matchFound");
+ this.player.trigger("search.matchFound");
} else {
- this.player.popcorn.trigger("IriSP.search.noMatchFound");
+ this.player.trigger("search.noMatchFound");
}
}
-}
+};
IriSP.Widgets.MediaList.prototype.draw = function() {
- this.bindPopcorn("timeupdate","onTimeupdate");
this.$.addClass("Ldt-MediaListWidget")
this.renderTemplate();
+ var _this = this;
+ if (typeof this.media.getMedias === "function") {
+ this.media.on("enter-annotation", function(_a) {
+ _this.redraw(_a.getMedia());
+ });
+ }
this.redraw();
};
@@ -76,9 +81,9 @@
left: _scale * _annotation.begin,
width: _scale * (_annotation.end - _annotation.begin),
color: ( typeof _annotation.color !== "undefined" && _annotation.color ? _annotation.color : _this.default_color )
- }
- })
-}
+ };
+ });
+};
IriSP.Widgets.MediaList.prototype.redraw = function(_media) {
if (typeof _media !== "undefined") {
@@ -116,21 +121,10 @@
title: _media.title,
description: _media.description,
segments: _this.getSegments(_media)
- })
+ });
}).join("");
this.$.find('.Ldt-MediaList-OtherList').html(_html);
} else {
this.$.find('.Ldt-MediaList-Other').hide();
}
};
-
-IriSP.Widgets.MediaList.prototype.onTimeupdate = function() {
- var _media = this.source.currentMedia;
- if (_media.elementType === "mashup") {
- _media = _media.getMediaAtTime(this.player.popcorn.currentTime() * 1000);
- }
- if (typeof _media !== "undefined" && _media.id !== this.lastMedia) {
- this.lastMedia = _media.id;
- this.redraw(_media);
- }
-}
diff -r 919e362b9db1 -r 3ab36f402b0c src/widgets/Mediafragment.js
--- a/src/widgets/Mediafragment.js Thu Aug 30 14:45:23 2012 +0200
+++ b/src/widgets/Mediafragment.js Thu Jan 02 16:40:25 2014 +0100
@@ -4,23 +4,33 @@
this.last_hash_value = "";
window.onhashchange = this.functionWrapper("goToHash");
if (typeof window.addEventListener !== "undefined") {
+ var _this = this;
window.addEventListener('message', function(_msg) {
if (/^#/.test(_msg.data)) {
- this.setWindowHash(_msg.data);
+ _this.setWindowHash(_msg.data);
}
- })
+ });
};
- this.bindPopcorn("pause","setHashToTime");
- this.bindPopcorn("seeked","setHashToTime");
- this.bindPopcorn("IriSP.Mediafragment.setHashToAnnotation","setHashToAnnotation");
+ this.onMdpEvent("Mediafragment.setHashToAnnotation","setHashToAnnotation");
this.blocked = false;
-}
+};
IriSP.Widgets.Mediafragment.prototype = new IriSP.Widgets.Widget();
IriSP.Widgets.Mediafragment.prototype.draw = function() {
- this.goToHash();
-}
+ this.onMediaEvent("setpause","setHashToTime");
+ var _this = this;
+ this.getWidgetAnnotations().forEach(function(_annotation) {
+ _annotation.on("click", function() {
+ _this.setHashToAnnotation(_annotation.id);
+ });
+ });
+ if (this.media.loadedMetadata) {
+ this.goToHash();
+ } else {
+ this.onMediaEvent("loadedmetadata","goToHash");
+ }
+};
IriSP.Widgets.Mediafragment.prototype.setWindowHash = function(_hash) {
if (typeof window.history !== "undefined" && typeof window.history.replaceState !== "undefined") {
@@ -28,7 +38,7 @@
} else {
document.location.hash = _hash;
}
-}
+};
IriSP.Widgets.Mediafragment.prototype.getLastHash = function() {
var _tab = document.location.hash.replace(/^#/,'').split('&');
@@ -39,7 +49,7 @@
_tab.push(this.last_hash_key + '=' + this.last_hash_value);
}
return '#' + _tab.join('&');
-}
+};
IriSP.Widgets.Mediafragment.prototype.goToHash = function() {
if (document.location.hash !== this.getLastHash()) {
@@ -52,27 +62,25 @@
if (this.last_hash_key == "id") {
var _annotation = this.source.getElement(this.last_hash_value);
if (typeof _annotation !== "undefined") {
- this.player.popcorn.currentTime(_annotation.begin.getSeconds());
+ this.media.setCurrentTime(_annotation.begin);
}
}
if (this.last_hash_key == "t") {
- this.player.popcorn.currentTime(this.last_hash_value);
+ this.media.setCurrentTime(1000*this.last_hash_value);
}
break;
}
}
}
-}
+};
IriSP.Widgets.Mediafragment.prototype.setHashToAnnotation = function(_annotationId) {
this.setHash( 'id', _annotationId );
-}
+};
-IriSP.Widgets.Mediafragment.prototype.setHashToTime = function(_time) {
- if (_time !== NaN) {
- this.setHash( 't', this.player.popcorn.currentTime() );
- }
-}
+IriSP.Widgets.Mediafragment.prototype.setHashToTime = function() {
+ this.setHash( 't', this.media.getCurrentTime().getSeconds() );
+};
IriSP.Widgets.Mediafragment.prototype.setHash = function(_key, _value) {
if (!this.blocked && (this.last_hash_key !== _key || this.last_hash_value !== _value)) {
@@ -81,11 +89,11 @@
var _hash = this.getLastHash();
this.setWindowHash(_hash);
if (window.parent !== window) {
- window.parent.postMessage(_hash,"*")
+ window.parent.postMessage(_hash,"*");
}
this.block();
}
-}
+};
IriSP.Widgets.Mediafragment.prototype.unblock = function() {
if (typeof this.blockTimeout !== "undefined") {
@@ -93,12 +101,12 @@
}
this.blockTimeout = undefined;
this.blocked = false;
-}
+};
IriSP.Widgets.Mediafragment.prototype.block = function() {
if (typeof this.blockTimeout !== "undefined") {
window.clearTimeout(this.blockTimeout);
}
this.blocked = true;
- this.blockTimeout = window.setTimeout(this.functionWrapper("unblock"), 1000);
-}
+ this.blockTimeout = window.setTimeout(this.functionWrapper("unblock"), 1500);
+};
diff -r 919e362b9db1 -r 3ab36f402b0c src/widgets/MultiSegments.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/widgets/MultiSegments.js Thu Jan 02 16:40:25 2014 +0100
@@ -0,0 +1,136 @@
+IriSP.Widgets.MultiSegments = function(player, config) {
+ IriSP.Widgets.Widget.call(this, player, config);
+};
+
+IriSP.Widgets.MultiSegments.prototype = new IriSP.Widgets.Widget();
+
+IriSP.Widgets.MultiSegments.prototype.defaults = {
+ annotation_show_arrow: true,
+ annotation_start_minimized: false,
+ annotation_show_annotation_type: true,
+ show_all: false
+};
+
+IriSP.Widgets.MultiSegments.prototype.draw = function() {
+ var _this = this,
+ lines = [],
+ currentLine = null,
+ segmentsopts = {},
+ annotationopts = {};
+ IriSP._(this).each(function(_v,_k) {
+ if (/^segments_/.test(_k)) {
+ segmentsopts[_k.replace(/^segments_/,"")] = _v;
+ }
+ if (/^annotation_/.test(_k)) {
+ annotationopts[_k.replace(/^annotation_/,"")] = _v;
+ }
+ });
+ this.source.getAnnotationTypes().forEach(function(_anntype) {
+ var segments = _anntype.getAnnotations().filter(function(_ann) {
+ return _ann.getDuration() > 0;
+ });
+ if (segments.length) {
+
+ var visible = false;
+
+ var line = {
+ segmentWidget: IriSP.jQuery(""),
+ annotationWidget: IriSP.jQuery("
"),
+ hasSegmentsNow: function() {
+ var _time = _this.media.getCurrentTime();
+ return !!segments.filter(function(_annotation) {
+ return _annotation.begin <= _time && _annotation.end > _time;
+ }).length;
+ },
+ hide: function() {
+ if (visible) {
+ visible = false;
+ this.annotationWidget.slideUp();
+ }
+ },
+ show: function() {
+ if (!visible) {
+ visible = true;
+ this.annotationWidget.slideDown();
+ }
+ }
+ };
+
+
+ line.segmentWidget
+ .addClass("Ldt-MultiSegments-Segment")
+ .appendTo(_this.$);
+
+ if (!_this.show_all) {
+ line.segmentWidget.mouseenter(function() {
+ if (line.hasSegmentsNow()) {
+ currentLine = line;
+ checkVisibilities();
+ }
+ });
+ }
+
+ line.annotationWidget
+ .addClass("Ldt-MultiSegments-Annotation")
+ .appendTo(_this.$)
+ .hide();
+
+ _this.insertSubwidget(
+ line.segmentWidget,
+ IriSP._({
+ type: "Segments",
+ annotation_type: _anntype,
+ width: _this.width
+ }).extend(segmentsopts)
+ );
+
+ _this.insertSubwidget(
+ line.annotationWidget,
+ IriSP._({
+ type: "Annotation",
+ annotation_type: _anntype,
+ width: _this.width
+ }).extend(annotationopts)
+ );
+
+ lines.push(line);
+ }
+ });
+
+ // open line on segment click
+ $j(document).on("click",".Ldt-Segments-Segment",function(e){
+ if (!_this.show_all && currentLine && !currentLine.hasSegmentsNow()) {
+ currentLine = undefined;
+ }
+ IriSP._(lines).each(function(line) {
+ if($j(e.target).parent().parent()[0]==line.segmentWidget[0]){
+ currentLine = line;
+ line.show();
+ } else {
+ line.hide();
+ }
+ });
+ });
+
+ //var _annotationWidgets = _this.$.find(".Ldt-MultiSegments-Annotation");
+
+ function checkVisibilities(_time) {
+ /*if (!_this.show_all && currentLine && !currentLine.hasSegmentsNow()) {
+ currentLine = undefined;
+ }
+ IriSP._(lines).each(function(line) {
+ if (line.hasSegmentsNow()) {
+ if (!_this.show_all && !currentLine) {
+ currentLine = line;
+ }
+ if (_this.show_all || line === currentLine) {
+ line.show();
+ } else {
+ line.hide();
+ }
+ } else {
+ line.hide();
+ }
+ });*/
+ }
+};
\ No newline at end of file
diff -r 919e362b9db1 -r 3ab36f402b0c src/widgets/Polemic.js
--- a/src/widgets/Polemic.js Thu Aug 30 14:45:23 2012 +0200
+++ b/src/widgets/Polemic.js Thu Jan 02 16:40:25 2014 +0100
@@ -15,11 +15,12 @@
_to_: " to ",
_annotations: " annotation(s)"
}
-}
+};
+
IriSP.Widgets.Polemic.prototype.defaults = {
element_width : 5,
element_height : 5,
- max_elements : 15,
+ max_elements: 20,
annotation_type : "tweet",
defaultcolor : "#585858",
foundcolor : "#fc00ff",
@@ -47,45 +48,9 @@
]
};
-IriSP.Widgets.Polemic.prototype.onSearch = function(searchString) {
- this.searchString = typeof searchString !== "undefined" ? searchString : '';
- var _found = 0,
- _re = IriSP.Model.regexpFromTextOrArray(searchString, true),
- _this = this;
- this.$tweets.each(function() {
- var _el = IriSP.jQuery(this);
- if (_this.searchString) {
- if (_re.test(_el.attr("tweet-title"))) {
- _el.css({
- "background" : _this.foundcolor,
- "opacity" : 1
- });
- _found++;
- } else {
- _el.css({
- "background" : _el.attr("polemic-color"),
- "opacity" : .3
- });
- }
- } else {
- _el.css({
- "background" : _el.attr("polemic-color"),
- "opacity" : 1
- });
- }
- });
- if (this.searchString) {
- if (_found) {
- this.player.popcorn.trigger("IriSP.search.matchFound");
- } else {
- this.player.popcorn.trigger("IriSP.search.noMatchFound");
- }
- }
-}
-
IriSP.Widgets.Polemic.prototype.draw = function() {
- this.bindPopcorn("timeupdate", "onTimeupdate");
+ this.onMediaEvent("timeupdate", "onTimeupdate");
this.$zone = IriSP.jQuery('
');
this.$zone.addClass("Ldt-Polemic");
this.$.append(this.$zone);
@@ -102,6 +67,7 @@
this.$zone.append(this.$elapsed);
+ // we don't filter with null duration anymore
var _slices = [],
_slice_count = Math.floor( this.width / this.element_width ),
_duration = this.source.getDuration(),
@@ -117,10 +83,10 @@
begin : _begin.toString(),
end : _end.toString(),
annotations : _list.filter(function(_annotation) {
- return _annotation.begin >= _begin && _annotation.end < _end;
+ return _annotation.begin >= _begin && _annotation.begin < _end;
}),
polemicStacks : []
- }
+ };
for (var _j = 0; _j < this.polemics.length; _j++) {
var _polemic = _res.annotations.searchByDescription(this.polemics[_j].keywords);
@@ -149,7 +115,7 @@
function displayAnnotation(_elx, _ely, _pol, _col, _annotation) {
var _html = Mustache.to_html(
- '',
{
id: _annotation.id,
@@ -160,7 +126,8 @@
color: _col,
width: (_this.element_width-1),
height: _this.element_height,
- title: _annotation.title
+ title: _annotation.title,
+ time: _annotation.begin.toString()
});
var _el = IriSP.jQuery(_html);
_el.mouseover(function() {
@@ -168,16 +135,34 @@
}).mouseout(function() {
_annotation.trigger("unselect");
}).click(function() {
- _this.player.popcorn.trigger("IriSP.Mediafragment.setHashToAnnotation", _annotation.id);
- _this.player.popcorn.trigger("IriSP.Tweet.show", _annotation.id);
+ _annotation.trigger("click");
+ return false;
});
+ IriSP.attachDndData(_el, {
+ title: _annotation.title,
+ description: _annotation.description,
+ image: _annotation.thumbnail,
+ uri: (typeof _annotation.url !== "undefined"
+ ? _annotation.url
+ : (document.location.href.replace(/#.*$/,'') + '#id=' + _annotation.id))
+ });
+ // test if annotation has several colors.
+ var colAr = [];
+ for (var _j = 0; _j < _this.polemics.length; _j++) {
+ if( IriSP.Model.regexpFromTextOrArray( _this.polemics[_j].keywords ).test( _annotation.title ) ){
+ colAr.push(_this.polemics[_j].color);
+ }
+ }
+ // display annotation
_annotation.on("select", function() {
- _this.tooltip.show(
- Math.floor(_elx + (_this.element_width - 1) / 2),
- _ely,
- _annotation.title,
- _col
- );
+ if (_this.tooltip) {
+ _this.tooltip.show(
+ + Math.floor(_elx + (_this.element_width - 1) / 2),
+ + _ely,
+ _annotation.title,
+ ( (colAr.length>1) ? colAr : _col )
+ );
+ }
_this.$tweets.each(function() {
var _e = IriSP.jQuery(this);
_e.css(
@@ -187,9 +172,23 @@
});
});
_annotation.on("unselect", function() {
- _this.tooltip.hide();
+ if (_this.tooltip) {
+ _this.tooltip.hide();
+ }
_this.$tweets.css("opacity",1);
});
+ _annotation.on("found", function() {
+ _el.css({
+ "background" : _this.foundcolor,
+ "opacity" : 1
+ });
+ });
+ _annotation.on("not-found", function() {
+ _el.css({
+ "background" : _col,
+ "opacity" : .3
+ });
+ });
_this.$zone.append(_el);
}
@@ -214,9 +213,15 @@
this.$tweets = this.$.find(".Ldt-Polemic-TweetDiv");
- this.bindPopcorn("IriSP.search", "onSearch");
- this.bindPopcorn("IriSP.search.closed", "onSearch");
- this.bindPopcorn("IriSP.search.cleared", "onSearch");
+ this.source.getAnnotations().on("search-cleared", function() {
+ _this.$tweets.each(function() {
+ var _el = IriSP.jQuery(this);
+ _el.css({
+ "background" : _el.attr("polemic-color"),
+ "opacity" : 1
+ });
+ });
+ });
} else {
this.$zone.hide();
@@ -257,7 +262,7 @@
IriSP._(_slices).forEach(function(_slice) {
var _y = _this.height,
_nums = _slice.annotations.length + "," + IriSP._(_slice.polemicStacks).map(function(_annotations) {
- return _annotations.length
+ return _annotations.length;
}).join(",");
if (_slice.annotations.length) {
var _h = Math.ceil(_scale * _slice.annotations.length);
@@ -287,15 +292,19 @@
_html = '
' + _this.l10n.from_ + _el.attr("begin-time") + _this.l10n._to_ + _el.attr("end-time") + '
';
for (var _i = 0; _i <= _this.polemics.length; _i++) {
var _color = _i ? _this.polemics[_i - 1].color : _this.defaultcolor;
- _html += '
' + _nums[_i] + _this.l10n._annotations + '
'
+ _html += '
' + _nums[_i] + _this.l10n._annotations + '
';
}
- _this.tooltip.show(_el.attr("pos-x"), _el.attr("pos-y"), _html);
+ if (_this.tooltip) {
+ _this.tooltip.show(+ _el.attr("pos-x"), + _el.attr("pos-y"), _html);
+ }
})
.mouseout(function() {
- _this.tooltip.hide();
- })
+ if (_this.tooltip) {
+ _this.tooltip.hide();
+ }
+ });
- }
+ };
this.$position = IriSP.jQuery('
').addClass("Ldt-Polemic-Position");
@@ -303,20 +312,28 @@
this.$zone.click(function(_e) {
var _x = _e.pageX - _this.$zone.offset().left;
- _this.player.popcorn.currentTime(_this.source.getDuration().getSeconds() * _x / _this.width);
+ _this.media.setCurrentTime(_this.media.duration * _x / _this.width);
});
this.$.append('
');
- this.insertSubwidget(this.$.find(".Ldt-Polemic-Tooltip"), "tooltip", { type: "Tooltip" });
-}
+ this.insertSubwidget(
+ this.$.find(".Ldt-Polemic-Tooltip"),
+ {
+ type: "Tooltip",
+ min_x: 0,
+ max_x: this.width
+ },
+ "tooltip"
+ );
+};
-IriSP.Widgets.Polemic.prototype.onTimeupdate = function() {
- var _x = Math.floor( this.width * this.player.popcorn.currentTime() / this.source.getDuration().getSeconds());
+IriSP.Widgets.Polemic.prototype.onTimeupdate = function(_time) {
+ var _x = Math.floor( this.width * _time / this.media.duration);
this.$elapsed.css({
width: _x + "px"
});
this.$position.css({
left: _x + "px"
- })
-}
+ });
+};
diff -r 919e362b9db1 -r 3ab36f402b0c src/widgets/PopcornPlayer.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/widgets/PopcornPlayer.js Thu Jan 02 16:40:25 2014 +0100
@@ -0,0 +1,138 @@
+IriSP.Widgets.PopcornPlayer = function(player, config) {
+ IriSP.Widgets.Widget.call(this, player, config);
+};
+
+IriSP.Widgets.PopcornPlayer.prototype = new IriSP.Widgets.Widget();
+
+/* A Popcorn-based player for HTML5 Video, Youtube and Vimeo */
+
+IriSP.Widgets.PopcornPlayer.prototype.defaults = {
+};
+
+IriSP.Widgets.PopcornPlayer.prototype.draw = function() {
+
+
+ if (typeof this.video === "undefined") {
+ this.video = this.media.video;
+ }
+
+ if (this.url_transform) {
+ this.video = this.url_transform(this.video);
+ }
+
+ if (/^(https?:\/\/)?(www\.)?vimeo\.com/.test(this.video)) {
+
+ /* VIMEO */
+
+ var _popcorn = Popcorn.vimeo(this.container, this.video);
+
+ } else if (/^(https?:\/\/)?(www\.)?youtube\.com/.test(this.video)) {
+
+ /* YOUTUBE */
+
+ var _urlparts = this.video.split(/[?&]/),
+ _params = {};
+ for (var i = 1; i < _urlparts.length; i++) {
+ var _ppart = _urlparts[i].split('=');
+ _params[_ppart[0]] = decodeURIComponent(_ppart[1]);
+ }
+ _params.controls = 0;
+ _params.modestbranding = 1;
+ if (this.autostart || this.autoplay) {
+ _params.autoplay = 1;
+ }
+ _url = _urlparts[0] + '?' + IriSP.jQuery.param(_params);
+
+ var _popcorn = Popcorn.youtube(this.container, _url);
+
+ } else {
+
+ /* DEFAULT HTML5 */
+
+ var _tmpId = IriSP._.uniqueId("popcorn"),
+ _videoEl = IriSP.jQuery('