src/widgets/CurrentSegmentInfobox.js
author durandn
Fri, 03 Jul 2015 17:00:33 +0200
changeset 1040 be314c4ea4ac
child 1046 eb77616c245f
permissions -rw-r--r--
New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1040
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
     1
/* Widget displays info on the current segment, with possibility of config for editing description and tags */
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
     2
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
     3
IriSP.Widgets.CurrentSegmentInfobox = function(player, config){
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
     4
    IriSP.Widgets.Widget.call(this, player, config);
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
     5
};
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
     6
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
     7
IriSP.Widgets.CurrentSegmentInfobox.prototype = new IriSP.Widgets.Widget();
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
     8
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
     9
IriSP.Widgets.CurrentSegmentInfobox.prototype.defaults = {
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    10
    annotation_type: "chap",
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    11
    readonly: true,
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    12
    empty_message: false
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    13
};
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    14
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    15
IriSP.Widgets.CurrentSegmentInfobox.prototype.template = 
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    16
    "<div class='Ldt-CurrentSegmentInfobox'>" 
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    17
    + "    <div class='Ldt-CurrentSegmentInfobox-Element Ldt-CurrentSegmentInfobox-Title'>{{title}}</div>" 
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    18
    + "    <div class='Ldt-CurrentSegmentInfobox-Element Ldt-CurrentSegmentInfobox-Description'>{{description}}</div>" 
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    19
    + "    <div class='Ldt-CurrentSegmentInfobox-Element Ldt-CurrentSegmentInfobox-Tags'>"
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    20
    + '        {{#tags.length}}'
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    21
    + '        <ul class="Ldt-CurrentSegmentInfobox-Tags-Ul">'
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    22
    + '        {{#tags}}'
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    23
    + '            {{#.}}'
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    24
    + '            <li class="Ldt-CurrentSegmentInfobox-Tags-Li">'
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    25
    + '                <span>{{.}}</span>'
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    26
    + '            </li>'
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    27
    + '            {{/.}}'
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    28
    + '        {{/tags}}'
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    29
    + '        </ul>'
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    30
    + '        {{/tags.length}}'
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    31
    + "    </div>" 
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    32
    + "</div>"
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    33
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    34
IriSP.Widgets.CurrentSegmentInfobox.prototype.messages = {
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    35
    fr : {
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    36
        empty : "Le player vidéo ne lit actuellement aucun segment"
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    37
    },
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    38
    en: {
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    39
        empty: "The player currently doesn't read any segment"
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    40
    }
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    41
}    
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    42
    
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    43
IriSP.Widgets.CurrentSegmentInfobox.prototype.draw = function() {
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    44
    var _this = this;
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    45
    this.segments = this.getWidgetAnnotations();
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    46
    
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    47
    this.renderTemplate();
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    48
    this.refresh();
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    49
    
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    50
    this.onMediaEvent("timeupdate", "refresh");
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    51
}
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    52
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    53
IriSP.Widgets.CurrentSegmentInfobox.prototype.refresh = function() {
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    54
    var _list = this.segments;
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    55
    
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    56
    _currentTime = this.media.getCurrentTime();
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    57
    _list = _list.filter(function(_segment){
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    58
        return (_segment.begin <= _currentTime && _segment.end >= _currentTime);
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    59
    })
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    60
    if (_list.length > 0){
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    61
        _currentSegment = _list[0];
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    62
        _data = {
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    63
            title: _currentSegment.title,
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    64
            description : _currentSegment.description,
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    65
            tags : _currentSegment.getTagTexts()
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    66
        }
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    67
        this.$.html(Mustache.to_html(this.template, _data))
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    68
    }
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    69
    else {
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    70
        var _empty_message = this.l10n.empty
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    71
        if (this.empty_message) {
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    72
            _empty_message = this.empty_message
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    73
        }
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    74
        this.$.find(".Ldt-CurrentSegmentInfobox").html("<div class='Ldt-CurrentSegmentInfobox-Element Ldt-CurrentSegmentInfobox-NoSegment'>"+_empty_message+"</div>");
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    75
    }
be314c4ea4ac New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff changeset
    76
}