| author | veltr |
| Wed, 21 Nov 2012 16:33:51 +0100 | |
| changeset 983 | 97fef7a4b189 |
| parent 969 | 353b0881a0b9 |
| child 988 | eefd336335f9 |
| permissions | -rw-r--r-- |
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
1 |
IriSP.Widgets.AnnotationsList = function(player, config) { |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
2 |
IriSP.Widgets.Widget.call(this, player, config); |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
3 |
this.lastIds = []; |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
4 |
var _this = this; |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
5 |
this.throttledRefresh = IriSP._.throttle(function() { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
6 |
_this.refresh(false); |
| 983 | 7 |
}, 800); |
8 |
this.searchString = false; |
|
9 |
this.lastSearch = false; |
|
| 585 | 10 |
}; |
11 |
||
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
12 |
IriSP.Widgets.AnnotationsList.prototype = new IriSP.Widgets.Widget(); |
| 585 | 13 |
|
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
14 |
IriSP.Widgets.AnnotationsList.prototype.defaults = { |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
15 |
/* URL when the annotations are to be reloaded from an LDT-like segment API |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
16 |
* e.g. http://ldt.iri.centrepompidou.fr/ldtplatform/api/ldt/segments/{{media}}/{{begin}}/{{end}}?callback=? |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
17 |
*/ |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
18 |
ajax_url : false, |
| 909 | 19 |
/* number of milliseconds before/after the current timecode when calling the segment API |
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
20 |
*/ |
| 967 | 21 |
ajax_granularity : 600000, |
| 925 | 22 |
default_thumbnail : "", |
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
23 |
/* URL when the annotation is not in the current project, |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
24 |
* e.g. http://ldt.iri.centrepompidou.fr/ldtplatform/ldt/front/player/{{media}}/{{project}}/{{annotationType}}#id={{annotation}} |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
25 |
*/ |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
26 |
foreign_url : "", |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
27 |
annotation_type : false, |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
28 |
refresh_interval : 0, |
| 966 | 29 |
limit_count : 20, |
| 924 | 30 |
newest_first : false, |
| 966 | 31 |
show_audio: true, |
| 924 | 32 |
polemics : [{ |
33 |
keyword: "++", |
|
34 |
background_color: "#c9ecc6" |
|
35 |
},{ |
|
36 |
keyword: "--", |
|
37 |
background_color: "#f9c5c6" |
|
38 |
},{ |
|
39 |
keyword: "??", |
|
40 |
background_color: "#cec5f9" |
|
41 |
},{ |
|
42 |
keyword: "==", |
|
43 |
background_color: "#f9f4c6" |
|
44 |
}] |
|
| 585 | 45 |
}; |
46 |
||
| 966 | 47 |
IriSP.Widgets.AnnotationsList.prototype.messages = { |
48 |
en: { |
|
49 |
voice_annotation: "Voice Annotation", |
|
50 |
now_playing: "Now playing..." |
|
51 |
}, |
|
52 |
fr: { |
|
53 |
voice_annotation: "Annotation Vocale", |
|
54 |
now_playing: "Lecture en cours..." |
|
55 |
} |
|
56 |
} |
|
57 |
||
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
58 |
IriSP.Widgets.AnnotationsList.prototype.template = |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
59 |
'<div class="Ldt-AnnotationsListWidget">' |
| 966 | 60 |
+ '{{#show_audio}}<div class="Ldt-AnnotationsList-Audio"></div>{{/show_audio}}' |
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
61 |
+ '<ul class="Ldt-AnnotationsList-ul">' |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
62 |
+ '</ul>' |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
63 |
+ '</div>'; |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
64 |
|
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
65 |
IriSP.Widgets.AnnotationsList.prototype.annotationTemplate = |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
66 |
'<li class="Ldt-AnnotationsList-li Ldt-TraceMe" trace-info="annotation-id:{{id}}, media-id:{{media_id}}" style="{{specific_style}}">' |
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
67 |
+ '<div class="Ldt-AnnotationsList-ThumbContainer">' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
68 |
+ '<a href="{{url}}">' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
69 |
+ '<img class="Ldt-AnnotationsList-Thumbnail" src="{{thumbnail}}" />' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
70 |
+ '</a>' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
71 |
+ '</div>' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
72 |
+ '<div class="Ldt-AnnotationsList-Duration">{{begin}} - {{end}}</div>' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
73 |
+ '<h3 class="Ldt-AnnotationsList-Title">' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
74 |
+ '<a href="{{url}}">{{title}}</a>' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
75 |
+ '</h3>' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
76 |
+ '<p class="Ldt-AnnotationsList-Description">{{description}}</p>' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
77 |
+ '{{#tags.length}}' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
78 |
+ '<ul class="Ldt-AnnotationsList-Tags">' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
79 |
+ '{{#tags}}' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
80 |
+ '{{#.}}' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
81 |
+ '<li class="Ldt-AnnotationsList-Tag-Li">' |
| 902 | 82 |
+ '<span>{{.}}</span>' |
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
83 |
+ '</li>' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
84 |
+ '{{/.}}' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
85 |
+ '{{/tags}}' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
86 |
+ '</ul>' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
87 |
+ '{{/tags.length}}' |
| 966 | 88 |
+ '{{#audio}}<div class="Ldt-AnnotationsList-Play" data-audio={{audio}}>{{l10n.voice_annotation}}</div>{{/audio}}' |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
89 |
+ '</li>'; |
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
90 |
|
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
91 |
//obj.url = this.project_url + "/" + media + "/" + annotations[i].meta.project + "/" + annotations[i].meta["id-ref"] + '#id=' + annotations[i].id; |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
92 |
|
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
93 |
IriSP.Widgets.AnnotationsList.prototype.ajaxSource = function() { |
| 957 | 94 |
var _currentTime = this.media.getCurrentTime(), |
95 |
_duration = this.media.duration; |
|
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
96 |
this.lastAjaxQuery = _currentTime; |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
97 |
var _url = Mustache.to_html(this.ajax_url, { |
| 916 | 98 |
media : this.source.currentMedia.id, |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
99 |
begin : Math.max(0, _currentTime - this.ajax_granularity), |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
100 |
end : Math.min(_duration.milliseconds, _currentTime + this.ajax_granularity) |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
101 |
}); |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
102 |
this.currentSource = this.player.loadMetadata(IriSP._.defaults({ |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
103 |
"url" : _url |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
104 |
}, this.metadata)); |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
105 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
106 |
|
| 903 | 107 |
IriSP.Widgets.AnnotationsList.prototype.ajaxMashup = function() { |
| 957 | 108 |
var _currentTime = this.media.getCurrentTime(); |
109 |
var _currentAnnotation = this.source.currentMedia.getAnnotationAtTime(_currentTime); |
|
| 916 | 110 |
if (typeof _currentAnnotation !== "undefined" && _currentAnnotation.id !== this.lastMashupAnnotation) { |
111 |
this.lastMashupAnnotation = _currentAnnotation.id; |
|
| 903 | 112 |
var _currentMedia = _currentAnnotation.getMedia(), |
113 |
_url = Mustache.to_html(this.ajax_url, { |
|
| 916 | 114 |
media : _currentMedia.id, |
| 903 | 115 |
begin : Math.max(0, _currentAnnotation.annotation.begin.milliseconds - this.ajax_granularity), |
116 |
end : Math.min(_currentMedia.duration.milliseconds, _currentAnnotation.annotation.end.milliseconds + this.ajax_granularity) |
|
117 |
}); |
|
118 |
this.currentSource = this.player.loadMetadata(IriSP._.defaults({ |
|
119 |
"url" : _url |
|
120 |
}, this.metadata)); |
|
121 |
} |
|
122 |
} |
|
123 |
||
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
124 |
IriSP.Widgets.AnnotationsList.prototype.refresh = function(_forceRedraw) { |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
125 |
_forceRedraw = (typeof _forceRedraw !== "undefined" && _forceRedraw); |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
126 |
if (this.currentSource.status !== IriSP.Model._SOURCE_STATUS_READY) { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
127 |
return 0; |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
128 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
129 |
var _this = this, |
| 957 | 130 |
_currentTime = this.media.getCurrentTime(); |
| 903 | 131 |
var _list = this.annotation_type ? this.currentSource.getAnnotationsByTypeTitle(this.annotation_type) : this.currentSource.getAnnotations(); |
132 |
if (this.mashupMode) { |
|
| 957 | 133 |
var _currentAnnotation = this.source.currentMedia.getAnnotationAtTime(_currentTime); |
| 903 | 134 |
if (typeof _currentAnnotation !== "undefined") { |
| 965 | 135 |
_currentTime = _currentTime - _currentAnnotation.begin + _currentAnnotation.annotation.begin; |
| 916 | 136 |
var _mediaId = _currentAnnotation.getMedia().id; |
| 903 | 137 |
_list = _list.filter(function(_annotation) { |
| 916 | 138 |
return _annotation.getMedia().id === _mediaId; |
| 903 | 139 |
}); |
140 |
} |
|
141 |
} |
|
| 983 | 142 |
_list = _list.filter(function(_annotation) { |
143 |
return _annotation.found !== false; |
|
144 |
}); |
|
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
145 |
if (this.limit_count) { |
| 965 | 146 |
/* Get the n annotations closest to current timecode */ |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
147 |
_list = _list.sortBy(function(_annotation) { |
| 965 | 148 |
return Math.abs((_annotation.begin + _annotation.end) / 2 - _currentTime); |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
149 |
}).slice(0, this.limit_count) |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
150 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
151 |
if (this.newest_first) { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
152 |
_list = _list.sortBy(function(_annotation) { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
153 |
return -_annotation.created.valueOf(); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
154 |
}); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
155 |
} else { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
156 |
_list = _list.sortBy(function(_annotation) { |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
157 |
return _annotation.begin; |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
158 |
}); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
159 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
160 |
|
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
161 |
var _ids = _list.idIndex; |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
162 |
|
| 983 | 163 |
if (_forceRedraw || !IriSP._.isEqual(_ids, this.lastIds) || this.searchString !== this.lastSearch) { |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
164 |
/* This part only gets executed if the list needs updating */ |
| 983 | 165 |
this.lastSearch = this.searchString; |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
166 |
this.lastIds = _ids; |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
167 |
this.list_$.html(""); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
168 |
_list.forEach(function(_annotation) { |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
169 |
var _url = ( |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
170 |
( typeof _annotation.url !== "undefined" && _annotation.url) |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
171 |
? _annotation.url |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
172 |
: ( |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
173 |
( typeof _this.source.projectId !== "undefined" && typeof _annotation.project !== "undefined" && _annotation.project && _this.source.projectId !== _annotation.project ) |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
174 |
? Mustache.to_html( |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
175 |
_this.foreign_url, |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
176 |
{ |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
177 |
project : _annotation.project, |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
178 |
media : _annotation.media.id, |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
179 |
annotation : _annotation.id, |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
180 |
annotationType : _annotation.annotationType.id |
| 924 | 181 |
} |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
182 |
) |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
183 |
: '#id=' + _annotation.id |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
184 |
) |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
185 |
); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
186 |
var _title = (_annotation.title || "").replace(_annotation.description,''), |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
187 |
_description = _annotation.description; |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
188 |
if (!_annotation.title) { |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
189 |
_title = _annotation.creator; |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
190 |
} |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
191 |
if (!_annotation.description && _annotation.creator) { |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
192 |
_description = _annotation.title; |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
193 |
_title = _annotation.creator; |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
194 |
} |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
195 |
var _bgcolor; |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
196 |
IriSP._(_this.polemics).each(function(_polemic) { |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
197 |
var _rgxp = IriSP.Model.regexpFromTextOrArray(_polemic.keyword, true); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
198 |
if (_rgxp.test(_title + " " + _description)) { |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
199 |
_bgcolor = _polemic.background_color; |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
200 |
} |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
201 |
}); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
202 |
var _data = { |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
203 |
id : _annotation.id, |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
204 |
media_id : _annotation.getMedia().id, |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
205 |
title : _title, |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
206 |
description : _description, |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
207 |
begin : _annotation.begin.toString(), |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
208 |
end : _annotation.end.toString(), |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
209 |
thumbnail : typeof _annotation.thumbnail !== "undefined" && _annotation.thumbnail ? _annotation.thumbnail : _this.default_thumbnail, |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
210 |
url : _url, |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
211 |
tags : _annotation.getTagTexts(), |
| 966 | 212 |
specific_style : (typeof _bgcolor !== "undefined" ? "background-color: " + _bgcolor : ""), |
| 967 | 213 |
audio : (_this.show_audio && _annotation.audio && _annotation.audio.href && _annotation.audio.href != "null" ? _annotation.audio.href : undefined), |
| 966 | 214 |
l10n: _this.l10n |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
215 |
}; |
|
969
353b0881a0b9
Added On-the-fly (file-less) metadata generation test
veltr
parents:
967
diff
changeset
|
216 |
var _html = Mustache.to_html(_this.annotationTemplate, _data), |
|
353b0881a0b9
Added On-the-fly (file-less) metadata generation test
veltr
parents:
967
diff
changeset
|
217 |
_el = IriSP.jQuery(_html), |
|
353b0881a0b9
Added On-the-fly (file-less) metadata generation test
veltr
parents:
967
diff
changeset
|
218 |
_onselect = function() { |
|
353b0881a0b9
Added On-the-fly (file-less) metadata generation test
veltr
parents:
967
diff
changeset
|
219 |
_this.annotations_$.removeClass("selected"); |
|
353b0881a0b9
Added On-the-fly (file-less) metadata generation test
veltr
parents:
967
diff
changeset
|
220 |
_el.addClass("selected"); |
|
353b0881a0b9
Added On-the-fly (file-less) metadata generation test
veltr
parents:
967
diff
changeset
|
221 |
}, |
|
353b0881a0b9
Added On-the-fly (file-less) metadata generation test
veltr
parents:
967
diff
changeset
|
222 |
_onunselect = function() { |
|
353b0881a0b9
Added On-the-fly (file-less) metadata generation test
veltr
parents:
967
diff
changeset
|
223 |
_this.annotations_$.removeClass("selected"); |
|
353b0881a0b9
Added On-the-fly (file-less) metadata generation test
veltr
parents:
967
diff
changeset
|
224 |
}; |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
225 |
_el.mouseover(function() { |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
226 |
_annotation.trigger("select"); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
227 |
}) |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
228 |
.mouseout(function() { |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
229 |
_annotation.trigger("unselect"); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
230 |
}) |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
231 |
.appendTo(_this.list_$); |
|
969
353b0881a0b9
Added On-the-fly (file-less) metadata generation test
veltr
parents:
967
diff
changeset
|
232 |
_el.on("remove", function() { |
|
353b0881a0b9
Added On-the-fly (file-less) metadata generation test
veltr
parents:
967
diff
changeset
|
233 |
_annotation.off("select", _onselect); |
|
353b0881a0b9
Added On-the-fly (file-less) metadata generation test
veltr
parents:
967
diff
changeset
|
234 |
_annotation.off("unselect", _onunselect); |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
235 |
}); |
|
969
353b0881a0b9
Added On-the-fly (file-less) metadata generation test
veltr
parents:
967
diff
changeset
|
236 |
_annotation.on("select", _onselect); |
|
353b0881a0b9
Added On-the-fly (file-less) metadata generation test
veltr
parents:
967
diff
changeset
|
237 |
_annotation.on("unselect", _onunselect); |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
238 |
}); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
239 |
|
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
240 |
this.annotations_$ = this.$.find('.Ldt-AnnotationsList-li'); |
| 903 | 241 |
|
242 |
/* Correct the empty tag bug */ |
|
243 |
this.$.find('.Ldt-AnnotationsList-Tag-Li').each(function() { |
|
244 |
var _el = IriSP.jQuery(this); |
|
245 |
if (!_el.text().replace(/(^\s+|\s+$)/g,'')) { |
|
|
969
353b0881a0b9
Added On-the-fly (file-less) metadata generation test
veltr
parents:
967
diff
changeset
|
246 |
_el.remove(); |
| 903 | 247 |
} |
248 |
}); |
|
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
249 |
|
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
250 |
this.$.find('.Ldt-AnnotationsList-Tag-Li').click(function() { |
| 983 | 251 |
_this.source.getAnnotations().search(IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,'')); |
| 966 | 252 |
}); |
253 |
|
|
254 |
this.$.find(".Ldt-AnnotationsList-Play").click(function() { |
|
255 |
var _el = IriSP.jQuery(this), |
|
256 |
_audiofile = _el.attr("data-audio").replace(_this.rtmp_streamer,""); |
|
257 |
_el.text(_this.l10n.now_playing); |
|
258 |
_this.jwplayer.load({ |
|
259 |
file: _audiofile, |
|
260 |
streamer: _this.rtmp_streamer |
|
261 |
}); |
|
262 |
_this.jwplayer.play(true); |
|
263 |
_this.media.pause(); |
|
264 |
_this.jw_paused_media = true; |
|
265 |
}); |
|
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
266 |
|
| 983 | 267 |
if (this.source.getAnnotations().searching) { |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
268 |
this.$.find(".Ldt-AnnotationsList-Title a, .Ldt-AnnotationsList-Description").each(function() { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
269 |
var _$ = IriSP.jQuery(this); |
| 983 | 270 |
_$.html(_$.text().replace(/(^\s+|\s+$)/g,'').replace(_this.source.getAnnotations().regexp, '<span class="Ldt-AnnotationsList-highlight">$1</span>')) |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
271 |
}) |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
272 |
} |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
273 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
274 |
|
| 903 | 275 |
if (this.ajax_url) { |
276 |
if (this.mashupMode) { |
|
277 |
this.ajaxMashup(); |
|
278 |
} else { |
|
| 963 | 279 |
if (Math.abs(_currentTime - this.lastAjaxQuery) > (this.ajax_granularity)) { |
| 903 | 280 |
this.ajaxSource(); |
281 |
} |
|
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
282 |
} |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
283 |
} |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
284 |
return _list.length; |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
285 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
286 |
|
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
287 |
IriSP.Widgets.AnnotationsList.prototype.draw = function() { |
| 876 | 288 |
|
| 959 | 289 |
this.mashupMode = (this.media.elementType === "mashup"); |
290 |
|
|
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
291 |
this.renderTemplate(); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
292 |
|
| 966 | 293 |
var _this = this; |
294 |
|
|
295 |
if (this.show_audio) { |
|
296 |
var _tmpId = "jwplayer-" + IriSP.Model.getUID(); |
|
297 |
this.$.find(".Ldt-AnnotationsList-Audio").attr("id", _tmpId); |
|
298 |
this.jwplayer = jwplayer(_tmpId); |
|
299 |
this.jwplayer.setup({ |
|
300 |
flashplayer: IriSP.getLib("jwPlayerSWF"), |
|
301 |
width: 1, |
|
302 |
height: 1, |
|
303 |
provider: "rtmp", |
|
304 |
events: { |
|
305 |
onIdle: function() { |
|
306 |
if (_this.jw_paused_media) { |
|
307 |
_this.jw_paused_media = false; |
|
308 |
_this.media.play(); |
|
309 |
} |
|
310 |
_this.$.find(".Ldt-AnnotationsList-Play").text(_this.l10n.voice_annotation) |
|
311 |
} |
|
312 |
} |
|
313 |
}); |
|
314 |
this.jw_paused_media = false; |
|
315 |
} |
|
316 |
|
|
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
317 |
this.list_$ = this.$.find(".Ldt-AnnotationsList-ul"); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
318 |
|
| 966 | 319 |
|
| 983 | 320 |
this.source.getAnnotations().on("search", function(_text) { |
321 |
_this.searchString = _text; |
|
322 |
if (_this.source !== _this.currentSource) { |
|
323 |
_this.currentSource.getAnnotations().search(_text); |
|
324 |
_this.throttledRefresh(); |
|
325 |
} |
|
326 |
}); |
|
327 |
this.source.getAnnotations().on("found", function() { |
|
328 |
_this.throttledRefresh(); |
|
329 |
}); |
|
330 |
this.source.getAnnotations().on("not-found", function() { |
|
331 |
_this.throttledRefresh(); |
|
332 |
}); |
|
333 |
this.source.getAnnotations().on("clear-search", function() { |
|
334 |
_this.searchString = false; |
|
335 |
if (_this.source !== _this.currentSource) { |
|
336 |
_this.currentSource.getAnnotations().trigger("clear-search"); |
|
337 |
} |
|
338 |
}); |
|
339 |
this.source.getAnnotations().on("search-cleared", function() { |
|
340 |
_this.throttledRefresh(); |
|
341 |
}); |
|
342 |
|
|
| 966 | 343 |
this.onMdpEvent("AnnotationsList.refresh", function() { |
344 |
if (_this.ajax_url) { |
|
345 |
if (_this.mashupMode) { |
|
346 |
_this.ajaxMashup(); |
|
347 |
} else { |
|
348 |
_this.ajaxSource(); |
|
349 |
} |
|
350 |
} |
|
351 |
_this.throttledRefresh(); |
|
352 |
}); |
|
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
353 |
|
| 903 | 354 |
if (this.ajax_url) { |
355 |
if (this.mashupMode) { |
|
356 |
this.ajaxMashup(); |
|
357 |
} else { |
|
358 |
this.ajaxSource(); |
|
359 |
} |
|
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
360 |
} else { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
361 |
this.currentSource = this.source; |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
362 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
363 |
|
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
364 |
if (this.refresh_interval) { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
365 |
window.setInterval(function() { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
366 |
_this.currentSource.get() |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
367 |
}, this.refresh_interval); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
368 |
} |
| 674 | 369 |
|
| 957 | 370 |
this.onMdpEvent("createAnnotationWidget.addedAnnotation"); |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
371 |
var _events = [ |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
372 |
"timeupdate", |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
373 |
"seeked", |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
374 |
"loadedmetadata" |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
375 |
]; |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
376 |
for (var _i = 0; _i < _events.length; _i++) { |
| 957 | 377 |
this.onMediaEvent(_events[_i], this.throttledRefresh); |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
378 |
} |
|
730
357fc047503b
redraw the widget after that an annotation has been added.
hamidouk
parents:
729
diff
changeset
|
379 |
|
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
380 |
this.throttledRefresh(); |
| 698 | 381 |
|
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
382 |
}; |