--- a/src/widgets/AnnotationsController.js Tue Sep 01 15:24:26 2015 +0200
+++ b/src/widgets/AnnotationsController.js Tue Sep 01 15:31:46 2015 +0200
@@ -15,7 +15,7 @@
display_or_write: false,
starts_hidden: false,
hide_without_segment: false,
- segments_annotation_type: "chap"
+ segments_annotation_type: "chap",
};
IriSP.Widgets.AnnotationsController.prototype.template =
@@ -57,7 +57,17 @@
_this.player.trigger("CreateAnnotation.hide");
}
})
- this.onMediaEvent("timeupdate", "onTimeUpdate")
+
+ if(this.hide_without_segment){
+ this.onMediaEvent("timeupdate", function(){
+ _this.refresh();
+ })
+ this.onMediaEvent("settimerange", function(_timeRange){
+ _this.refresh(_timeRange);
+ })
+ this.segments = this.source.getAnnotationsByTypeTitle(this.segments_annotation_type)
+ this.currentSegment = false
+ }
if (this.starts_hidden) {
this.visible = true
@@ -70,25 +80,53 @@
};
-IriSP.Widgets.AnnotationsController.prototype.onTimeUpdate = function(){
+IriSP.Widgets.AnnotationsController.prototype.refresh = function(_timeRange){
+ _timeRange = typeof _timeRange !== 'undefined' ? _timeRange : false ;
+
+ if(!_timeRange){
+ if (this.media.getTimeRange()){
+ _timeRange = this.media.getTimeRange();
+ }
+ }
+
if (this.hide_without_segment){
- _currentTime = this.media.getCurrentTime()
- _segmentsAnnotations = this.source.getAnnotationsByTypeTitle(this.segments_annotation_type)
- _currentSegments = _segmentsAnnotations.filter(function(_segment){
- return (_currentTime >= _segment.begin && _currentTime <= _segment.end)
- });
- if (_currentSegments.length == 0){
+ if (!_timeRange && !this.media.getTimeRange()){
+ _currentTime = this.media.getCurrentTime()
+ _currentSegments = this.segments.filter(function(_segment){
+ return (_currentTime >= _segment.begin && _currentTime <= _segment.end)
+ });
+ if(_currentSegments.length > 0){
+ currentSegment = true;
+ }
+ else {
+ currentSegment = false;
+ }
+ }
+ else {
+ var _timeRangeBegin = _timeRange[0],
+ _timeRangeEnd = _timeRange[1];
+ _currentSegments = this.segments.filter(function(_segment){
+ return (_timeRangeBegin == _segment.begin && _timeRangeEnd == _segment.end)
+ });
+ if(_currentSegments.length > 0){
+ currentSegment = true;
+ }
+ else {
+ currentSegment = false;
+ }
+ }
+ if (!currentSegment && _currentSegments.length == 0){
if (this.visible){
this.hide();
- _this.player.trigger("CreateAnnotation.hide");
- _this.player.trigger("AnnotationsList.hide");
+ this.player.trigger("CreateAnnotation.hide");
+ this.player.trigger("AnnotationsList.hide");
}
}
else {
if (!this.visible){
this.show();
- _this.player.trigger("CreateAnnotation.hide");
- _this.player.trigger("AnnotationsList.hide");
+ this.player.trigger("CreateAnnotation.hide");
+ this.player.trigger("AnnotationsList.hide");
}
}
}