13 IriSP.Widgets.AnnotationsController.prototype.defaults = { |
13 IriSP.Widgets.AnnotationsController.prototype.defaults = { |
14 // If true, displaying AnnotationList will hide CreateAnnotation and vice versa. |
14 // If true, displaying AnnotationList will hide CreateAnnotation and vice versa. |
15 display_or_write: false, |
15 display_or_write: false, |
16 starts_hidden: false, |
16 starts_hidden: false, |
17 hide_without_segment: false, |
17 hide_without_segment: false, |
18 segments_annotation_type: "chap" |
18 segments_annotation_type: "chap", |
19 }; |
19 }; |
20 |
20 |
21 IriSP.Widgets.AnnotationsController.prototype.template = |
21 IriSP.Widgets.AnnotationsController.prototype.template = |
22 "<div class='Ldt-AnnotationsController'>" |
22 "<div class='Ldt-AnnotationsController'>" |
23 + "<div class='Ldt-AnnotationsController-ButtonsContainer'>" |
23 + "<div class='Ldt-AnnotationsController-ButtonsContainer'>" |
55 _this.player.trigger("AnnotationsList.toggle"); |
55 _this.player.trigger("AnnotationsList.toggle"); |
56 if (_this.display_or_write){ |
56 if (_this.display_or_write){ |
57 _this.player.trigger("CreateAnnotation.hide"); |
57 _this.player.trigger("CreateAnnotation.hide"); |
58 } |
58 } |
59 }) |
59 }) |
60 this.onMediaEvent("timeupdate", "onTimeUpdate") |
60 |
|
61 if(this.hide_without_segment){ |
|
62 this.onMediaEvent("timeupdate", function(){ |
|
63 _this.refresh(); |
|
64 }) |
|
65 this.onMediaEvent("settimerange", function(_timeRange){ |
|
66 _this.refresh(_timeRange); |
|
67 }) |
|
68 this.segments = this.source.getAnnotationsByTypeTitle(this.segments_annotation_type) |
|
69 this.currentSegment = false |
|
70 } |
61 |
71 |
62 if (this.starts_hidden) { |
72 if (this.starts_hidden) { |
63 this.visible = true |
73 this.visible = true |
64 this.hide(); |
74 this.hide(); |
65 } |
75 } |
68 this.show(); |
78 this.show(); |
69 } |
79 } |
70 |
80 |
71 }; |
81 }; |
72 |
82 |
73 IriSP.Widgets.AnnotationsController.prototype.onTimeUpdate = function(){ |
83 IriSP.Widgets.AnnotationsController.prototype.refresh = function(_timeRange){ |
|
84 _timeRange = typeof _timeRange !== 'undefined' ? _timeRange : false ; |
|
85 |
|
86 if(!_timeRange){ |
|
87 if (this.media.getTimeRange()){ |
|
88 _timeRange = this.media.getTimeRange(); |
|
89 } |
|
90 } |
|
91 |
74 if (this.hide_without_segment){ |
92 if (this.hide_without_segment){ |
75 _currentTime = this.media.getCurrentTime() |
93 if (!_timeRange && !this.media.getTimeRange()){ |
76 _segmentsAnnotations = this.source.getAnnotationsByTypeTitle(this.segments_annotation_type) |
94 _currentTime = this.media.getCurrentTime() |
77 _currentSegments = _segmentsAnnotations.filter(function(_segment){ |
95 _currentSegments = this.segments.filter(function(_segment){ |
78 return (_currentTime >= _segment.begin && _currentTime <= _segment.end) |
96 return (_currentTime >= _segment.begin && _currentTime <= _segment.end) |
79 }); |
97 }); |
80 if (_currentSegments.length == 0){ |
98 if(_currentSegments.length > 0){ |
|
99 currentSegment = true; |
|
100 } |
|
101 else { |
|
102 currentSegment = false; |
|
103 } |
|
104 } |
|
105 else { |
|
106 var _timeRangeBegin = _timeRange[0], |
|
107 _timeRangeEnd = _timeRange[1]; |
|
108 _currentSegments = this.segments.filter(function(_segment){ |
|
109 return (_timeRangeBegin == _segment.begin && _timeRangeEnd == _segment.end) |
|
110 }); |
|
111 if(_currentSegments.length > 0){ |
|
112 currentSegment = true; |
|
113 } |
|
114 else { |
|
115 currentSegment = false; |
|
116 } |
|
117 } |
|
118 if (!currentSegment && _currentSegments.length == 0){ |
81 if (this.visible){ |
119 if (this.visible){ |
82 this.hide(); |
120 this.hide(); |
83 _this.player.trigger("CreateAnnotation.hide"); |
121 this.player.trigger("CreateAnnotation.hide"); |
84 _this.player.trigger("AnnotationsList.hide"); |
122 this.player.trigger("AnnotationsList.hide"); |
85 } |
123 } |
86 } |
124 } |
87 else { |
125 else { |
88 if (!this.visible){ |
126 if (!this.visible){ |
89 this.show(); |
127 this.show(); |
90 _this.player.trigger("CreateAnnotation.hide"); |
128 this.player.trigger("CreateAnnotation.hide"); |
91 _this.player.trigger("AnnotationsList.hide"); |
129 this.player.trigger("AnnotationsList.hide"); |
92 } |
130 } |
93 } |
131 } |
94 } |
132 } |
95 } |
133 } |
96 |
134 |