| author | veltr |
| Tue, 01 Oct 2013 15:41:46 +0200 | |
| changeset 1013 | 392ddcd212d7 |
| parent 1011 | 7396abb7e251 |
| child 1021 | 7253d4d06f0d |
| 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 |
} |
|
| 1013 | 56 |
}; |
| 966 | 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">' |
| 993 | 68 |
+ '<a href="{{url}}" draggable="true">' |
|
875
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>' |
| 993 | 73 |
+ '<h3 class="Ldt-AnnotationsList-Title" draggable="true">' |
74 |
+ '<a href="{{url}}">{{{htitle}}}</a>' |
|
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
75 |
+ '</h3>' |
| 993 | 76 |
+ '<p class="Ldt-AnnotationsList-Description">{{{hdescription}}}</p>' |
|
875
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}}' |
| 1010 | 88 |
+ '{{#audio}}<div class="Ldt-AnnotationsList-Play" data-annotation-id="{{id}}">{{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)); |
| 1013 | 105 |
}; |
|
870
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 |
} |
|
| 1013 | 122 |
}; |
| 903 | 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); |
| 1013 | 149 |
}).slice(0, this.limit_count); |
|
870
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 |
) |
| 993 | 183 |
: document.location.href.replace(/#.*$/,'') + '#id=' + _annotation.id |
|
937
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,''), |
| 993 | 187 |
_description = _annotation.description, |
188 |
_thumbnail = (typeof _annotation.thumbnail !== "undefined" && _annotation.thumbnail ? _annotation.thumbnail : _this.default_thumbnail); |
|
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
189 |
if (!_annotation.title) { |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
190 |
_title = _annotation.creator; |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
191 |
} |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
192 |
if (!_annotation.description && _annotation.creator) { |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
193 |
_description = _annotation.title; |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
194 |
_title = _annotation.creator; |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
195 |
} |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
196 |
var _bgcolor; |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
197 |
IriSP._(_this.polemics).each(function(_polemic) { |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
198 |
var _rgxp = IriSP.Model.regexpFromTextOrArray(_polemic.keyword, true); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
199 |
if (_rgxp.test(_title + " " + _description)) { |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
200 |
_bgcolor = _polemic.background_color; |
|
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 |
}); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
203 |
var _data = { |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
204 |
id : _annotation.id, |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
205 |
media_id : _annotation.getMedia().id, |
| 993 | 206 |
htitle : IriSP.textFieldHtml(_title), |
207 |
hdescription : IriSP.textFieldHtml(_description), |
|
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
208 |
begin : _annotation.begin.toString(), |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
209 |
end : _annotation.end.toString(), |
| 993 | 210 |
thumbnail : _thumbnail, |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
211 |
url : _url, |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
212 |
tags : _annotation.getTagTexts(), |
| 966 | 213 |
specific_style : (typeof _bgcolor !== "undefined" ? "background-color: " + _bgcolor : ""), |
214 |
l10n: _this.l10n |
|
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
215 |
}; |
| 1010 | 216 |
if (_this.show_audio && _annotation.audio && _annotation.audio.href && _annotation.audio.href != "null") { |
217 |
_data.audio = true; |
|
218 |
if (!_this.jwplayers[_annotation.id]) { |
|
219 |
var _audiofile = _annotation.audio.href; |
|
220 |
if (_this.audio_url_transform) { |
|
221 |
_audiofile = _this.audio_url_transform(_annotation.audio.href); |
|
222 |
} |
|
223 |
var _tmpId = "jwplayer-" + IriSP.Model.getUID(); |
|
224 |
_this.jwplayers[_annotation.id] = _tmpId; |
|
| 1011 | 225 |
_this.$.find(".Ldt-AnnotationsList-Audio").append(IriSP.jQuery("<div>").attr("id", _tmpId)); |
| 1010 | 226 |
jwplayer(_tmpId).setup({ |
227 |
flashplayer: IriSP.getLib("jwPlayerSWF"), |
|
228 |
file: _audiofile, |
|
229 |
fallback: false, |
|
230 |
primary: "flash", |
|
231 |
controls: false, |
|
232 |
width: 1, |
|
233 |
height: 1, |
|
234 |
events: { |
|
235 |
onPause: function() { |
|
| 1013 | 236 |
_this.$.find(".Ldt-AnnotationsList-Play[data-annotation-id=" + _annotation.id + "]").text(_this.l10n.voice_annotation); |
| 1010 | 237 |
}, |
238 |
onPlay: function() { |
|
| 1013 | 239 |
_this.$.find(".Ldt-AnnotationsList-Play[data-annotation-id=" + _annotation.id + "]").text(_this.l10n.now_playing); |
| 1011 | 240 |
} |
| 1010 | 241 |
} |
242 |
}); |
|
243 |
} |
|
244 |
} |
|
|
969
353b0881a0b9
Added On-the-fly (file-less) metadata generation test
veltr
parents:
967
diff
changeset
|
245 |
var _html = Mustache.to_html(_this.annotationTemplate, _data), |
|
353b0881a0b9
Added On-the-fly (file-less) metadata generation test
veltr
parents:
967
diff
changeset
|
246 |
_el = IriSP.jQuery(_html), |
|
353b0881a0b9
Added On-the-fly (file-less) metadata generation test
veltr
parents:
967
diff
changeset
|
247 |
_onselect = function() { |
| 1011 | 248 |
_this.$.find('.Ldt-AnnotationsList-li').removeClass("selected"); |
|
969
353b0881a0b9
Added On-the-fly (file-less) metadata generation test
veltr
parents:
967
diff
changeset
|
249 |
_el.addClass("selected"); |
|
353b0881a0b9
Added On-the-fly (file-less) metadata generation test
veltr
parents:
967
diff
changeset
|
250 |
}, |
|
353b0881a0b9
Added On-the-fly (file-less) metadata generation test
veltr
parents:
967
diff
changeset
|
251 |
_onunselect = function() { |
| 1011 | 252 |
_this.$.find('.Ldt-AnnotationsList-li').removeClass("selected"); |
|
969
353b0881a0b9
Added On-the-fly (file-less) metadata generation test
veltr
parents:
967
diff
changeset
|
253 |
}; |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
254 |
_el.mouseover(function() { |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
255 |
_annotation.trigger("select"); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
256 |
}) |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
257 |
.mouseout(function() { |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
258 |
_annotation.trigger("unselect"); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
259 |
}) |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
260 |
.appendTo(_this.list_$); |
|
996
c472984db275
refactored drag-and-drop interface (IE Compatibility)
veltr
parents:
994
diff
changeset
|
261 |
IriSP.attachDndData(_el.find("[draggable]"), { |
|
c472984db275
refactored drag-and-drop interface (IE Compatibility)
veltr
parents:
994
diff
changeset
|
262 |
title: _title, |
|
c472984db275
refactored drag-and-drop interface (IE Compatibility)
veltr
parents:
994
diff
changeset
|
263 |
description: _description, |
|
c472984db275
refactored drag-and-drop interface (IE Compatibility)
veltr
parents:
994
diff
changeset
|
264 |
uri: _url, |
|
c472984db275
refactored drag-and-drop interface (IE Compatibility)
veltr
parents:
994
diff
changeset
|
265 |
image: _annotation.thumbnail |
|
c472984db275
refactored drag-and-drop interface (IE Compatibility)
veltr
parents:
994
diff
changeset
|
266 |
}); |
|
969
353b0881a0b9
Added On-the-fly (file-less) metadata generation test
veltr
parents:
967
diff
changeset
|
267 |
_el.on("remove", function() { |
|
353b0881a0b9
Added On-the-fly (file-less) metadata generation test
veltr
parents:
967
diff
changeset
|
268 |
_annotation.off("select", _onselect); |
|
353b0881a0b9
Added On-the-fly (file-less) metadata generation test
veltr
parents:
967
diff
changeset
|
269 |
_annotation.off("unselect", _onunselect); |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
270 |
}); |
|
969
353b0881a0b9
Added On-the-fly (file-less) metadata generation test
veltr
parents:
967
diff
changeset
|
271 |
_annotation.on("select", _onselect); |
|
353b0881a0b9
Added On-the-fly (file-less) metadata generation test
veltr
parents:
967
diff
changeset
|
272 |
_annotation.on("unselect", _onunselect); |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
273 |
}); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
274 |
|
| 903 | 275 |
/* Correct the empty tag bug */ |
276 |
this.$.find('.Ldt-AnnotationsList-Tag-Li').each(function() { |
|
277 |
var _el = IriSP.jQuery(this); |
|
278 |
if (!_el.text().replace(/(^\s+|\s+$)/g,'')) { |
|
|
969
353b0881a0b9
Added On-the-fly (file-less) metadata generation test
veltr
parents:
967
diff
changeset
|
279 |
_el.remove(); |
| 903 | 280 |
} |
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 |
this.$.find('.Ldt-AnnotationsList-Tag-Li').click(function() { |
| 983 | 284 |
_this.source.getAnnotations().search(IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,'')); |
| 966 | 285 |
}); |
286 |
|
|
287 |
this.$.find(".Ldt-AnnotationsList-Play").click(function() { |
|
288 |
var _el = IriSP.jQuery(this), |
|
| 1010 | 289 |
_annid = _el.attr("data-annotation-id"); |
290 |
if (_this.jwplayers[_annid]) { |
|
291 |
jwplayer(_this.jwplayers[_annid]).play(); |
|
292 |
} |
|
| 966 | 293 |
_this.media.pause(); |
294 |
}); |
|
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
295 |
|
| 983 | 296 |
if (this.source.getAnnotations().searching) { |
|
988
eefd336335f9
Some improvements: Hashtags can be used, links are now clickable, ....
veltr
parents:
983
diff
changeset
|
297 |
var rx = _this.source.getAnnotations().regexp || false; |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
298 |
this.$.find(".Ldt-AnnotationsList-Title a, .Ldt-AnnotationsList-Description").each(function() { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
299 |
var _$ = IriSP.jQuery(this); |
|
988
eefd336335f9
Some improvements: Hashtags can be used, links are now clickable, ....
veltr
parents:
983
diff
changeset
|
300 |
_$.html(IriSP.textFieldHtml(_$.text(), rx)); |
|
eefd336335f9
Some improvements: Hashtags can be used, links are now clickable, ....
veltr
parents:
983
diff
changeset
|
301 |
}); |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
302 |
} |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
303 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
304 |
|
| 903 | 305 |
if (this.ajax_url) { |
306 |
if (this.mashupMode) { |
|
307 |
this.ajaxMashup(); |
|
308 |
} else { |
|
| 963 | 309 |
if (Math.abs(_currentTime - this.lastAjaxQuery) > (this.ajax_granularity)) { |
| 903 | 310 |
this.ajaxSource(); |
311 |
} |
|
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
312 |
} |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
313 |
} |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
314 |
return _list.length; |
| 1013 | 315 |
}; |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
316 |
|
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
317 |
IriSP.Widgets.AnnotationsList.prototype.draw = function() { |
| 876 | 318 |
|
| 1010 | 319 |
this.jwplayers = {}; |
| 959 | 320 |
this.mashupMode = (this.media.elementType === "mashup"); |
321 |
|
|
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
322 |
this.renderTemplate(); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
323 |
|
| 966 | 324 |
var _this = this; |
| 1010 | 325 |
|
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
326 |
this.list_$ = this.$.find(".Ldt-AnnotationsList-ul"); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
327 |
|
| 966 | 328 |
|
| 983 | 329 |
this.source.getAnnotations().on("search", function(_text) { |
330 |
_this.searchString = _text; |
|
331 |
if (_this.source !== _this.currentSource) { |
|
332 |
_this.currentSource.getAnnotations().search(_text); |
|
333 |
_this.throttledRefresh(); |
|
334 |
} |
|
335 |
}); |
|
336 |
this.source.getAnnotations().on("found", function() { |
|
337 |
_this.throttledRefresh(); |
|
338 |
}); |
|
339 |
this.source.getAnnotations().on("not-found", function() { |
|
340 |
_this.throttledRefresh(); |
|
341 |
}); |
|
342 |
this.source.getAnnotations().on("clear-search", function() { |
|
343 |
_this.searchString = false; |
|
344 |
if (_this.source !== _this.currentSource) { |
|
345 |
_this.currentSource.getAnnotations().trigger("clear-search"); |
|
346 |
} |
|
347 |
}); |
|
348 |
this.source.getAnnotations().on("search-cleared", function() { |
|
349 |
_this.throttledRefresh(); |
|
350 |
}); |
|
351 |
|
|
| 966 | 352 |
this.onMdpEvent("AnnotationsList.refresh", function() { |
353 |
if (_this.ajax_url) { |
|
354 |
if (_this.mashupMode) { |
|
355 |
_this.ajaxMashup(); |
|
356 |
} else { |
|
357 |
_this.ajaxSource(); |
|
358 |
} |
|
359 |
} |
|
360 |
_this.throttledRefresh(); |
|
361 |
}); |
|
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
362 |
|
| 903 | 363 |
if (this.ajax_url) { |
364 |
if (this.mashupMode) { |
|
365 |
this.ajaxMashup(); |
|
366 |
} else { |
|
367 |
this.ajaxSource(); |
|
368 |
} |
|
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
369 |
} else { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
370 |
this.currentSource = this.source; |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
371 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
372 |
|
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
373 |
if (this.refresh_interval) { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
374 |
window.setInterval(function() { |
| 1013 | 375 |
_this.currentSource.get(); |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
376 |
}, this.refresh_interval); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
377 |
} |
| 674 | 378 |
|
| 957 | 379 |
this.onMdpEvent("createAnnotationWidget.addedAnnotation"); |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
380 |
var _events = [ |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
381 |
"timeupdate", |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
382 |
"seeked", |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
383 |
"loadedmetadata" |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
384 |
]; |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
385 |
for (var _i = 0; _i < _events.length; _i++) { |
| 957 | 386 |
this.onMediaEvent(_events[_i], this.throttledRefresh); |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
387 |
} |
|
730
357fc047503b
redraw the widget after that an annotation has been added.
hamidouk
parents:
729
diff
changeset
|
388 |
|
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
389 |
this.throttledRefresh(); |
| 698 | 390 |
|
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
391 |
}; |