5 |
5 |
6 this.checkOption('ajax_mode'); |
6 this.checkOption('ajax_mode'); |
7 this.checkOption('project_url'); |
7 this.checkOption('project_url'); |
8 this.checkOption('default_thumbnail'); |
8 this.checkOption('default_thumbnail'); |
9 this.checkOption("cinecast_version", false); |
9 this.checkOption("cinecast_version", false); |
|
10 this.searchRe = null; |
|
11 this._ajax_cache = []; |
10 var _this = this; |
12 var _this = this; |
|
13 |
|
14 this._Popcorn.listen("IriSP.search", function(searchString) { |
|
15 _this.searchHandler(searchString); |
|
16 }); |
|
17 this._Popcorn.listen("IriSP.search.closed", function() { |
|
18 _this.searchHandler(false); |
|
19 }); |
|
20 this._Popcorn.listen("IriSP.search.cleared", function() { |
|
21 _this.searchHandler(false); |
|
22 }); |
11 }; |
23 }; |
12 |
24 |
13 |
25 |
14 IriSP.AnnotationsListWidget.prototype = new IriSP.Widget(); |
26 IriSP.AnnotationsListWidget.prototype = new IriSP.Widget(); |
15 |
27 |
16 IriSP.AnnotationsListWidget.prototype.clear = function() { |
28 IriSP.AnnotationsListWidget.prototype.clear = function() { |
17 }; |
29 }; |
18 |
30 |
19 IriSP.AnnotationsListWidget.prototype.clearWidget = function() { |
31 IriSP.AnnotationsListWidget.prototype.clearWidget = function() { |
20 }; |
32 }; |
|
33 |
|
34 IriSP.AnnotationsListWidget.prototype.searchHandler = function(searchString) { |
|
35 this.searchRe = (searchString && searchString.length) ? IriSP.regexpFromText(searchString) : null; |
|
36 if (this.ajax_mode) { |
|
37 var _this = this, |
|
38 _annotations = ( |
|
39 this.searchRe === null |
|
40 ? this._ajax_cache |
|
41 : IriSP.underscore.filter(this._ajax_cache, function(_a) { |
|
42 return (_this.searchRe.test(_a.desc) || _this.searchRe.test(_a.title)); |
|
43 }) |
|
44 ); |
|
45 this.do_redraw(_annotations); |
|
46 if (_annotations.length) { |
|
47 this._Popcorn.trigger("IriSP.search.matchFound"); |
|
48 } else { |
|
49 this._Popcorn.trigger("IriSP.search.noMatchFound"); |
|
50 } |
|
51 } else { |
|
52 this.drawList(); |
|
53 } |
|
54 } |
21 |
55 |
22 /** effectively redraw the widget - called by drawList */ |
56 /** effectively redraw the widget - called by drawList */ |
23 IriSP.AnnotationsListWidget.prototype.do_redraw = function(list) { |
57 IriSP.AnnotationsListWidget.prototype.do_redraw = function(list) { |
24 var widgetMarkup = IriSP.templToHTML(IriSP.annotationsListWidget_template, {annotations: list}); |
58 var _html = IriSP.templToHTML( |
25 this.selector.html(widgetMarkup); |
59 IriSP.annotationsListWidget_template, { |
|
60 annotations: list |
|
61 }), |
|
62 _this = this; |
|
63 |
|
64 this.selector.html(_html); |
|
65 |
|
66 if (this.searchRe !== null) { |
|
67 this.selector.find(".Ldt-AnnotationsList-Title a, .Ldt-AnnotationsList-Description") |
|
68 .each(function() { |
|
69 var _$ = IriSP.jQuery(this); |
|
70 _$.html(_$.text().replace(_this.searchRe, '<span class="Ldt-AnnotationsList-highlight">$1</span>')) |
|
71 }) |
|
72 } |
26 }; |
73 }; |
27 |
74 |
28 IriSP.AnnotationsListWidget.prototype.transformAnnotation = function(a) { |
75 IriSP.AnnotationsListWidget.prototype.transformAnnotation = function(a) { |
29 var _this = this |
76 var _this = this |
30 return { |
77 return { |
190 var i = 0; |
248 var i = 0; |
191 for(i = 0; i < annotations.length; i++) { |
249 for(i = 0; i < annotations.length; i++) { |
192 this.annotations_ids.push(annotations[i]["id"]); |
250 this.annotations_ids.push(annotations[i]["id"]); |
193 } |
251 } |
194 |
252 |
195 this.drawList(); |
|
196 |
|
197 var _this = this; |
253 var _this = this; |
198 |
254 |
199 if (!this.ajax_mode) { |
255 if (!this.ajax_mode) { |
200 var _throttled = IriSP.underscore.throttle(function() { |
256 var _throttled = IriSP.underscore.throttle(function() { |
201 _this.drawList(); |
257 _this.drawList(); |
202 }, 1500); |
258 }, 1500); |
203 this._Popcorn.listen("IriSP.createAnnotationWidget.addedAnnotation", _throttled); |
259 _throttled(); |
204 this._Popcorn.listen("timeupdate", _throttled); |
260 this._Popcorn.listen("IriSP.createAnnotationWidget.addedAnnotation", _throttled); |
|
261 this._Popcorn.listen("timeupdate", _throttled); |
205 } else { |
262 } else { |
206 /* update the widget when the video has finished loading and when it's seeked and paused */ |
263 /* update the widget when the video has finished loading and when it's seeked and paused */ |
207 this._Popcorn.listen("seeked", IriSP.wrap(this, this.ajaxRedraw)); |
264 this._Popcorn.listen("seeked", IriSP.wrap(this, this.ajaxRedraw)); |
208 this._Popcorn.listen("loadedmetadata", IriSP.wrap(this, this.ajaxRedraw)); |
265 this._Popcorn.listen("loadedmetadata", IriSP.wrap(this, this.ajaxRedraw)); |
209 this._Popcorn.listen("paused", IriSP.wrap(this, this.ajaxRedraw)); |
266 this._Popcorn.listen("paused", IriSP.wrap(this, this.ajaxRedraw)); |