src/widgets/AnnotationsList.js
changeset 993 a7efd386872a
parent 988 eefd336335f9
child 994 d18d6b9e1078
equal deleted inserted replaced
992:566b590aaf8f 993:a7efd386872a
    63     + '</div>';
    63     + '</div>';
    64 
    64 
    65 IriSP.Widgets.AnnotationsList.prototype.annotationTemplate = 
    65 IriSP.Widgets.AnnotationsList.prototype.annotationTemplate = 
    66     '<li class="Ldt-AnnotationsList-li Ldt-TraceMe" trace-info="annotation-id:{{id}}, media-id:{{media_id}}" style="{{specific_style}}">'
    66     '<li class="Ldt-AnnotationsList-li Ldt-TraceMe" trace-info="annotation-id:{{id}}, media-id:{{media_id}}" style="{{specific_style}}">'
    67     + '<div class="Ldt-AnnotationsList-ThumbContainer">'
    67     + '<div class="Ldt-AnnotationsList-ThumbContainer">'
    68     + '<a href="{{url}}">'
    68     + '<a href="{{url}}" draggable="true">'
    69     + '<img class="Ldt-AnnotationsList-Thumbnail" src="{{thumbnail}}" />'
    69     + '<img class="Ldt-AnnotationsList-Thumbnail" src="{{thumbnail}}" />'
    70     + '</a>'
    70     + '</a>'
    71     + '</div>'
    71     + '</div>'
    72     + '<div class="Ldt-AnnotationsList-Duration">{{begin}} - {{end}}</div>'
    72     + '<div class="Ldt-AnnotationsList-Duration">{{begin}} - {{end}}</div>'
    73     + '<h3 class="Ldt-AnnotationsList-Title">'
    73     + '<h3 class="Ldt-AnnotationsList-Title" draggable="true">'
    74     + '<a href="{{url}}">{{{title}}}</a>'
    74     + '<a href="{{url}}">{{{htitle}}}</a>'
    75     + '</h3>'
    75     + '</h3>'
    76     + '<p class="Ldt-AnnotationsList-Description">{{{description}}}</p>'
    76     + '<p class="Ldt-AnnotationsList-Description">{{{hdescription}}}</p>'
    77     + '{{#tags.length}}'
    77     + '{{#tags.length}}'
    78     + '<ul class="Ldt-AnnotationsList-Tags">'
    78     + '<ul class="Ldt-AnnotationsList-Tags">'
    79     + '{{#tags}}'
    79     + '{{#tags}}'
    80     + '{{#.}}'
    80     + '{{#.}}'
    81     + '<li class="Ldt-AnnotationsList-Tag-Li">'
    81     + '<li class="Ldt-AnnotationsList-Tag-Li">'
   178                             media : _annotation.media.id,
   178                             media : _annotation.media.id,
   179                             annotation : _annotation.id,
   179                             annotation : _annotation.id,
   180                             annotationType : _annotation.annotationType.id
   180                             annotationType : _annotation.annotationType.id
   181                         }
   181                         }
   182                     )
   182                     )
   183                     : '#id=' + _annotation.id
   183                     : document.location.href.replace(/#.*$/,'') + '#id=' + _annotation.id
   184                     )
   184                     )
   185             );
   185             );
   186             var _title = (_annotation.title || "").replace(_annotation.description,''),
   186             var _title = (_annotation.title || "").replace(_annotation.description,''),
   187                 _description = _annotation.description;
   187                 _description = _annotation.description,
       
   188                 _thumbnail = (typeof _annotation.thumbnail !== "undefined" && _annotation.thumbnail ? _annotation.thumbnail : _this.default_thumbnail);
   188             if (!_annotation.title) {
   189             if (!_annotation.title) {
   189                 _title = _annotation.creator;
   190                 _title = _annotation.creator;
   190             }
   191             }
   191             if (!_annotation.description && _annotation.creator) {
   192             if (!_annotation.description && _annotation.creator) {
   192                 _description = _annotation.title;
   193                 _description = _annotation.title;
   200                 }
   201                 }
   201             });
   202             });
   202             var _data = {
   203             var _data = {
   203                 id : _annotation.id,
   204                 id : _annotation.id,
   204                 media_id : _annotation.getMedia().id,
   205                 media_id : _annotation.getMedia().id,
   205                 title : IriSP.textFieldHtml(_title),
   206                 htitle : IriSP.textFieldHtml(_title),
   206                 description : IriSP.textFieldHtml(_description),
   207                 hdescription : IriSP.textFieldHtml(_description),
   207                 begin : _annotation.begin.toString(),
   208                 begin : _annotation.begin.toString(),
   208                 end : _annotation.end.toString(),
   209                 end : _annotation.end.toString(),
   209                 thumbnail : typeof _annotation.thumbnail !== "undefined" && _annotation.thumbnail ? _annotation.thumbnail : _this.default_thumbnail,
   210                 thumbnail : _thumbnail,
   210                 url : _url,
   211                 url : _url,
   211                 tags : _annotation.getTagTexts(),
   212                 tags : _annotation.getTagTexts(),
   212                 specific_style : (typeof _bgcolor !== "undefined" ? "background-color: " + _bgcolor : ""),
   213                 specific_style : (typeof _bgcolor !== "undefined" ? "background-color: " + _bgcolor : ""),
   213                 audio : (_this.show_audio && _annotation.audio && _annotation.audio.href && _annotation.audio.href != "null" ? _annotation.audio.href : undefined),
   214                 audio : (_this.show_audio && _annotation.audio && _annotation.audio.href && _annotation.audio.href != "null" ? _annotation.audio.href : undefined),
   214                 l10n: _this.l10n
   215                 l10n: _this.l10n
   227                 })
   228                 })
   228                 .mouseout(function() {
   229                 .mouseout(function() {
   229                     _annotation.trigger("unselect");
   230                     _annotation.trigger("unselect");
   230                 })
   231                 })
   231                 .appendTo(_this.list_$);
   232                 .appendTo(_this.list_$);
       
   233             _el.find("[draggable]").on("dragstart", function(e) {
       
   234 	        	e.originalEvent.dataTransfer.setData("text/x-iri-title",_title);
       
   235 	        	e.originalEvent.dataTransfer.setData("text/x-iri-description",_description);
       
   236 	        	e.originalEvent.dataTransfer.setData("text/x-iri-uri",_url);
       
   237 	        	e.originalEvent.dataTransfer.setData("text/x-iri-image",_thumbnail);
       
   238 	        });
   232             _el.on("remove", function() {
   239             _el.on("remove", function() {
   233                 _annotation.off("select", _onselect);
   240                 _annotation.off("select", _onselect);
   234                 _annotation.off("unselect", _onunselect);
   241                 _annotation.off("unselect", _onunselect);
   235             });
   242             });
   236             _annotation.on("select", _onselect);
   243             _annotation.on("select", _onselect);