|
1 /* This widget displays the image associated to the annotation in the given container */ |
|
2 |
|
3 IriSP.Widgets.ImageDisplay = function(player, config) { |
|
4 IriSP.Widgets.Widget.call(this, player, config); |
|
5 } |
|
6 |
|
7 IriSP.Widgets.ImageDisplay.prototype = new IriSP.Widgets.Widget(); |
|
8 |
|
9 IriSP.Widgets.ImageDisplay.prototype.defaults = { |
|
10 annotation_type: "Slides", |
|
11 // container: "imageContainer" |
|
12 } |
|
13 |
|
14 IriSP.Widgets.ImageDisplay.prototype.template = '<div class="Ldt-ImageDisplay-Container"><img class="Ldt-ImageDisplay-Image" title="" alt="Slide Image" src=""/><div class="Ldt-ImageDisplay-Overlay Ldt-ImageDisplay-Overlay-Left"></div><div class="Ldt-ImageDisplay-Overlay Ldt-ImageDisplay-Overlay-Right"></div></div>'; |
|
15 |
|
16 IriSP.Widgets.ImageDisplay.prototype.annotationTemplate = ''; |
|
17 |
|
18 IriSP.Widgets.ImageDisplay.prototype.update = function(annotation) { |
|
19 // Update the widget with data corresponding to the annotation |
|
20 this.image.setAttribute("title", IriSP.textFieldHtml(annotation.title) + " - " + annotation.begin.toString()); |
|
21 this.image.setAttribute("src", annotation.thumbnail); |
|
22 }; |
|
23 |
|
24 IriSP.Widgets.ImageDisplay.prototype.draw = function() { |
|
25 var _annotations = this.getWidgetAnnotations().sortBy(function(_annotation) { |
|
26 return _annotation.begin; |
|
27 }); |
|
28 var _this = this; |
|
29 _this.renderTemplate(); |
|
30 _this.image = _this.$.find("img")[0]; |
|
31 |
|
32 _this.$.find(".Ldt-ImageDisplay-Overlay-Left").on("click", function () { _this.navigate(-1); }); |
|
33 _this.$.find(".Ldt-ImageDisplay-Overlay-Right").on("click", function () { _this.navigate(+1); }); |
|
34 |
|
35 _annotations.forEach(function(_a) { |
|
36 _a.on("enter", function() { |
|
37 _this.update(_a); |
|
38 }); |
|
39 }); |
|
40 if (_annotations.length) |
|
41 _this.update(_annotations[0]); |
|
42 } |