# HG changeset patch # User veltr # Date 1337089819 -7200 # Node ID d9da52e20f7f3f31c7170d4e13fd85b7d929210f # Parent 14022f1d49ab9f1f3b61394cba312af8acb9a1a7 AnnotationsList now updated to work with mashups diff -r 14022f1d49ab -r d9da52e20f7f src/css/LdtPlayer-core.css --- a/src/css/LdtPlayer-core.css Mon May 14 16:59:07 2012 +0200 +++ b/src/css/LdtPlayer-core.css Tue May 15 15:50:19 2012 +0200 @@ -9,7 +9,7 @@ } .Ldt-Widget { - font-family: Arial, Helvetica, sans-serif; +/* font-family: Arial, Helvetica, sans-serif; */ color: black; font-size: 12px; } diff -r 14022f1d49ab -r d9da52e20f7f src/js/model.js --- a/src/js/model.js Mon May 14 16:59:07 2012 +0200 +++ b/src/js/model.js Tue May 15 15:50:19 2012 +0200 @@ -573,6 +573,26 @@ } } +IriSP.Model.Mashup.prototype.getAnnotationAtTime = function(_time) { + var _list = this.segments.filter(function(_annotation) { + return _annotation.begin <= _time && _annotation.end > _time; + }); + if (_list.length) { + return _list[0]; + } else { + return undefined; + } +} + +IriSP.Model.Mashup.prototype.getMediaAtTime = function(_time) { + var _annotation = this.getAnnotationAtTime(_time); + if (typeof _annotation !== "undefined") { + return _annotation.getMedia(); + } else { + return undefined; + } +} + /* */ IriSP.Model.Source = function(_config) { diff -r 14022f1d49ab -r d9da52e20f7f src/widgets/AnnotationsList.css --- a/src/widgets/AnnotationsList.css Mon May 14 16:59:07 2012 +0200 +++ b/src/widgets/AnnotationsList.css Tue May 15 15:50:19 2012 +0200 @@ -1,7 +1,7 @@ /* AnnotationsListWidget */ .Ldt-AnnotationsListWidget { - border: 1px solid #b6b8b8; + border: none; margin: 0; padding: 0; overflow: auto; max-height: 480px; } diff -r 14022f1d49ab -r d9da52e20f7f src/widgets/AnnotationsList.js --- a/src/widgets/AnnotationsList.js Mon May 14 16:59:07 2012 +0200 +++ b/src/widgets/AnnotationsList.js Tue May 15 15:50:19 2012 +0200 @@ -6,6 +6,7 @@ this.throttledRefresh = IriSP._.throttle(function() { _this.refresh(false); }, 1500); + this.mashupMode = (this.source.currentMedia.elementType === "mashup"); }; IriSP.Widgets.AnnotationsList.prototype = new IriSP.Widgets.Widget(); @@ -92,6 +93,27 @@ }, this.metadata)); } +IriSP.Widgets.AnnotationsList.prototype.ajaxMashup = function() { + var _currentTime = this.player.popcorn.currentTime(); + if (typeof _currentTime == "undefined") { + _currentTime = 0; + } + var _currentAnnotation = this.source.currentMedia.getAnnotationAtTime(_currentTime * 1000); + if (typeof _currentAnnotation !== "undefined" && _currentAnnotation.namespacedId.name !== this.lastMashupAnnotation) { + this.lastMashupAnnotation = _currentAnnotation.namespacedId.name; + var _currentMedia = _currentAnnotation.getMedia(), + _url = Mustache.to_html(this.ajax_url, { + media : _currentMedia.namespacedId.name, + begin : Math.max(0, _currentAnnotation.annotation.begin.milliseconds - this.ajax_granularity), + end : Math.min(_currentMedia.duration.milliseconds, _currentAnnotation.annotation.end.milliseconds + this.ajax_granularity) + }); + console.log("Getting", _url); + this.currentSource = this.player.loadMetadata(IriSP._.defaults({ + "url" : _url + }, this.metadata)); + } +} + IriSP.Widgets.AnnotationsList.prototype.refresh = function(_forceRedraw) { _forceRedraw = (typeof _forceRedraw !== "undefined" && _forceRedraw); if (this.currentSource.status !== IriSP.Model._SOURCE_STATUS_READY) { @@ -102,7 +124,17 @@ if (typeof _currentTime == "undefined") { _currentTime = 0; } - var _list = this.annotation_type ? this.currentSource.getAnnotationsByTypeTitle(this.annotation_type, true) : this.currentSource.getAnnotations(); + var _list = this.annotation_type ? this.currentSource.getAnnotationsByTypeTitle(this.annotation_type) : this.currentSource.getAnnotations(); + if (this.mashupMode) { + var _currentAnnotation = this.source.currentMedia.getAnnotationAtTime(_currentTime * 1000); + if (typeof _currentAnnotation !== "undefined") { + _currentTime = _currentTime - _currentAnnotation.begin.getSeconds() + _currentAnnotation.annotation.begin.getSeconds(); + var _mediaId = _currentAnnotation.getMedia().namespacedId.name; + _list = _list.filter(function(_annotation) { + return _annotation.getMedia().namespacedId.name === _mediaId; + }); + } + } if (this.searchString) { _list = _list.searchByTextFields(this.searchString); } @@ -163,6 +195,14 @@ }); this.$.html(_html); + + /* Correct the empty tag bug */ + this.$.find('.Ldt-AnnotationsList-Tag-Li').each(function() { + var _el = IriSP.jQuery(this); + if (!_el.text().replace(/(^\s+|\s+$)/g,'')) { + _el.detach(); + } + }); this.$.find('.Ldt-AnnotationsList-Tag-Li').click(function() { _this.player.popcorn.trigger("IriSP.search.triggeredSearch", IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,'')); @@ -177,9 +217,13 @@ } } - if (this.ajax_url && this.ajax_granularity) { - if (Math.abs(_currentTime - this.lastAjaxQuery) > (this.ajax_granularity / 2000)) { - this.ajaxSource(); + if (this.ajax_url) { + if (this.mashupMode) { + this.ajaxMashup(); + } else { + if (Math.abs(_currentTime - this.lastAjaxQuery) > (this.ajax_granularity / 2000)) { + this.ajaxSource(); + } } } return _list.length; @@ -193,8 +237,12 @@ var _this = this; - if (this.ajax_url && this.ajax_granularity) { - this.ajaxSource(); + if (this.ajax_url) { + if (this.mashupMode) { + this.ajaxMashup(); + } else { + this.ajaxSource(); + } } else { this.currentSource = this.source; } diff -r 14022f1d49ab -r d9da52e20f7f src/widgets/MediaList.js --- a/src/widgets/MediaList.js Mon May 14 16:59:07 2012 +0200 +++ b/src/widgets/MediaList.js Tue May 15 15:50:19 2012 +0200 @@ -30,8 +30,8 @@ + '
' + '