web/res/metadataplayer/SpelSyncHtml.js
author Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
Sun, 15 Feb 2015 00:43:16 +0100
changeset 1198 ff4b567d51f2
permissions -rw-r--r--
upgrade metadataplayer and add annotation creation

IriSP.Widgets.SpelSyncHtml = function(player, config) {
    console.log("Calling IriSP.Widget's constructor from IriSP.HelloWorldWidget");
    IriSP.Widgets.Widget.call(this, player, config);
};

IriSP.Widgets.SpelSyncHtml.prototype = new IriSP.Widgets.Widget();

IriSP.Widgets.SpelSyncHtml.prototype.defaults = {
    src: "about:blank"
};

IriSP.Widgets.SpelSyncHtml.prototype.template =
    '<div class="Ldt-SpelSyncHtml"><iframe src="{{src}}" {{#width}}width="{{width}}"{{/width}} {{#height}}height="{{height}}"{{/height}}</div>';

IriSP.Widgets.SpelSyncHtml.prototype.draw = function() {
    this.renderTemplate();
    var frame = this.$.find("iframe")[0],
        basesrc = this.src.replace(/#.*$/,'');
    this.getWidgetAnnotations().forEach(function(a) {
        a.on("enter", function() {
            if (a.content && a.content.data && a.content.data.ref_text) {
                frame.src = basesrc + '#' + a.content.data.ref_text;
            }
        });
    });
};