| author | ymh <ymh.work@gmail.com> |
| Wed, 04 Sep 2024 17:32:50 +0200 | |
| changeset 1072 | ac1eacb3aa33 |
| parent 1068 | 7623f9af9272 |
| permissions | -rw-r--r-- |
| 1033 | 1 |
/* This widget displays the image associated to the annotation in the given container */ |
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
2 |
// ImageDisplay |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
3 |
import imageDisplayStyles from "./ImageDisplay.module.css"; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
4 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
5 |
const ImageDisplay = function (ns) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
6 |
return class extends ns.Widgets.Widget { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
7 |
constructor(player, config) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
8 |
super(player, config); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
9 |
} |
| 1033 | 10 |
|
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
11 |
static defaults = { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
12 |
annotation_type: "Slides", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
13 |
// container: "imageContainer" |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
14 |
}; |
| 1033 | 15 |
|
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
16 |
static template = |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
17 |
'<div class="Ldt-ImageDisplay-Container"><div class="Ldt-ImageDisplay-Overlay Ldt-ImageDisplay-Overlay-Left"></div><div class="Ldt-ImageDisplay-Overlay Ldt-ImageDisplay-Overlay-Right"></div></div>'; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
18 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
19 |
annotationTemplate = ""; |
| 1033 | 20 |
|
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
21 |
update(annotation) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
22 |
// Update the widget with data corresponding to the annotation |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
23 |
this.image.css("background-image", "url(" + annotation.thumbnail + ")"); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
24 |
this.image.attr( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
25 |
"title", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
26 |
ns.textFieldHtml(annotation.title) + " - " + annotation.begin.toString() |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
27 |
); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
28 |
} |
| 1033 | 29 |
|
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
30 |
draw() { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
31 |
var _annotations = this.getWidgetAnnotations().sortBy(function ( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
32 |
_annotation |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
33 |
) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
34 |
return _annotation.begin; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
35 |
}); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
36 |
var _this = this; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
37 |
_this.renderTemplate(); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
38 |
_this.image = _this.$.find(".Ldt-ImageDisplay-Container"); |
| 1033 | 39 |
|
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
40 |
_this.$.find(".Ldt-ImageDisplay-Overlay-Left").on("click", function () { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
41 |
_this.navigate(-1); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
42 |
}); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
43 |
_this.$.find(".Ldt-ImageDisplay-Overlay-Right").on("click", function () { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
44 |
_this.navigate(+1); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
45 |
}); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
46 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
47 |
_annotations.forEach(function (_a) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
48 |
_a.on("enter", function () { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
49 |
_this.update(_a); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
50 |
}); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
51 |
}); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
52 |
if (_annotations.length) _this.update(_annotations[0]); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
53 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
54 |
}; |
| 1033 | 55 |
}; |
56 |
||
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
57 |
export { ImageDisplay, imageDisplayStyles }; |