src/js/widgets/segmentsWidget.js
branchpopcorn-port
changeset 336 8da13562cfea
parent 334 e20f97514d44
child 353 21f3a1d501eb
equal deleted inserted replaced
335:54c0686efd85 336:8da13562cfea
    80         {"divTitle" : divTitle, "id" : id, "startPourcent" : startPourcent,
    80         {"divTitle" : divTitle, "id" : id, "startPourcent" : startPourcent,
    81         "endPourcent" : endPourcent, "hexa_color" : IriSP.DEC_HEXA_COLOR(color),
    81         "endPourcent" : endPourcent, "hexa_color" : IriSP.DEC_HEXA_COLOR(color),
    82         "seekPlace" : Math.round(begin/1000)});
    82         "seekPlace" : Math.round(begin/1000)});
    83 
    83 
    84 
    84 
    85     var toolTipTemplate = Mustache.to_html(IriSP.tooltip_template,
       
    86           {"title" : divTitle, "begin" : begin, "end" : end,
       
    87           "description": annotation.content.description});
       
    88 
       
    89     this.selector.append(annotationTemplate);
    85     this.selector.append(annotationTemplate);
    90 
    86 
    91     IriSP.jQuery("#" + id).tooltip({ effect: 'slide'});
    87 //    IriSP.jQuery("#" + id).tooltip({ effect: 'slide'});
    92 
    88 
    93     IriSP.jQuery("#" + id).fadeTo(0, 0.3);
    89     IriSP.jQuery("#" + id).fadeTo(0, 0.3);
    94 
    90 
    95     IriSP.jQuery("#" + id).mouseover(function() {
    91     IriSP.jQuery("#" + id).mouseover(
    96       IriSP.jQuery(this).animate({opacity: 0.6}, 5);
    92     /* we wrap the handler in another function because js's scoping
    97     }).mouseout(function(){
    93        rules are function-based - otherwise, the internal vars like
       
    94        divTitle are preserved but they are looked-up from the draw
       
    95        method scope, so after that the loop is run, so they're not
       
    96        preserved */
       
    97     (function(divTitle) { 
       
    98      return function(event) {
       
    99           IriSP.jQuery(this).animate({opacity: 0.6}, 5);
       
   100           var offset = IriSP.jQuery(this).offset();
       
   101           var correction = IriSP.jQuery(this).outerWidth() / 2;
       
   102 
       
   103           var offset_x = offset.left + correction - 106;
       
   104           if (offset_x < 0)
       
   105             offset_x = 0;
       
   106 
       
   107           self.TooltipWidget.show(divTitle, color, offset_x, event.pageY - 160);
       
   108     } })(divTitle)).mouseout(function(){
    98       IriSP.jQuery(this).animate({opacity: 0.3}, 5);
   109       IriSP.jQuery(this).animate({opacity: 0.3}, 5);
       
   110       self.TooltipWidget.hide();
    99     });
   111     });
   100 
   112 
   101     IriSP.jQuery("#" + id).click(function(_this, annotation) {
   113     IriSP.jQuery("#" + id).click(function(_this, annotation) {
   102                                     return function() { _this.clickHandler(annotation)};
   114                                     return function() { _this.clickHandler(annotation)};
   103                                  }(this, annotation));
   115                                  }(this, annotation));