src/js/widgets/polemicWidget.js
branchpopcorn-port
changeset 658 cfaf0986d22b
parent 648 431b3495f958
child 820 7968346b9689
equal deleted inserted replaced
657:138160f52f14 658:cfaf0986d22b
   158       this._Popcorn.listen("IriSP.search", IriSP.wrap(this, function(searchString) { this.searchHandler(searchString); }));
   158       this._Popcorn.listen("IriSP.search", IriSP.wrap(this, function(searchString) { this.searchHandler(searchString); }));
   159       this._Popcorn.listen("IriSP.search.closed", IriSP.wrap(this, this.searchFieldClosedHandler));
   159       this._Popcorn.listen("IriSP.search.closed", IriSP.wrap(this, this.searchFieldClosedHandler));
   160       this._Popcorn.listen("IriSP.search.cleared", IriSP.wrap(this, this.searchFieldClearedHandler));
   160       this._Popcorn.listen("IriSP.search.cleared", IriSP.wrap(this, this.searchFieldClearedHandler));
   161       this.selector.mouseleave(IriSP.wrap(this, function() { self.TooltipWidget.hide.call(self.TooltipWidget); }));
   161       this.selector.mouseleave(IriSP.wrap(this, function() { self.TooltipWidget.hide.call(self.TooltipWidget); }));
   162       this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.sliderUpdater));
   162       this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.sliderUpdater));
       
   163       this._Popcorn.listen("IriSP.Mediafragment.showAnnotation", IriSP.wrap(this, this.showAnnotation));
   163       
   164       
   164       for(var i = 0; i < json.annotations.length; i++) {
   165       for(var i = 0; i < json.annotations.length; i++) {
   165         var item = json.annotations[i];        
   166         var item = json.annotations[i];        
   166         var MyTime  = Math.floor(item.begin/duration*lineSize);
   167         var MyTime  = Math.floor(item.begin/duration*lineSize);
   167         var Myframe = Math.floor(MyTime/lineSize*frameLength);
   168         var Myframe = Math.floor(MyTime/lineSize*frameLength);
   310                   var e = this.paper.rect(x, y, frameSize - margin, TweetHeight /* height */)
   311                   var e = this.paper.rect(x, y, frameSize - margin, TweetHeight /* height */)
   311                                     .attr({stroke:"#00","stroke-width":0.1,  fill: colors[j]});  
   312                                     .attr({stroke:"#00","stroke-width":0.1,  fill: colors[j]});  
   312                   
   313                   
   313                   addEheight += TweetHeight;
   314                   addEheight += TweetHeight;
   314                   
   315                   
       
   316                   /* stick a lot of things into e because that's the easiest way
       
   317                      to do it */
   315                   e.color = colors[j];
   318                   e.color = colors[j];
   316                   e.time = frames[i].mytweetsID[k].timeframe;
   319                   e.time = frames[i].mytweetsID[k].timeframe;
   317                   e.title = frames[i].mytweetsID[k].title;
   320                   e.title = frames[i].mytweetsID[k].title;
   318                   e.id = frames[i].mytweetsID[k].cinecast_id;
   321                   e.id = frames[i].mytweetsID[k].cinecast_id;
   319                   
   322                   var pos = IriSP.jQuery(e.node).offset();                  
       
   323                   e.x = pos.left;
       
   324                   e.y = pos.top;
   320                   this.svgElements[e.id] = e;
   325                   this.svgElements[e.id] = e;
   321                   
   326                   
   322                   IriSP.jQuery(e.node).mouseenter(function(element) { return function (event) {                        
   327                   IriSP.jQuery(e.node).mouseenter(function(element) { return function (event) {                        
   323                         // event.clientX and event.clientY are to raphael what event.pageX and pageY are to jquery.                        
   328                         // event.clientX and event.clientY are to raphael what event.pageX and pageY are to jquery.                        
   324                         self.TooltipWidget.show.call(self.TooltipWidget, element.title, element.attr("fill"), event.pageX - 106, event.pageY - 160);
   329                         self.TooltipWidget.show.call(self.TooltipWidget, element.title, element.attr("fill"), event.pageX - 106, event.pageY - 160);
   429     e.attr({fill: e.color, opacity: 1});
   434     e.attr({fill: e.color, opacity: 1});
   430   }
   435   }
   431  
   436  
   432 };
   437 };
   433    
   438    
       
   439 IriSP.PolemicWidget.prototype.showAnnotation = function(id) {
       
   440   if (this.svgElements.hasOwnProperty(id)) {
       
   441     var e = this.svgElements[id];
       
   442     this.TooltipWidget.show(e.title, e.attr("fill"), e.x - 103, e.y - 160);
       
   443   }
       
   444 };