Improvements on traces
authorveltr
Mon, 28 Jan 2013 18:17:26 +0100
changeset 990 6a90c96f0b4c
parent 989 458e9754d1cf
child 991 2b036bd80f6d
Improvements on traces
src/widgets/Polemic.js
src/widgets/Segments.js
src/widgets/Trace.js
--- a/src/widgets/Polemic.js	Fri Jan 25 18:47:43 2013 +0100
+++ b/src/widgets/Polemic.js	Mon Jan 28 18:17:26 2013 +0100
@@ -113,7 +113,7 @@
             
             function displayAnnotation(_elx, _ely, _pol, _col, _annotation) {
                 var _html = Mustache.to_html(
-                    '<div class="Ldt-Polemic-TweetDiv Ldt-TraceMe" trace-info="annotation-id:{{id}}, media-id={{media_id}}, polemic={{polemic}}" polemic-color="{{color}}"'
+                    '<div class="Ldt-Polemic-TweetDiv Ldt-TraceMe" trace-info="annotation-id:{{id}}, media-id:{{media_id}}, polemic:{{polemic}}, time:{{time}}" polemic-color="{{color}}"'
                     + ' tweet-title="{{title}}" annotation-id="{{id}}" style="width: {{width}}px; height: {{height}}px; top: {{top}}px; left: {{left}}px; background: {{color}}"></div>',
                 {
                     id: _annotation.id,
@@ -124,7 +124,8 @@
                     color: _col,
                     width: (_this.element_width-1),
                     height: _this.element_height,
-                    title: _annotation.title
+                    title: _annotation.title,
+                    time: _annotation.begin.toString()
                 });
                 var _el = IriSP.jQuery(_html);
                 _el.mouseover(function() {
--- a/src/widgets/Segments.js	Fri Jan 25 18:47:43 2013 +0100
+++ b/src/widgets/Segments.js	Mon Jan 28 18:17:26 2013 +0100
@@ -22,7 +22,7 @@
     + '<div class="Ldt-Segments-Tooltip"></div>';
 
 IriSP.Widgets.Segments.prototype.annotationTemplate =
-    '<div class="Ldt-Segments-Segment Ldt-TraceMe" trace-info="segment-id:{{id}}, media-id:{{media_id}}" segment-text="{{text}}"'
+    '<div class="Ldt-Segments-Segment Ldt-TraceMe" trace-info="segment-id:{{id}}, media-id:{{media_id}}, from:{{from}}, to:{{to}}" segment-text="{{text}}"'
     + 'style="top:{{top}}px; height:{{height}}px; left:{{left}}px; width:{{width}}px; background:{{medcolor}}" data-base-color="{{color}}" data-low-color="{{lowcolor}}" data-medium-color="{{medcolor}}"></div>'
 
 
@@ -83,7 +83,9 @@
             top: _top,
             height: _this.line_height - 1,
             id : _annotation.id,
-            media_id : _annotation.getMedia().id
+            media_id : _annotation.getMedia().id,
+            from: _annotation.begin.toString(),
+            to: _annotation.end.toString()
         };
         var _html = Mustache.to_html(_this.annotationTemplate, _data),
             _el = IriSP.jQuery(_html);
--- a/src/widgets/Trace.js	Fri Jan 25 18:47:43 2013 +0100
+++ b/src/widgets/Trace.js	Mon Jan 28 18:17:26 2013 +0100
@@ -29,6 +29,10 @@
         "play" : 0,
         "pause" : 0,
         "timeupdate" : 10000
+    },
+    _annlisteners = {
+        search: 0,
+        "search-cleared": 0
     };
     IriSP._(_medialisteners).each(function(_ms, _listener) {
         var _f = function(_arg) {
@@ -39,6 +43,16 @@
         }
         _this.media.on(_listener, _f);
     });
+    var _annotations = this.source.getAnnotations();
+    IriSP._(_annlisteners).each(function(_ms, _listener) {
+        var _f = function(_arg) {
+            _this.eventHandler(_listener, _arg);
+        }
+        if (_ms) {
+            _f = IriSP._.throttle(_f, _ms);
+        }
+        _annotations.on(_listener, _f);
+    });
     
     if (!this.tracer) {
     
@@ -51,6 +65,8 @@
     
     }
     
+    
+    
     this.tracer.trace("TraceWidgetInit", {});
     
     this.mouseLocation = '';
@@ -60,8 +76,6 @@
         var _widget = _target.attr("widget-type") || _target.parents(".Ldt-Widget").attr("widget-type"),
             _data = {
                 "type": _e.type,
-                "x": _e.clientX,
-                "y": _e.clientY,
                 "widget": _widget
             },
             _targetEl = _target[0],