src/widgets/AnnotationsList.js
changeset 966 c1c762ad1697
parent 965 eadb7290c325
child 967 b4c6e64acb2d
equal deleted inserted replaced
965:eadb7290c325 966:c1c762ad1697
    23      * e.g. http://ldt.iri.centrepompidou.fr/ldtplatform/ldt/front/player/{{media}}/{{project}}/{{annotationType}}#id={{annotation}}
    23      * e.g. http://ldt.iri.centrepompidou.fr/ldtplatform/ldt/front/player/{{media}}/{{project}}/{{annotationType}}#id={{annotation}}
    24      */
    24      */
    25     foreign_url : "",
    25     foreign_url : "",
    26     annotation_type : false,
    26     annotation_type : false,
    27     refresh_interval : 0,
    27     refresh_interval : 0,
    28     limit_count : 10,
    28     limit_count : 20,
    29     newest_first : false,
    29     newest_first : false,
       
    30     show_audio: true,
    30     polemics : [{
    31     polemics : [{
    31         keyword: "++",
    32         keyword: "++",
    32         background_color: "#c9ecc6"
    33         background_color: "#c9ecc6"
    33     },{
    34     },{
    34         keyword: "--",
    35         keyword: "--",
    40         keyword: "==",
    41         keyword: "==",
    41         background_color: "#f9f4c6"
    42         background_color: "#f9f4c6"
    42     }]
    43     }]
    43 };
    44 };
    44 
    45 
       
    46 IriSP.Widgets.AnnotationsList.prototype.messages = {
       
    47     en: {
       
    48         voice_annotation: "Voice Annotation",
       
    49         now_playing: "Now playing..."
       
    50     },
       
    51     fr: {
       
    52         voice_annotation: "Annotation Vocale",
       
    53         now_playing: "Lecture en cours..."
       
    54     }
       
    55 }
       
    56 
    45 IriSP.Widgets.AnnotationsList.prototype.template =
    57 IriSP.Widgets.AnnotationsList.prototype.template =
    46     '<div class="Ldt-AnnotationsListWidget">'
    58     '<div class="Ldt-AnnotationsListWidget">'
       
    59     + '{{#show_audio}}<div class="Ldt-AnnotationsList-Audio"></div>{{/show_audio}}'
    47     + '<ul class="Ldt-AnnotationsList-ul">'
    60     + '<ul class="Ldt-AnnotationsList-ul">'
    48     + '</ul>'
    61     + '</ul>'
    49     + '</div>';
    62     + '</div>';
    50 
    63 
    51 IriSP.Widgets.AnnotationsList.prototype.annotationTemplate = 
    64 IriSP.Widgets.AnnotationsList.prototype.annotationTemplate = 
    69     + '</li>'
    82     + '</li>'
    70     + '{{/.}}'
    83     + '{{/.}}'
    71     + '{{/tags}}'
    84     + '{{/tags}}'
    72     + '</ul>'
    85     + '</ul>'
    73     + '{{/tags.length}}'
    86     + '{{/tags.length}}'
       
    87     + '{{#audio}}<div class="Ldt-AnnotationsList-Play" data-audio={{audio}}>{{l10n.voice_annotation}}</div>{{/audio}}'
    74     + '</li>';
    88     + '</li>';
    75 
    89 
    76 IriSP.Widgets.AnnotationsList.prototype.onSearch = function(searchString) {
    90 IriSP.Widgets.AnnotationsList.prototype.onSearch = function(searchString) {
    77     this.searchString = typeof searchString !== "undefined" ? searchString : '';
    91     this.searchString = typeof searchString !== "undefined" ? searchString : '';
    78     var _n = this.refresh(true);
    92     var _n = this.refresh(true);
   203                 begin : _annotation.begin.toString(),
   217                 begin : _annotation.begin.toString(),
   204                 end : _annotation.end.toString(),
   218                 end : _annotation.end.toString(),
   205                 thumbnail : typeof _annotation.thumbnail !== "undefined" && _annotation.thumbnail ? _annotation.thumbnail : _this.default_thumbnail,
   219                 thumbnail : typeof _annotation.thumbnail !== "undefined" && _annotation.thumbnail ? _annotation.thumbnail : _this.default_thumbnail,
   206                 url : _url,
   220                 url : _url,
   207                 tags : _annotation.getTagTexts(),
   221                 tags : _annotation.getTagTexts(),
   208                 specific_style : (typeof _bgcolor !== "undefined" ? "background-color: " + _bgcolor : "")
   222                 specific_style : (typeof _bgcolor !== "undefined" ? "background-color: " + _bgcolor : ""),
       
   223                 audio : (_this.show_audio && _annotation.audio ? _annotation.audio.href : undefined),
       
   224                 l10n: _this.l10n
   209             };
   225             };
   210             var _html = Mustache.to_html(_this.annotationTemplate, _data);
   226             var _html = Mustache.to_html(_this.annotationTemplate, _data);
   211             var _el = IriSP.jQuery(_html);
   227             var _el = IriSP.jQuery(_html);
   212             _el.mouseover(function() {
   228             _el.mouseover(function() {
   213                     _annotation.trigger("select");
   229                     _annotation.trigger("select");
   235             }
   251             }
   236         });
   252         });
   237     
   253     
   238         this.$.find('.Ldt-AnnotationsList-Tag-Li').click(function() {
   254         this.$.find('.Ldt-AnnotationsList-Tag-Li').click(function() {
   239             _this.player.trigger("search.triggeredSearch", IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,''));
   255             _this.player.trigger("search.triggeredSearch", IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,''));
   240         })
   256         });
       
   257         
       
   258         this.$.find(".Ldt-AnnotationsList-Play").click(function() {
       
   259             var _el = IriSP.jQuery(this),
       
   260                 _audiofile = _el.attr("data-audio").replace(_this.rtmp_streamer,"");
       
   261             _el.text(_this.l10n.now_playing);
       
   262             _this.jwplayer.load({
       
   263                 file: _audiofile,
       
   264                 streamer: _this.rtmp_streamer
       
   265             });
       
   266             _this.jwplayer.play(true);
       
   267             _this.media.pause();
       
   268             _this.jw_paused_media = true;
       
   269         });
   241         
   270         
   242         if(this.searchString) {
   271         if(this.searchString) {
   243             var _searchRe = IriSP.Model.regexpFromTextOrArray(this.searchString);
   272             var _searchRe = IriSP.Model.regexpFromTextOrArray(this.searchString);
   244             this.$.find(".Ldt-AnnotationsList-Title a, .Ldt-AnnotationsList-Description").each(function() {
   273             this.$.find(".Ldt-AnnotationsList-Title a, .Ldt-AnnotationsList-Description").each(function() {
   245                 var _$ = IriSP.jQuery(this);
   274                 var _$ = IriSP.jQuery(this);
   264     
   293     
   265     this.mashupMode = (this.media.elementType === "mashup");
   294     this.mashupMode = (this.media.elementType === "mashup");
   266     
   295     
   267     this.renderTemplate();
   296     this.renderTemplate();
   268     
   297     
       
   298     var _this = this;
       
   299     
       
   300     if (this.show_audio) {
       
   301         var _tmpId = "jwplayer-" + IriSP.Model.getUID();
       
   302         this.$.find(".Ldt-AnnotationsList-Audio").attr("id", _tmpId);
       
   303         this.jwplayer = jwplayer(_tmpId);
       
   304         this.jwplayer.setup({
       
   305             flashplayer: IriSP.getLib("jwPlayerSWF"),
       
   306             width: 1,
       
   307             height: 1,
       
   308             provider: "rtmp",
       
   309             events: {
       
   310                 onIdle: function() {
       
   311                     if (_this.jw_paused_media) {
       
   312                         _this.jw_paused_media = false;
       
   313                         _this.media.play();
       
   314                     }
       
   315                     _this.$.find(".Ldt-AnnotationsList-Play").text(_this.l10n.voice_annotation)
       
   316                 }
       
   317             }
       
   318         });
       
   319         this.jw_paused_media = false;
       
   320     }
       
   321     
   269     this.list_$ = this.$.find(".Ldt-AnnotationsList-ul");
   322     this.list_$ = this.$.find(".Ldt-AnnotationsList-ul");
       
   323     
   270     
   324     
   271     this.onMdpEvent("search", "onSearch");
   325     this.onMdpEvent("search", "onSearch");
   272     this.onMdpEvent("search.closed", "onSearch");
   326     this.onMdpEvent("search.closed", "onSearch");
   273     this.onMdpEvent("search.cleared", "onSearch");
   327     this.onMdpEvent("search.cleared", "onSearch");
   274     this.onMdpEvent("AnnotationsList.refresh","refresh");
   328     this.onMdpEvent("AnnotationsList.refresh", function() {
   275     
   329         if (_this.ajax_url) {
   276     var _this = this;
   330             if (_this.mashupMode) {
       
   331                 _this.ajaxMashup();
       
   332             } else {
       
   333                 _this.ajaxSource();
       
   334             }
       
   335         }
       
   336         _this.throttledRefresh();
       
   337     });
   277     
   338     
   278     if (this.ajax_url) {
   339     if (this.ajax_url) {
   279         if (this.mashupMode) {
   340         if (this.mashupMode) {
   280             this.ajaxMashup();
   341             this.ajaxMashup();
   281         } else {
   342         } else {