highlight a tweet if it corresponds to a hashtag link. popcorn-port
authorhamidouk
Tue, 17 Jan 2012 14:49:43 +0100
branchpopcorn-port
changeset 648 431b3495f958
parent 647 2984fbbcbe35
child 649 dc5109512123
highlight a tweet if it corresponds to a hashtag link.
src/js/widgets/polemicWidget.js
--- a/src/js/widgets/polemicWidget.js	Tue Jan 17 14:48:37 2012 +0100
+++ b/src/js/widgets/polemicWidget.js	Tue Jan 17 14:49:43 2012 +0100
@@ -160,6 +160,7 @@
       this._Popcorn.listen("IriSP.search.cleared", IriSP.wrap(this, this.searchFieldClearedHandler));
       this.selector.mouseleave(IriSP.wrap(this, function() { self.TooltipWidget.hide.call(self.TooltipWidget); }));
       this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.sliderUpdater));
+      this._Popcorn.listen("IriSP.Mediafragment.showAnnotation", IriSP.wrap(this, this.showAnnotation));
       
       for(var i = 0; i < json.annotations.length; i++) {
         var item = json.annotations[i];        
@@ -312,11 +313,15 @@
                   
                   addEheight += TweetHeight;
                   
+                  /* stick a lot of things into e because that's the easiest way
+                     to do it */
                   e.color = colors[j];
                   e.time = frames[i].mytweetsID[k].timeframe;
                   e.title = frames[i].mytweetsID[k].title;
                   e.id = frames[i].mytweetsID[k].cinecast_id;
-                  
+                  var pos = IriSP.jQuery(e.node).offset();                  
+                  e.x = pos.left;
+                  e.y = pos.top;
                   this.svgElements[e.id] = e;
                   
                   IriSP.jQuery(e.node).mouseenter(function(element) { return function (event) {                        
@@ -431,3 +436,9 @@
  
 };
    
+IriSP.PolemicWidget.prototype.showAnnotation = function(id) {
+  if (this.svgElements.hasOwnProperty(id)) {
+    var e = this.svgElements[id];
+    this.TooltipWidget.show(e.title, e.attr("fill"), e.x - 103, e.y - 160);
+  }
+};