src/widgets/AnnotationsList.js
branchnew-model
changeset 924 64c2eaafe5e2
parent 923 b3ee7d1b472a
child 925 28efc97b5d78
equal deleted inserted replaced
923:b3ee7d1b472a 924:64c2eaafe5e2
    25      */
    25      */
    26     foreign_url : "",
    26     foreign_url : "",
    27     annotation_type : false,
    27     annotation_type : false,
    28     refresh_interval : 0,
    28     refresh_interval : 0,
    29     limit_count : 10,
    29     limit_count : 10,
    30     newest_first : false
    30     newest_first : false,
       
    31     polemics : [{
       
    32         keyword: "++",
       
    33         background_color: "#c9ecc6"
       
    34     },{
       
    35         keyword: "--",
       
    36         background_color: "#f9c5c6"
       
    37     },{
       
    38         keyword: "??",
       
    39         background_color: "#cec5f9"
       
    40     },{
       
    41         keyword: "==",
       
    42         background_color: "#f9f4c6"
       
    43     }]
    31 };
    44 };
    32 
    45 
    33 IriSP.Widgets.AnnotationsList.prototype.template =
    46 IriSP.Widgets.AnnotationsList.prototype.template =
    34     '<div class="Ldt-AnnotationsListWidget">'
    47     '<div class="Ldt-AnnotationsListWidget">'
    35     + '<ul class="Ldt-AnnotationsList-ul">'
    48     + '<ul class="Ldt-AnnotationsList-ul">'
    36     + '{{#annotations}}'
    49     + '{{#annotations}}'
    37     + '<li class="Ldt-AnnotationsList-li Ldt-TraceMe" trace-info="annotation-id:{{id}}">'
    50     + '<li class="Ldt-AnnotationsList-li Ldt-TraceMe" trace-info="annotation-id:{{id}}" style="{{specific_style}}">'
    38     + '<div class="Ldt-AnnotationsList-ThumbContainer">'
    51     + '<div class="Ldt-AnnotationsList-ThumbContainer">'
    39     + '<a href="{{url}}">'
    52     + '<a href="{{url}}">'
    40     + '<img class="Ldt-AnnotationsList-Thumbnail" src="{{thumbnail}}" />'
    53     + '<img class="Ldt-AnnotationsList-Thumbnail" src="{{thumbnail}}" />'
    41     + '</a>'
    54     + '</a>'
    42     + '</div>'
    55     + '</div>'
   173                                 }
   186                                 }
   174                             )
   187                             )
   175                             : '#id=' + _annotation.id
   188                             : '#id=' + _annotation.id
   176                             )
   189                             )
   177                     );
   190                     );
   178                     var _title = _annotation.title.replace(_annotation.description,''),
   191                     var _title = (_annotation.title || "").replace(_annotation.description,''),
   179                         _description = _annotation.description;
   192                         _description = _annotation.description;
   180                     if (!_annotation.title) {
   193                     if (!_annotation.title) {
   181                         _title = _annotation.creator;
   194                         _title = _annotation.creator;
   182                     }
   195                     }
   183                     if (!_annotation.description && _annotation.creator) {
   196                     if (!_annotation.description && _annotation.creator) {
   184                         _description = _annotation.title;
   197                         _description = _annotation.title;
   185                         _title = _annotation.creator;
   198                         _title = _annotation.creator;
   186                     }
   199                     }
       
   200                     var _bgcolor;
       
   201                     IriSP._(_this.polemics).each(function(_polemic) {
       
   202                         var _rgxp = IriSP.Model.regexpFromTextOrArray(_polemic.keyword);
       
   203                         if (_rgxp.test(_title + " " + _description)) {
       
   204                             _bgcolor = _polemic.background_color;
       
   205                         }
       
   206                     });
   187                     var _res = {
   207                     var _res = {
   188                         id : _annotation.id,
   208                         id : _annotation.id,
   189                         title : _title,
   209                         title : _title,
   190                         description : _description,
   210                         description : _description,
   191                         begin : _annotation.begin.toString(),
   211                         begin : _annotation.begin.toString(),
   192                         end : _annotation.end.toString(),
   212                         end : _annotation.end.toString(),
   193                         thumbnail : typeof _annotation.thumbnail !== "undefined" && _annotation.thumbnail ? _annotation.thumbnail : _this.default_thumbnail,
   213                         thumbnail : typeof _annotation.thumbnail !== "undefined" && _annotation.thumbnail ? _annotation.thumbnail : _this.default_thumbnail,
   194                         url : _url,
   214                         url : _url,
   195                         tags : _annotation.getTagTexts()
   215                         tags : _annotation.getTagTexts(),
       
   216                         specific_style : (typeof _bgcolor !== "undefined" ? "background: " + _bgcolor : "")
   196                     }
   217                     }
   197                     return _res;
   218                     return _res;
   198             }),
   219             }),
   199             _html = Mustache.to_html(
   220             _html = Mustache.to_html(
   200                 this.template,
   221                 this.template,