client/js/ldtjson-bin.js
changeset 37 db991a757015
parent 34 08a366a35143
child 42 48d825187d67
equal deleted inserted replaced
36:d249d36ecc37 37:db991a757015
     1 Rkns.Ldt = {}
     1 Rkns.Ldt = {}
     2 
     2 
     3 Rkns.Ldt.ProjectBin = Rkns.Utils.inherit(Rkns._BaseBin);
     3 Rkns.Ldt.ProjectBin = Rkns.Utils.inherit(Rkns._BaseBin);
     4 
     4 
     5 Rkns.Ldt.ProjectBin.prototype.tagTemplate = Rkns._.template(
     5 Rkns.Ldt.ProjectBin.prototype.tagTemplate = Rkns._.template(
     6     '<li class="Rk-Bin-Item" data-uri="<%=ldt_platform%>ldtplatform/ldt/front/search/?search=<%=encodedtitle%>&field=all" data-title="<%-title%>" data-description="Tag \'<%-title%>\'">'
     6     '<li class="Rk-Bin-Item" data-image="img/ldt-tag.png" data-uri="<%=ldt_platform%>ldtplatform/ldt/front/search/?search=<%=encodedtitle%>&field=all" data-title="<%-title%>" data-description="Tag \'<%-title%>\'">'
     7     + '<div class="Rk-Ldt-Icon Rk-Ldt-TagIcon"></div><h4><%-title%></h4></li>'
     7     + '<img class="Rk-Ldt-Tag-Icon" src="img/ldt-tag.png" /><h4><%-title%></h4><div class="Rk-Clear"></div></li>'
     8 );
     8 );
     9 
     9 
    10 Rkns.Ldt.ProjectBin.prototype.annotationTemplate = Rkns._.template(
    10 Rkns.Ldt.ProjectBin.prototype.annotationTemplate = Rkns._.template(
    11     '<li class="Rk-Bin-Item" data-uri="<%=ldt_platform%>ldtplatform/ldt/front/player/<%=mediaid%>/#id=<%=annotationid%>" data-title="<%-title%>" data-description="<%-description%>">'
    11     '<li class="Rk-Bin-Item" data-image="<%=image%>" data-uri="<%=ldt_platform%>ldtplatform/ldt/front/player/<%=mediaid%>/#id=<%=annotationid%>" data-title="<%-title%>" data-description="<%-description%>">'
    12     + '<div class="Rk-Ldt-Icon Rk-Ldt-<%=type%>Icon"></div><h4><%-title%></h4><p><%-description%></p><p>Start: <%=start%>, End: <%=end%>, Duration: <%=duration%></p></li>'
    12     + '<img class="Rk-Ldt-Annotation-Icon" src="<%=image%>"/><h4><%-title%></h4><p><%-description%></p><p>Start: <%=start%>, End: <%=end%>, Duration: <%=duration%></p><div class="Rk-Clear"></div></li>'
    13 );
    13 );
    14 
    14 
    15 Rkns.Ldt.ProjectBin.prototype._init = function(_renkan, _opts) {
    15 Rkns.Ldt.ProjectBin.prototype._init = function(_renkan, _opts) {
    16     this.proj_id = _opts.project_id;
    16     this.proj_id = _opts.project_id;
    17     this.ldt_platform = _opts.ldt_platform || "http://ldt.iri.centrepompidou.fr/";
    17     this.ldt_platform = _opts.ldt_platform || "http://ldt.iri.centrepompidou.fr/";
    52             }).join("");
    52             }).join("");
    53             _html += '<li><h3>Annotations</h3></li>';
    53             _html += '<li><h3>Annotations</h3></li>';
    54             _html += Rkns._(_data.annotations).map(function(_annotation) {
    54             _html += Rkns._(_data.annotations).map(function(_annotation) {
    55                 var _description = _annotation.content.description,
    55                 var _description = _annotation.content.description,
    56                     _title = _annotation.content.title.replace(_description,""),
    56                     _title = _annotation.content.title.replace(_description,""),
    57                     _duration = _annotation.end - _annotation.begin;
    57                     _duration = _annotation.end - _annotation.begin,
       
    58                     _img = (
       
    59                         (_annotation.content && _annotation.content.img && _annotation.content.img.src)
       
    60                         ? _annotation.content.img.src
       
    61                         : ( _duration ? "img/ldt-segment.png" : "img/ldt-point.png" )
       
    62                     );
    58                 return _this.annotationTemplate({
    63                 return _this.annotationTemplate({
    59                     ldt_platform: _this.ldt_platform,
    64                     ldt_platform: _this.ldt_platform,
    60                     title: _title,
    65                     title: _title,
    61                     description: _description,
    66                     description: _description,
    62                     start: convertTC(_annotation.begin),
    67                     start: convertTC(_annotation.begin),
    63                     end: convertTC(_annotation.end),
    68                     end: convertTC(_annotation.end),
    64                     duration: convertTC(_duration),
    69                     duration: convertTC(_duration),
    65                     mediaid: _annotation.media,
    70                     mediaid: _annotation.media,
    66                     annotationid: _annotation.id,
    71                     annotationid: _annotation.id,
    67                     type: _duration ? "Segment" : "Point"
    72                     image: _img
    68                 });
    73                 });
    69             }).join("");
    74             }).join("");
    70             
    75             
    71             _this.main_$.html(_html);
    76             _this.main_$.html(_html);
    72             _renkan.resizeBins();
    77             _renkan.resizeBins();