bug fixes. enabled tags.
authorhamidouk
Mon, 06 Feb 2012 16:03:30 +0100
changeset 536 cce3b4845f22
parent 529 d2c99cb03187
child 537 8589160ac9e3
bug fixes. enabled tags.
src/ldt/ldt/static/ldt/js/LdtPlayer-release.js
--- a/src/ldt/ldt/static/ldt/js/LdtPlayer-release.js	Mon Feb 06 11:52:17 2012 +0100
+++ b/src/ldt/ldt/static/ldt/js/LdtPlayer-release.js	Mon Feb 06 16:03:30 2012 +0100
@@ -1088,7 +1088,7 @@
 };
 IriSP.SparklineWidget_template = "<div class='Ldt-sparklineWidget' style='width: {{width}}px; height: {{height}}px'>    <div class='Ldt-sparkLinePositionMarker' style='width: 0px; height: {{height}}px'></div>    <div class='Ldt-sparkLineClickOverlay' style='width: {{width}}px; height: {{height}}px'></div>    <div class='Ldt-sparkLine' style='width: {{width}}px; height: {{height}}px'>Loading</div></div>";
 IriSP.annotation_template = "{{! template for an annotation displayed in a segmentWidget }}<div title='{{divTitle}}' id='{{id}}'	class='Ldt-iri-chapter' 	style='left: {{startPixel}}px;          width: {{pxWidth}}px;          background-color:#{{hexa_color}};' 	></div>";
-IriSP.annotationWidget_template = "{{! template for the annotation widget }}<div class='Ldt-AnnotationsWidget'>  <!-- ugly div because we want to have a double border -->  <div class='Ldt-Annotation-DoubleBorder'>      <div class='Ldt-AnnotationContent'>        <div class='Ldt-AnnotationShareIcons'>         <a target='_blank' class='Ldt-fbShare' title='share on facebook'></a>         <a target='_blank' class='Ldt-TwShare' title='share on twitter'></a>         <a target='_blank'  class='Ldt-GplusShare' title='share on google+'></a>      </div>		  <div class='Ldt-SaTitle'></div>	  	<div class='Ldt-SaDescription'></div>    </div>  </div></div>";
+IriSP.annotationWidget_template = "{{! template for the annotation widget }}<div class='Ldt-AnnotationsWidget'>  <!-- ugly div because we want to have a double border -->  <div class='Ldt-Annotation-DoubleBorder'>      <div class='Ldt-AnnotationContent'>          <div class='Ldt-AnnotationShareIcons'>         <a target='_blank' class='Ldt-fbShare' title='share on facebook'></a>         <a target='_blank' class='Ldt-TwShare' title='share on twitter'></a>         <a target='_blank'  class='Ldt-GplusShare' title='share on google+'></a>        </div>        <div class='Ldt-SaTitle'></div>        <div class='Ldt-SaDescription'></div>        <div class='Ldt-SaKeywords'></div>    </div>  </div></div>";
 IriSP.annotation_loading_template = "{{! template shown while the annotation widget is loading }}<div id='Ldt-load-container'><div id='Ldt-loader'>&nbsp;</div> Chargement... </div>";
 IriSP.annotationsListWidget_template = "{{! template for the annotation list widget }}<div class='Ldt-AnnotationsListWidget'>  <!-- ugly div because we want to have a double border -->  <div class='Ldt-Annotation-DoubleBorder'>    <ul>    {{#annotations}}      <li>        {{! if the url is not present, it means that the annotation exists             in the current project }}        {{^url}}        <a href='#id={{id}}'>        {{/url}}        {{! otherwise link to url }}        {{#url}}        <a href='{{url}}#id={{id}}'>        {{/url}}          <div style='overflow: auto; margin-top: 5px; margin-bottom: 5px;'>            <div class='Ldt-AnnotationsList-Caption'>              <img src='http://i.imgur.com/aoUlC.jpg'></img>            </div>            <div class='Ldt-AnnotationsList-Duration'>{{begin}} - {{end}}</div>            <div class='Ldt-AnnotationsList-Title'>{{title}}</div>            <div class='Ldt-AnnotationsList-Description'>{{desc}}</div>          </div>        </a>      </li>    {{/annotations}}    </ul>  </div></div>";
 IriSP.arrowWidget_template = "<div class='Ldt-arrowWidget'></div>";
@@ -2431,7 +2431,10 @@
   if (IriSP.null_or_undefined(annotations))
     return;
   
+  /*
+  commented in case we wanted to discriminate against some annotation types.
   var view_types = serializer.getIds("Contributions");
+  */
   var l = [];
   
   var media = this._serializer.currentMedia()["id"];
@@ -2525,6 +2528,7 @@
     var begin = +annotation.begin / 1000;
     var end = +annotation.end / 1000;
     var duration = +this._serializer.currentMedia().meta["dc:duration"];
+    var tags = "";
     
     var title_templ = "{{title}} - ( {{begin}} - {{end}} )";
     var endstr = Mustache.to_html(title_templ, {title: title, begin: IriSP.secondsToTime(begin), end: IriSP.secondsToTime(end)});
@@ -2532,6 +2536,28 @@
     this.selector.find(".Ldt-SaTitle").text(endstr);
     this.selector.find(".Ldt-SaDescription").text(description);
     
+    
+    if (!IriSP.null_or_undefined(annotation.tags) && !IriSP.null_or_undefined(this._serializer._data.tags)) {
+      /* save the tag id and keywords in a unique structure */
+      var tag_list = {};
+      for (var i = 0; i < this._serializer._data.tags.length; i++) {
+        var id = this._serializer._data.tags[i]["id"];
+        var keyword = this._serializer._data.tags[i]["meta"]["dc:title"];
+
+        tag_list[id] = keyword;
+      }
+
+      /* then browse the list of defined tags for the current annotation */
+      for (var i = 0; i < annotation.tags.length; i++) {
+        if (tag_list.hasOwnProperty(annotation.tags[i]["id-ref"]))
+          tags += tag_list[annotation.tags[i]["id-ref"]] + ", ";
+      }
+    }
+    
+    tags = "Keywords: " + tags.slice(0, tags.length - 2);
+    
+    this.selector.find(".Ldt-SaKeywords").text(tags);
+    
     // update sharing buttons
     var defaults = IriSP.widgetsDefaults.AnnotationsWidget;
     var text = defaults.share_text;
@@ -5426,7 +5452,11 @@
   name = name.toUpperCase();
   var e;  
   e = IriSP.underscore.find(this._data["annotation-types"], 
-                                  function(entry) { return (entry["dc:title"].toUpperCase().indexOf(name) !== -1) });
+                                  function(entry) { 
+                                    if (IriSP.null_or_undefined(entry["dc:title"]))
+                                      return false;
+                                    
+                                    return (entry["dc:title"].toUpperCase().indexOf(name) !== -1) });
   
   if (typeof(e) === "undefined")
     return;