# HG changeset patch # User durandn # Date 1435222971 -7200 # Node ID fdc8b96317013c42c0c8a30895409eeedd6f1606 # Parent 2b17782e7c08c4cb8fd9b0aa27cd037fab067360 Added LatestAnnotation widget that displays the latest annotation for a given type and potentially for the current segment diff -r 2b17782e7c08 -r fdc8b9631701 src/ldt/ldt/static/ldt/metadataplayer/LatestAnnotation.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ldt/ldt/static/ldt/metadataplayer/LatestAnnotation.css Thu Jun 25 11:02:51 2015 +0200 @@ -0,0 +1,39 @@ +.Ldt-LatestAnnotation{ + background: url(img/pinstripe.png); + width: 537px; + max-height: 180px; + margin: 0px; + margin-top: 4px; + border-style: solid; + border-width: 1px; + border-color: #b7b7b7; +} + +.Ldt-LatestAnnotation-Element{ + margin: 5px; + display: inline-block; + vertical-align: top; +} + +.Ldt-LatestAnnotation-Box{ + background-color: #ffffff; + margin: 3px; +} + +.Ldt-LatestAnnotation-CreationDate{ + color: #f7268e; +} + +.Ldt-LatestAnnotation-Content{ +} + +.Ldt-LatestAnnotation-Title{ + color: #0068c4; + font-size: 14px; + font-weight: bold; +} + +.Ldt-LatestAnnotation-NoAnnotation{ + font-size: 14px; + font-weight: bold; +} diff -r 2b17782e7c08 -r fdc8b9631701 src/ldt/ldt/static/ldt/metadataplayer/LatestAnnotation.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ldt/ldt/static/ldt/metadataplayer/LatestAnnotation.js Thu Jun 25 11:02:51 2015 +0200 @@ -0,0 +1,85 @@ +/* Widget that displays the last annotation that was posted, optionally for current segment, optionally for a given username */ + +IriSP.Widgets.LatestAnnotation = function(player, config){ + IriSP.Widgets.Widget.call(this, player, config); +}; + +IriSP.Widgets.LatestAnnotation.prototype = new IriSP.Widgets.Widget(); + +IriSP.Widgets.LatestAnnotation.prototype.defaults = { + from_user: false, + filter_by_segment: false, + segment_annotation_type: "chap", + annotation_type: "contribution" +}; + +IriSP.Widgets.LatestAnnotation.prototype.template = + "
" + + "
"; + +IriSP.Widgets.LatestAnnotation.prototype.annotationTemplate = + "
" + + "
{{{annotation_created}}}
" + + "
{{{annotation_creator}}}{{#annotation_title}}: {{{annotation_title}}}{{/annotation_title}}
" + + "
" + + "{{{annotation_content}}}" + + "
" + + "
" + +IriSP.Widgets.LatestAnnotation.prototype.draw = function(){ + var _this = this; + + this.renderTemplate(); + + this.annotationContainer_$ = this.$.find('.Ldt-LatestAnnotation'); + this.refresh(); + + this.onMediaEvent("timeupdate", "refresh"); +} + +IriSP.Widgets.LatestAnnotation.prototype.refresh = function(){ + var _list = this.getWidgetAnnotations(); + if(this.filter_by_segment){ + _currentTime = this.media.getCurrentTime(); + _segments_annotations = this.source.getAnnotationsByTypeTitle(this.segments_annotation_type); + _current_segments = _segments_annotations.filter(function(_segment){ + return (_currentTime >= _segment.begin && _currentTime <= _segment.end); + }); + if (_current_segments.length == 0) { + _list = _list.filter(function(_annotation){ + return false; + }); + } + else { + _list = _list.filter(function(_annotation){ + _annotation_time = (_annotation.begin+_annotation.end)/2; + return (_current_segments[0].begin <= _annotation_time && _current_segments[0].end >= _annotation_time); + }); + } + _list.sortBy(function(_annotation){ + return _annotation.created; + }); + + var _latestAnnotation = false; + var _html=""; + if (_list.length != 0){ + _latestAnnotation = _list.pop(); + console.log(_latestAnnotation.creator); + _html = Mustache.to_html(this.annotationTemplate, { + annotation_created: _latestAnnotation.created.toLocaleDateString()+", "+_latestAnnotation.created.toLocaleTimeString(), + annotation_creator: _latestAnnotation.creator, + annotation_title: _latestAnnotation.title, + annotation_content: _latestAnnotation.description, + }); + } + else { + _html = "
Aucune annotation à afficher
"; + } + this.annotationContainer_$.html(_html); + + }; +} + +IriSP.Widgets.LatestAnnotation.prototype.getLastAnnotation = function(){ + +} \ No newline at end of file