src/widgets/Transcript.js
changeset 1033 c20df1c080e6
child 1068 7623f9af9272
equal deleted inserted replaced
1032:74ac0be7655c 1033:c20df1c080e6
       
     1 /* This widget displays annotations as a transcript */
       
     2 
       
     3 IriSP.Widgets.Transcript = function(player, config) {
       
     4     IriSP.Widgets.Widget.call(this, player, config);
       
     5 }
       
     6 
       
     7 IriSP.Widgets.Transcript.prototype = new IriSP.Widgets.Widget();
       
     8 
       
     9 IriSP.Widgets.Transcript.prototype.defaults = {
       
    10     annotation_type: "Caption"
       
    11     // container: "transcriptContainer"
       
    12 }
       
    13 
       
    14 IriSP.Widgets.Transcript.prototype.template = '<div class="Ldt-TranscriptWidget"></div>';
       
    15 
       
    16 IriSP.Widgets.Transcript.prototype.annotationTemplate = '<a data-begin="{{ begin }}" data-end="{{ end }}" data-id="{{ id }}" class="Ldt-Transcript-Annotation" href="#{{id}}">{{ content }}</a> ';
       
    17 
       
    18 IriSP.Widgets.Transcript.prototype.draw = function() {
       
    19     var _annotations = this.getWidgetAnnotations();
       
    20     var _this = this;
       
    21     var content;
       
    22 
       
    23     _this.renderTemplate();
       
    24     content = _this.$.find('.Ldt-TranscriptWidget');
       
    25 
       
    26     _annotations.forEach(function(_a) {
       
    27         var _data = {
       
    28             id : _a.id,
       
    29             content : IriSP.textFieldHtml(_a.title),
       
    30             begin : _a.begin.toString(),
       
    31             end : _a.end.toString()
       
    32         };
       
    33         var _html = Mustache.to_html(_this.annotationTemplate, _data);
       
    34         var _el = IriSP.jQuery(_html);
       
    35         content.append(_el);
       
    36     });
       
    37 };