| author | veltr |
| Mon, 17 Sep 2012 00:17:06 +0900 | |
| branch | players-as-widgets |
| changeset 957 | 4da0a5740b6c |
| parent 944 | 8a6c9e3d0158 |
| child 959 | ee11ed1b739e |
| 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, |
| 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 |
*/ |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
21 |
ajax_granularity : 300000, |
| 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, |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
29 |
limit_count : 10, |
| 924 | 30 |
newest_first : false, |
31 |
polemics : [{ |
|
32 |
keyword: "++", |
|
33 |
background_color: "#c9ecc6" |
|
34 |
},{ |
|
35 |
keyword: "--", |
|
36 |
background_color: "#f9c5c6" |
|
37 |
},{ |
|
38 |
keyword: "??", |
|
39 |
background_color: "#cec5f9" |
|
40 |
},{ |
|
41 |
keyword: "==", |
|
42 |
background_color: "#f9f4c6" |
|
43 |
}] |
|
| 585 | 44 |
}; |
45 |
||
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
46 |
IriSP.Widgets.AnnotationsList.prototype.template = |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
47 |
'<div class="Ldt-AnnotationsListWidget">' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
48 |
+ '<ul class="Ldt-AnnotationsList-ul">' |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
49 |
+ '</ul>' |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
50 |
+ '</div>'; |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
51 |
|
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
52 |
IriSP.Widgets.AnnotationsList.prototype.annotationTemplate = |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
53 |
'<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
|
54 |
+ '<div class="Ldt-AnnotationsList-ThumbContainer">' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
55 |
+ '<a href="{{url}}">' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
56 |
+ '<img class="Ldt-AnnotationsList-Thumbnail" src="{{thumbnail}}" />' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
57 |
+ '</a>' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
58 |
+ '</div>' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
59 |
+ '<div class="Ldt-AnnotationsList-Duration">{{begin}} - {{end}}</div>' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
60 |
+ '<h3 class="Ldt-AnnotationsList-Title">' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
61 |
+ '<a href="{{url}}">{{title}}</a>' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
62 |
+ '</h3>' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
63 |
+ '<p class="Ldt-AnnotationsList-Description">{{description}}</p>' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
64 |
+ '{{#tags.length}}' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
65 |
+ '<ul class="Ldt-AnnotationsList-Tags">' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
66 |
+ '{{#tags}}' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
67 |
+ '{{#.}}' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
68 |
+ '<li class="Ldt-AnnotationsList-Tag-Li">' |
| 902 | 69 |
+ '<span>{{.}}</span>' |
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
70 |
+ '</li>' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
71 |
+ '{{/.}}' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
72 |
+ '{{/tags}}' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
73 |
+ '</ul>' |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
74 |
+ '{{/tags.length}}' |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
75 |
+ '</li>'; |
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
76 |
|
| 876 | 77 |
IriSP.Widgets.AnnotationsList.prototype.onSearch = function(searchString) { |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
78 |
this.searchString = typeof searchString !== "undefined" ? searchString : ''; |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
79 |
var _n = this.refresh(true); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
80 |
if (this.searchString) { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
81 |
if (_n) { |
| 957 | 82 |
this.player.trigger("search.matchFound"); |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
83 |
} else { |
| 957 | 84 |
this.player.trigger("search.noMatchFound"); |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
85 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
86 |
} |
|
838
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
87 |
} |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
88 |
|
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
89 |
//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
|
90 |
|
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
91 |
IriSP.Widgets.AnnotationsList.prototype.ajaxSource = function() { |
| 957 | 92 |
var _currentTime = this.media.getCurrentTime(), |
93 |
_duration = this.media.duration; |
|
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
94 |
this.lastAjaxQuery = _currentTime; |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
95 |
_currentTime = Math.floor(1000 * _currentTime); |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
96 |
var _url = Mustache.to_html(this.ajax_url, { |
| 916 | 97 |
media : this.source.currentMedia.id, |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
98 |
begin : Math.max(0, _currentTime - this.ajax_granularity), |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
99 |
end : Math.min(_duration.milliseconds, _currentTime + this.ajax_granularity) |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
100 |
}); |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
101 |
this.currentSource = this.player.loadMetadata(IriSP._.defaults({ |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
102 |
"url" : _url |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
103 |
}, this.metadata)); |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
104 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
105 |
|
| 903 | 106 |
IriSP.Widgets.AnnotationsList.prototype.ajaxMashup = function() { |
| 957 | 107 |
var _currentTime = this.media.getCurrentTime(); |
108 |
var _currentAnnotation = this.source.currentMedia.getAnnotationAtTime(_currentTime); |
|
| 916 | 109 |
if (typeof _currentAnnotation !== "undefined" && _currentAnnotation.id !== this.lastMashupAnnotation) { |
110 |
this.lastMashupAnnotation = _currentAnnotation.id; |
|
| 903 | 111 |
var _currentMedia = _currentAnnotation.getMedia(), |
112 |
_url = Mustache.to_html(this.ajax_url, { |
|
| 916 | 113 |
media : _currentMedia.id, |
| 903 | 114 |
begin : Math.max(0, _currentAnnotation.annotation.begin.milliseconds - this.ajax_granularity), |
115 |
end : Math.min(_currentMedia.duration.milliseconds, _currentAnnotation.annotation.end.milliseconds + this.ajax_granularity) |
|
116 |
}); |
|
117 |
this.currentSource = this.player.loadMetadata(IriSP._.defaults({ |
|
118 |
"url" : _url |
|
119 |
}, this.metadata)); |
|
120 |
} |
|
121 |
} |
|
122 |
||
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
123 |
IriSP.Widgets.AnnotationsList.prototype.refresh = function(_forceRedraw) { |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
124 |
_forceRedraw = (typeof _forceRedraw !== "undefined" && _forceRedraw); |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
125 |
if (this.currentSource.status !== IriSP.Model._SOURCE_STATUS_READY) { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
126 |
return 0; |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
127 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
128 |
var _this = this, |
| 957 | 129 |
_currentTime = this.media.getCurrentTime(); |
| 903 | 130 |
var _list = this.annotation_type ? this.currentSource.getAnnotationsByTypeTitle(this.annotation_type) : this.currentSource.getAnnotations(); |
131 |
if (this.mashupMode) { |
|
| 957 | 132 |
var _currentAnnotation = this.source.currentMedia.getAnnotationAtTime(_currentTime); |
| 903 | 133 |
if (typeof _currentAnnotation !== "undefined") { |
134 |
_currentTime = _currentTime - _currentAnnotation.begin.getSeconds() + _currentAnnotation.annotation.begin.getSeconds(); |
|
| 916 | 135 |
var _mediaId = _currentAnnotation.getMedia().id; |
| 903 | 136 |
_list = _list.filter(function(_annotation) { |
| 916 | 137 |
return _annotation.getMedia().id === _mediaId; |
| 903 | 138 |
}); |
139 |
} |
|
140 |
} |
|
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
141 |
if (this.searchString) { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
142 |
_list = _list.searchByTextFields(this.searchString); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
143 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
144 |
if (this.limit_count) { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
145 |
_list = _list.sortBy(function(_annotation) { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
146 |
return Math.abs(_annotation.begin.getSeconds() - _currentTime); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
147 |
}).slice(0, this.limit_count) |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
148 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
149 |
if (this.newest_first) { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
150 |
_list = _list.sortBy(function(_annotation) { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
151 |
return -_annotation.created.valueOf(); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
152 |
}); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
153 |
} else { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
154 |
_list = _list.sortBy(function(_annotation) { |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
155 |
return _annotation.begin; |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
156 |
}); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
157 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
158 |
|
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
159 |
var _ids = _list.idIndex; |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
160 |
|
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
161 |
if (_forceRedraw || !IriSP._.isEqual(_ids, this.lastIds)) { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
162 |
/* This part only gets executed if the list needs updating */ |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
163 |
this.lastIds = _ids; |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
164 |
this.list_$.html(""); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
165 |
_list.forEach(function(_annotation) { |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
166 |
var _url = ( |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
167 |
( typeof _annotation.url !== "undefined" && _annotation.url) |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
168 |
? _annotation.url |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
169 |
: ( |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
170 |
( 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
|
171 |
? Mustache.to_html( |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
172 |
_this.foreign_url, |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
173 |
{ |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
174 |
project : _annotation.project, |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
175 |
media : _annotation.media.id, |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
176 |
annotation : _annotation.id, |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
177 |
annotationType : _annotation.annotationType.id |
| 924 | 178 |
} |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
179 |
) |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
180 |
: '#id=' + _annotation.id |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
181 |
) |
|
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 |
var _title = (_annotation.title || "").replace(_annotation.description,''), |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
184 |
_description = _annotation.description; |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
185 |
if (!_annotation.title) { |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
186 |
_title = _annotation.creator; |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
187 |
} |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
188 |
if (!_annotation.description && _annotation.creator) { |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
189 |
_description = _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 |
var _bgcolor; |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
193 |
IriSP._(_this.polemics).each(function(_polemic) { |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
194 |
var _rgxp = IriSP.Model.regexpFromTextOrArray(_polemic.keyword, true); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
195 |
if (_rgxp.test(_title + " " + _description)) { |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
196 |
_bgcolor = _polemic.background_color; |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
197 |
} |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
198 |
}); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
199 |
var _data = { |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
200 |
id : _annotation.id, |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
201 |
media_id : _annotation.getMedia().id, |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
202 |
title : _title, |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
203 |
description : _description, |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
204 |
begin : _annotation.begin.toString(), |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
205 |
end : _annotation.end.toString(), |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
206 |
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
|
207 |
url : _url, |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
208 |
tags : _annotation.getTagTexts(), |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
209 |
specific_style : (typeof _bgcolor !== "undefined" ? "background-color: " + _bgcolor : "") |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
210 |
}; |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
211 |
var _html = Mustache.to_html(_this.annotationTemplate, _data); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
212 |
var _el = IriSP.jQuery(_html); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
213 |
_el.mouseover(function() { |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
214 |
_annotation.trigger("select"); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
215 |
}) |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
216 |
.mouseout(function() { |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
217 |
_annotation.trigger("unselect"); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
218 |
}) |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
219 |
.appendTo(_this.list_$); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
220 |
_annotation.on("select", function() { |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
221 |
_this.annotations_$.removeClass("selected"); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
222 |
_el.addClass("selected"); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
223 |
}); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
224 |
_annotation.on("unselect", function() { |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
225 |
_this.annotations_$.removeClass("selected"); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
226 |
});; |
|
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 |
|
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
229 |
this.annotations_$ = this.$.find('.Ldt-AnnotationsList-li'); |
| 903 | 230 |
|
231 |
/* Correct the empty tag bug */ |
|
232 |
this.$.find('.Ldt-AnnotationsList-Tag-Li').each(function() { |
|
233 |
var _el = IriSP.jQuery(this); |
|
234 |
if (!_el.text().replace(/(^\s+|\s+$)/g,'')) { |
|
235 |
_el.detach(); |
|
236 |
} |
|
237 |
}); |
|
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
238 |
|
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
239 |
this.$.find('.Ldt-AnnotationsList-Tag-Li').click(function() { |
| 957 | 240 |
_this.player.trigger("search.triggeredSearch", IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,'')); |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
241 |
}) |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
242 |
|
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
243 |
if(this.searchString) { |
| 925 | 244 |
var _searchRe = IriSP.Model.regexpFromTextOrArray(this.searchString); |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
245 |
this.$.find(".Ldt-AnnotationsList-Title a, .Ldt-AnnotationsList-Description").each(function() { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
246 |
var _$ = IriSP.jQuery(this); |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
247 |
_$.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
|
248 |
}) |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
249 |
} |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
250 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
251 |
|
| 903 | 252 |
if (this.ajax_url) { |
253 |
if (this.mashupMode) { |
|
254 |
this.ajaxMashup(); |
|
255 |
} else { |
|
256 |
if (Math.abs(_currentTime - this.lastAjaxQuery) > (this.ajax_granularity / 2000)) { |
|
257 |
this.ajaxSource(); |
|
258 |
} |
|
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
259 |
} |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
260 |
} |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
261 |
return _list.length; |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
262 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
263 |
|
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
264 |
IriSP.Widgets.AnnotationsList.prototype.draw = function() { |
| 876 | 265 |
|
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
266 |
this.renderTemplate(); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
267 |
|
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
268 |
this.list_$ = this.$.find(".Ldt-AnnotationsList-ul"); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
269 |
|
| 957 | 270 |
this.onMdpEvent("search", "onSearch"); |
271 |
this.onMdpEvent("search.closed", "onSearch"); |
|
272 |
this.onMdpEvent("search.cleared", "onSearch"); |
|
273 |
this.onMdpEvent("AnnotationsList.refresh","refresh"); |
|
| 876 | 274 |
|
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
275 |
var _this = this; |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
276 |
|
| 903 | 277 |
if (this.ajax_url) { |
278 |
if (this.mashupMode) { |
|
279 |
this.ajaxMashup(); |
|
280 |
} else { |
|
281 |
this.ajaxSource(); |
|
282 |
} |
|
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
283 |
} else { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
284 |
this.currentSource = this.source; |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
285 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
286 |
|
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
287 |
if (this.refresh_interval) { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
288 |
window.setInterval(function() { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
289 |
_this.currentSource.get() |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
290 |
}, this.refresh_interval); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
291 |
} |
| 674 | 292 |
|
| 957 | 293 |
this.onMdpEvent("createAnnotationWidget.addedAnnotation"); |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
294 |
var _events = [ |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
295 |
"timeupdate", |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
296 |
"seeked", |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
297 |
"loadedmetadata" |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
298 |
]; |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
299 |
for (var _i = 0; _i < _events.length; _i++) { |
| 957 | 300 |
this.onMediaEvent(_events[_i], this.throttledRefresh); |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
301 |
} |
|
730
357fc047503b
redraw the widget after that an annotation has been added.
hamidouk
parents:
729
diff
changeset
|
302 |
|
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
303 |
this.throttledRefresh(); |
| 698 | 304 |
|
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
852
diff
changeset
|
305 |
}; |