src/widgets/SpelSyncHtml.js
author ymh <ymh.work@gmail.com>
Sun, 12 Nov 2017 22:07:33 +0100
changeset 1071 02c04d2c8fd8
parent 1013 392ddcd212d7
child 1072 ac1eacb3aa33
permissions -rw-r--r--
Various changes from git version and make autoplayer determine video type on lowercase url

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;
            }
        });
    });
};