diff -r 07ab28bca482 -r d366aa22bd79 web/res/metadataplayer/Annotation.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/res/metadataplayer/Annotation.js Thu May 03 17:52:07 2012 +0200 @@ -0,0 +1,112 @@ +// TODO: Open share links in a small window - Migrate Timeupdate functions to Extract + +IriSP.Widgets.Annotation = function(player, config) { + IriSP.Widgets.Widget.call(this, player, config); + this.lastAnnotation = false; +}; + +IriSP.Widgets.Annotation.prototype = new IriSP.Widgets.Widget(); + +IriSP.Widgets.Annotation.prototype.messages = { + "fr": { + share_on: "Partager sur", + watching: "Je regarde ", + on_site: " sur ", + tags: "Mots-clés :" + }, + "en": { + share_on: "Share on", + watching: "I'm watching ", + on_site: " on ", + tags: "Keywords:" + } +} + +IriSP.Widgets.Annotation.prototype.template = + '
'; + +IriSP.Widgets.Annotation.prototype.defaults = { + annotation_type : "chap", + show_top_border : false, + site_name : "Lignes de Temps" +} + +IriSP.Widgets.Annotation.prototype.draw = function() { + this.renderTemplate(); + this.bindPopcorn("timeupdate","onTimeupdate"); + this.bindPopcorn("IriSP.Annotation.hide","hide"); + this.bindPopcorn("IriSP.Annotation.show","show"); + this.bindPopcorn("IriSP.Annotation.minimize","minimize"); + this.bindPopcorn("IriSP.Annotation.maximize","maximize"); + this.onTimeupdate(); +} + +IriSP.Widgets.Annotation.prototype.onTimeupdate = function() { + var _time = Math.floor(this.player.popcorn.currentTime() * 1000), + _list = this.getWidgetAnnotations().filter(function(_annotation) { + return _annotation.begin <= _time && _annotation.end > _time; + }); + if (_list.length) { + if (_list[0].id !== this.lastAnnotation) { + this.drawAnnotation(_list[0]); + this.player.popcorn.trigger("IriSP.Annotation.boundsChanged",[ _list[0].begin.valueOf(), _list[0].end.valueOf() ]); + } + this.player.popcorn.trigger("IriSP.Arrow.updatePosition",{widget: this.type, time: ( _list[0].begin + _list[0].end ) / 2}); + } + else { + this.lastAnnotation = false; + this.$.find(".Ldt-Annotation-Inner").addClass("Ldt-Annotation-Empty"); + this.player.popcorn.trigger("IriSP.Arrow.updatePosition",{widget: this.type, time: _time}); + this.player.popcorn.trigger("IriSP.Annotation.boundsChanged",[ _time, _time ]); + } +} + +IriSP.Widgets.Annotation.prototype.drawAnnotation = function(_annotation) { + this.lastAnnotation = _annotation.id; + var _url = (typeof _annotation.url !== "undefined" + ? _annotation.url + : (document.location.href.replace(/#.*$/,'') + '#id=' + _annotation.namespacedId.name)); + var _text = this.l10n.watching + _annotation.title + (this.site_name ? this.l10n.on_site + this.site_name : ''); + var _tags = _annotation.getTagTexts(); + if (_tags.length) { + var _html = IriSP._(_tags).map(function(_tag) { + return '