diff -r c4c876db76fb -r a5977736d2b0 web/res/metadataplayer/Annotation.js --- a/web/res/metadataplayer/Annotation.js Tue Jul 03 18:19:39 2012 +0200 +++ b/web/res/metadataplayer/Annotation.js Fri Jul 06 18:22:13 2012 +0200 @@ -1,67 +1,73 @@ -// TODO: Open share links in a small window - Migrate Timeupdate functions to Extract +// TODO: Migrate Timeupdate functions to Extract IriSP.Widgets.Annotation = function(player, config) { IriSP.Widgets.Widget.call(this, player, config); this.lastAnnotation = false; + this.minimized = this.start_minimized || false; + this.bounds = [ 0, 0 ]; }; IriSP.Widgets.Annotation.prototype = new IriSP.Widgets.Widget(); IriSP.Widgets.Annotation.prototype.messages = { - "fr": { - share_on: "Partager sur", + fr: { watching: "Je regarde ", on_site: " sur ", - tags: "Mots-clés :", + tags_: "Mots-clés :", + description_: "Description :", excerpt_from: "Extrait de :" }, - "en": { - share_on: "Share on", + en: { watching: "I'm watching ", on_site: " on ", - tags: "Keywords:", + tags_: "Keywords:", + description_: "Description:", excerpt_from: "Excerpt from:" } } IriSP.Widgets.Annotation.prototype.template = '
' - + '
' - + '' - + '' - + '' - + '

' + + '
' + + '
' + + '
' + + '

' + '( - )

' + '

{{l10n.excerpt_from}} ' + '( - )

' - + '

' - + '
{{l10n.tags}}

    '; + + '
    {{l10n.description_}}
    ' + + '

    ' + + '
    ' + + '
    {{l10n.tags_}}
    ' + + '
    '; IriSP.Widgets.Annotation.prototype.defaults = { annotation_type : "chap", + start_minimized: false, show_top_border : false, site_name : "Lignes de Temps" } IriSP.Widgets.Annotation.prototype.draw = function() { this.renderTemplate(); + this.insertSubwidget(this.$.find(".Ldt-Annotation-Social"), "socialWidget", { type: "Social" }); 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.bindPopcorn("IriSP.Annotation.getBounds","sendBounds"); + this.$.find(".Ldt-Annotation-MaxMinButton").click(this.functionWrapper("toggleSize")); 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; - }); + _list = this.getWidgetAnnotationsAtTime(); 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.bounds = [ _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}); } @@ -69,8 +75,13 @@ 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 ]); + this.bounds = [ _time, _time ]; } + this.sendBounds(); +} + +IriSP.Widgets.Annotation.prototype.sendBounds = function() { + this.player.popcorn.trigger("IriSP.Annotation.boundsChanged",this.bounds); } IriSP.Widgets.Annotation.prototype.drawAnnotation = function(_annotation) { @@ -85,7 +96,7 @@ return '
  • ' + _tag + '
  • '; }).join(""); this.$.find(".Ldt-Annotation-Tags").html(_html); - this.$.find(".Ldt-Annotation-Tags-Block").removeClass("Ldt-Annotation-NoTags"); + this.$.find(".Ldt-Annotation-Tags-Block").removeClass("Ldt-Annotation-EmptyBlock"); /* Correct the empty tag bug */ this.$.find('.Ldt-Annotation-TagLabel').each(function() { @@ -99,10 +110,16 @@ _this.player.popcorn.trigger("IriSP.search.triggeredSearch", IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,'')); }); } else { - this.$.find(".Ldt-Annotation-Tags-Block").addClass("Ldt-Annotation-NoTags"); + this.$.find(".Ldt-Annotation-Tags-Block").addClass("Ldt-Annotation-EmptyBlock"); } this.$.find(".Ldt-Annotation-Title").html(_annotation.title); - this.$.find(".Ldt-Annotation-Description").html(_annotation.description); + var _desc = _annotation.description.replace(/(^\s+|\s+$)/g,''); + if (_desc) { + this.$.find(".Ldt-Annotation-Description-Block").removeClass("Ldt-Annotation-EmptyBlock"); + this.$.find(".Ldt-Annotation-Description").html(_desc); + } else { + this.$.find(".Ldt-Annotation-Description-Block").addClass("Ldt-Annotation-EmptyBlock"); + } this.$.find(".Ldt-Annotation-Begin").html(_annotation.begin.toString()); this.$.find(".Ldt-Annotation-End").html(_annotation.end.toString()); if (_annotation.elementType === "mashedAnnotation") { @@ -113,9 +130,9 @@ } else { this.$.find('.Ldt-Annotation-Inner').removeClass("Ldt-Annotation-isMashup"); } - this.$.find(".Ldt-Annotation-Fb").attr("href", "http://www.facebook.com/share.php?" + IriSP.jQuery.param({ u: _url, t: _text })); - this.$.find(".Ldt-Annotation-Twitter").attr("href", "https://twitter.com/intent/tweet?" + IriSP.jQuery.param({ url: _url, text: _text })); - this.$.find(".Ldt-Annotation-Gplus").attr("href", "https://plusone.google.com/_/+1/confirm?" + IriSP.jQuery.param({ url: _url, title: _text })); + if (typeof this.socialWidget !== "undefined") { + this.socialWidget.updateUrls(_url, _text); + } this.$.find(".Ldt-Annotation-Inner").removeClass("Ldt-Annotation-Empty"); } @@ -127,10 +144,20 @@ this.$.slideDown(); } +IriSP.Widgets.Annotation.prototype.toggleSize = function() { + if (this.minimized) { + this.maximize(); + } else { + this.minimize(); + } +} + IriSP.Widgets.Annotation.prototype.minimize = function() { + this.minimized = true; this.$.find('.Ldt-Annotation-Inner').addClass("Ldt-Annotation-Minimized"); } IriSP.Widgets.Annotation.prototype.maximize = function() { + this.minimized = false; this.$.find('.Ldt-Annotation-Inner').removeClass("Ldt-Annotation-Minimized"); } \ No newline at end of file