| author | veltr |
| Tue, 15 May 2012 15:50:19 +0200 | |
| branch | new-model |
| changeset 903 | d9da52e20f7f |
| parent 902 | 14022f1d49ab |
| child 906 | 4b6e154ae8de |
| 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.searchString = false; |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
4 |
this.lastIds = []; |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
5 |
var _this = this; |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
6 |
this.throttledRefresh = IriSP._.throttle(function() { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
7 |
_this.refresh(false); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
8 |
}, 1500); |
| 903 | 9 |
this.mashupMode = (this.source.currentMedia.elementType === "mashup"); |
| 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, |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
19 |
/* how much ms should we look before and after the current timecode in the segment API |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
20 |
*/ |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
21 |
ajax_granularity : 300000, |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
22 |
default_thumbnail : "http://ldt.iri.centrepompidou.fr/static/site/ldt/css/imgs/video_sequence.png", |
|
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, |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
29 |
limit_count : 10, |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
30 |
newest_first : false |
| 585 | 31 |
}; |
32 |
||
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
33 |
IriSP.Widgets.AnnotationsList.prototype.template = |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
34 |
'<div class="Ldt-AnnotationsListWidget">' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
35 |
+ '<ul class="Ldt-AnnotationsList-ul">' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
36 |
+ '{{#annotations}}' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
37 |
+ '<li id="Ldt-Annotation-li-{{id}}" class="Ldt-AnnotationsList-li Ldt-TraceMe">' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
38 |
+ '<div class="Ldt-AnnotationsList-ThumbContainer">' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
39 |
+ '<a href="{{url}}">' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
40 |
+ '<img class="Ldt-AnnotationsList-Thumbnail" src="{{thumbnail}}" />' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
41 |
+ '</a>' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
42 |
+ '</div>' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
43 |
+ '<div class="Ldt-AnnotationsList-Duration">{{begin}} - {{end}}</div>' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
44 |
+ '<h3 class="Ldt-AnnotationsList-Title">' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
45 |
+ '<a href="{{url}}">{{title}}</a>' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
46 |
+ '</h3>' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
47 |
+ '<p class="Ldt-AnnotationsList-Description">{{description}}</p>' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
48 |
+ '{{#tags.length}}' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
49 |
+ '<ul class="Ldt-AnnotationsList-Tags">' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
50 |
+ '{{#tags}}' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
51 |
+ '{{#.}}' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
52 |
+ '<li class="Ldt-AnnotationsList-Tag-Li">' |
| 902 | 53 |
+ '<span>{{.}}</span>' |
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
54 |
+ '</li>' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
55 |
+ '{{/.}}' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
56 |
+ '{{/tags}}' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
57 |
+ '</ul>' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
58 |
+ '{{/tags.length}}' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
59 |
+ '</li>' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
60 |
+ '{{/annotations}}' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
61 |
+ '</ul>' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
62 |
+ '</div>'; |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
63 |
|
| 876 | 64 |
IriSP.Widgets.AnnotationsList.prototype.onSearch = function(searchString) { |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
65 |
this.searchString = typeof searchString !== "undefined" ? searchString : ''; |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
66 |
var _n = this.refresh(true); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
67 |
if (this.searchString) { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
68 |
if (_n) { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
69 |
this.player.popcorn.trigger("IriSP.search.matchFound"); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
70 |
} else { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
71 |
this.player.popcorn.trigger("IriSP.search.noMatchFound"); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
72 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
73 |
} |
|
838
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
74 |
} |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
75 |
|
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
76 |
//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
|
77 |
|
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
78 |
IriSP.Widgets.AnnotationsList.prototype.ajaxSource = function() { |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
79 |
var _currentTime = this.player.popcorn.currentTime(), |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
80 |
_duration = this.source.getDuration(); |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
81 |
if (typeof _currentTime == "undefined") { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
82 |
_currentTime = 0; |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
83 |
} |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
84 |
this.lastAjaxQuery = _currentTime; |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
85 |
_currentTime = Math.floor(1000 * _currentTime); |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
86 |
var _url = Mustache.to_html(this.ajax_url, { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
87 |
media : this.source.currentMedia.namespacedId.name, |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
88 |
begin : Math.max(0, _currentTime - this.ajax_granularity), |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
89 |
end : Math.min(_duration.milliseconds, _currentTime + this.ajax_granularity) |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
90 |
}); |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
91 |
this.currentSource = this.player.loadMetadata(IriSP._.defaults({ |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
92 |
"url" : _url |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
93 |
}, this.metadata)); |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
94 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
95 |
|
| 903 | 96 |
IriSP.Widgets.AnnotationsList.prototype.ajaxMashup = function() { |
97 |
var _currentTime = this.player.popcorn.currentTime(); |
|
98 |
if (typeof _currentTime == "undefined") { |
|
99 |
_currentTime = 0; |
|
100 |
} |
|
101 |
var _currentAnnotation = this.source.currentMedia.getAnnotationAtTime(_currentTime * 1000); |
|
102 |
if (typeof _currentAnnotation !== "undefined" && _currentAnnotation.namespacedId.name !== this.lastMashupAnnotation) { |
|
103 |
this.lastMashupAnnotation = _currentAnnotation.namespacedId.name; |
|
104 |
var _currentMedia = _currentAnnotation.getMedia(), |
|
105 |
_url = Mustache.to_html(this.ajax_url, { |
|
106 |
media : _currentMedia.namespacedId.name, |
|
107 |
begin : Math.max(0, _currentAnnotation.annotation.begin.milliseconds - this.ajax_granularity), |
|
108 |
end : Math.min(_currentMedia.duration.milliseconds, _currentAnnotation.annotation.end.milliseconds + this.ajax_granularity) |
|
109 |
}); |
|
110 |
console.log("Getting", _url); |
|
111 |
this.currentSource = this.player.loadMetadata(IriSP._.defaults({ |
|
112 |
"url" : _url |
|
113 |
}, this.metadata)); |
|
114 |
} |
|
115 |
} |
|
116 |
||
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
117 |
IriSP.Widgets.AnnotationsList.prototype.refresh = function(_forceRedraw) { |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
118 |
_forceRedraw = (typeof _forceRedraw !== "undefined" && _forceRedraw); |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
119 |
if (this.currentSource.status !== IriSP.Model._SOURCE_STATUS_READY) { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
120 |
return 0; |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
121 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
122 |
var _this = this, |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
123 |
_currentTime = this.player.popcorn.currentTime(); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
124 |
if (typeof _currentTime == "undefined") { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
125 |
_currentTime = 0; |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
126 |
} |
| 903 | 127 |
var _list = this.annotation_type ? this.currentSource.getAnnotationsByTypeTitle(this.annotation_type) : this.currentSource.getAnnotations(); |
128 |
if (this.mashupMode) { |
|
129 |
var _currentAnnotation = this.source.currentMedia.getAnnotationAtTime(_currentTime * 1000); |
|
130 |
if (typeof _currentAnnotation !== "undefined") { |
|
131 |
_currentTime = _currentTime - _currentAnnotation.begin.getSeconds() + _currentAnnotation.annotation.begin.getSeconds(); |
|
132 |
var _mediaId = _currentAnnotation.getMedia().namespacedId.name; |
|
133 |
_list = _list.filter(function(_annotation) { |
|
134 |
return _annotation.getMedia().namespacedId.name === _mediaId; |
|
135 |
}); |
|
136 |
} |
|
137 |
} |
|
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
138 |
if (this.searchString) { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
139 |
_list = _list.searchByTextFields(this.searchString); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
140 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
141 |
if (this.limit_count) { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
142 |
_list = _list.sortBy(function(_annotation) { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
143 |
return Math.abs(_annotation.begin.getSeconds() - _currentTime); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
144 |
}).slice(0, this.limit_count) |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
145 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
146 |
if (this.newest_first) { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
147 |
_list = _list.sortBy(function(_annotation) { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
148 |
return -_annotation.created.valueOf(); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
149 |
}); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
150 |
} else { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
151 |
_list = _list.sortBy(function(_annotation) { |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
152 |
return _annotation.begin; |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
153 |
}); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
154 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
155 |
|
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
156 |
var _ids = _list.idIndex; |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
157 |
|
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
158 |
if (_forceRedraw || !IriSP._.isEqual(_ids, this.lastIds)) { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
159 |
/* This part only gets executed if the list needs updating */ |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
160 |
this.lastIds = _ids; |
| 876 | 161 |
var _data = _list.map(function(_annotation) { |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
162 |
var _url = ( |
| 876 | 163 |
( typeof _annotation.url !== "undefined" && _annotation.url) |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
164 |
? _annotation.url |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
165 |
: ( |
| 876 | 166 |
( typeof _this.source.projectId !== "undefined" && typeof _annotation.project !== "undefined" && _annotation.project && _this.source.projectId !== _annotation.project ) |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
167 |
? Mustache.to_html( |
| 876 | 168 |
_this.foreign_url, |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
169 |
{ |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
170 |
project : _annotation.project, |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
171 |
media : _annotation.media.id.replace(/^.*:/,''), |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
172 |
annotation : _annotation.namespacedId.name, |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
173 |
annotationType : _annotation.annotationType.id.replace(/^.*:/,'') |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
174 |
} |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
175 |
) |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
176 |
: '#id=' + _annotation.namespacedId.name |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
177 |
) |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
178 |
); |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
179 |
var _res = { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
180 |
id : _annotation.id, |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
181 |
title : _annotation.title.replace(_annotation.description,''), |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
182 |
description : _annotation.description, |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
183 |
begin : _annotation.begin.toString(), |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
184 |
end : _annotation.end.toString(), |
| 876 | 185 |
thumbnail : typeof _annotation.thumbnail !== "undefined" && _annotation.thumbnail ? _annotation.thumbnail : _this.default_thumbnail, |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
186 |
url : _url, |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
187 |
tags : _annotation.getTagTexts() |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
188 |
} |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
189 |
return _res; |
| 876 | 190 |
}), |
191 |
_html = Mustache.to_html( |
|
192 |
this.template, |
|
193 |
{ |
|
194 |
annotations : _data |
|
195 |
}); |
|
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
196 |
|
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
197 |
this.$.html(_html); |
| 903 | 198 |
|
199 |
/* Correct the empty tag bug */ |
|
200 |
this.$.find('.Ldt-AnnotationsList-Tag-Li').each(function() { |
|
201 |
var _el = IriSP.jQuery(this); |
|
202 |
if (!_el.text().replace(/(^\s+|\s+$)/g,'')) { |
|
203 |
_el.detach(); |
|
204 |
} |
|
205 |
}); |
|
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
206 |
|
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
207 |
this.$.find('.Ldt-AnnotationsList-Tag-Li').click(function() { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
208 |
_this.player.popcorn.trigger("IriSP.search.triggeredSearch", IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,'')); |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
209 |
}) |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
210 |
|
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
211 |
if(this.searchString) { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
212 |
var _searchRe = new RegExp('(' + this.searchString.replace(/(\W)/gm,'\\$1') + ')','gim'); |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
213 |
this.$.find(".Ldt-AnnotationsList-Title a, .Ldt-AnnotationsList-Description").each(function() { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
214 |
var _$ = IriSP.jQuery(this); |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
215 |
_$.html(_$.text().replace(/(^\s+|\s+$)/g,'').replace(_searchRe, '<span class="Ldt-AnnotationsList-highlight">$1</span>')) |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
216 |
}) |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
217 |
} |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
218 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
219 |
|
| 903 | 220 |
if (this.ajax_url) { |
221 |
if (this.mashupMode) { |
|
222 |
this.ajaxMashup(); |
|
223 |
} else { |
|
224 |
if (Math.abs(_currentTime - this.lastAjaxQuery) > (this.ajax_granularity / 2000)) { |
|
225 |
this.ajaxSource(); |
|
226 |
} |
|
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
227 |
} |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
228 |
} |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
229 |
return _list.length; |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
230 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
231 |
|
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
232 |
IriSP.Widgets.AnnotationsList.prototype.draw = function() { |
| 876 | 233 |
|
234 |
this.bindPopcorn("IriSP.search", "onSearch"); |
|
235 |
this.bindPopcorn("IriSP.search.closed", "onSearch"); |
|
236 |
this.bindPopcorn("IriSP.search.cleared", "onSearch"); |
|
237 |
|
|
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
238 |
var _this = this; |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
239 |
|
| 903 | 240 |
if (this.ajax_url) { |
241 |
if (this.mashupMode) { |
|
242 |
this.ajaxMashup(); |
|
243 |
} else { |
|
244 |
this.ajaxSource(); |
|
245 |
} |
|
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
246 |
} else { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
247 |
this.currentSource = this.source; |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
248 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
249 |
|
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
250 |
if (this.refresh_interval) { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
251 |
window.setInterval(function() { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
252 |
_this.currentSource.get() |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
253 |
}, this.refresh_interval); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
254 |
} |
| 674 | 255 |
|
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
256 |
var _events = [ |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
257 |
"IriSP.createAnnotationWidget.addedAnnotation", |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
258 |
"timeupdate", |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
259 |
"seeked", |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
260 |
"loadedmetadata" |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
261 |
]; |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
262 |
for (var _i = 0; _i < _events.length; _i++) { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
263 |
this.player.popcorn.listen(_events[_i], this.throttledRefresh); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
264 |
} |
|
730
357fc047503b
redraw the widget after that an annotation has been added.
hamidouk
parents:
729
diff
changeset
|
265 |
|
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
266 |
this.throttledRefresh(); |
| 698 | 267 |
|
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
268 |
}; |