web/res/metadataplayer/ImageDisplay.js
author ymh <ymh.work@gmail.com>
Mon, 20 Nov 2023 18:10:58 +0100
changeset 1557 7c67caaafdeb
parent 1304 10974bff4dae
permissions -rw-r--r--
enmi 22
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1198
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     1
/* This widget displays the image associated to the annotation in the given container */
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     2
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     3
IriSP.Widgets.ImageDisplay = function(player, config) {
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     4
    IriSP.Widgets.Widget.call(this, player, config);
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     5
}
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     6
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     7
IriSP.Widgets.ImageDisplay.prototype = new IriSP.Widgets.Widget();
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     8
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     9
IriSP.Widgets.ImageDisplay.prototype.defaults = {
1304
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    10
    annotation_type: "Slides"
1198
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    11
    // container: "imageContainer"
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    12
}
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    13
1304
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    14
IriSP.Widgets.ImageDisplay.prototype.template = '<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>';
1198
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    15
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    16
IriSP.Widgets.ImageDisplay.prototype.annotationTemplate = '';
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    17
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    18
IriSP.Widgets.ImageDisplay.prototype.update = function(annotation) {
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    19
    // Update the widget with data corresponding to the annotation
1304
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    20
    this.image.css("background-image", "url(" + annotation.thumbnail + ")");
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    21
    this.image.attr("title", IriSP.textFieldHtml(annotation.title) + " - " + annotation.begin.toString());
1198
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    22
};
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    23
1304
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    24
IriSP.Widgets.ImageDisplay.prototype.draw = function() {
1198
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    25
    var _annotations = this.getWidgetAnnotations().sortBy(function(_annotation) {
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    26
        return _annotation.begin;
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    27
    });
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    28
    var _this = this;
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    29
    _this.renderTemplate();
1304
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    30
    _this.image = _this.$.find(".Ldt-ImageDisplay-Container");
1198
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    31
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    32
    _this.$.find(".Ldt-ImageDisplay-Overlay-Left").on("click", function () { _this.navigate(-1); });
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    33
    _this.$.find(".Ldt-ImageDisplay-Overlay-Right").on("click", function () { _this.navigate(+1); });
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    34
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    35
    _annotations.forEach(function(_a) {
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    36
        _a.on("enter", function() {
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    37
            _this.update(_a);
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    38
        });
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    39
    });
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    40
    if (_annotations.length)
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    41
        _this.update(_annotations[0]);
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    42
}