src/js/widgets/tooltipWidget.js
branchnew-model
changeset 875 43629caa77bc
parent 874 38b65761a7d5
child 876 03967b6ada7c
equal deleted inserted replaced
874:38b65761a7d5 875:43629caa77bc
     1 /* this widget displays a small tooltip */
       
     2 IriSP.TooltipWidget = function(Popcorn, config, Serializer) {
       
     3     IriSP.Widget.call(this, Popcorn, config, Serializer);
       
     4 };
       
     5 
       
     6 IriSP.TooltipWidget.prototype = new IriSP.Widget();
       
     7 
       
     8 IriSP.TooltipWidget.prototype.draw = function() {
       
     9     var _html = Mustache.to_html(IriSP.tooltipWidget_template),
       
    10         _this = this;
       
    11     this.$.parent().css({
       
    12         "position" : "relative"
       
    13     });
       
    14     this.$.append(_html);
       
    15     this.$tip = this.$.find(".Ldt-Tooltip");
       
    16     this.$.mouseover(function() {
       
    17         _this.$tip.hide();
       
    18     });
       
    19     this.hide();
       
    20 };
       
    21 
       
    22 IriSP.TooltipWidget.prototype.show = function(x, y, text, color) {
       
    23     
       
    24     if (typeof color !== "undefined") {
       
    25         this.$.find(".Ldt-Tooltip-Color").show().css("background-color", color);
       
    26     } else {
       
    27         this.$.find(".Ldt-Tooltip-Color").hide();
       
    28     }
       
    29     
       
    30     this.$.find(".Ldt-Tooltip-Text").html(text);
       
    31 
       
    32     this.$tip.show();
       
    33     this.$tip.css({
       
    34         "left" : Math.floor(x - this.$tip.outerWidth() / 2) + "px",
       
    35         "top" : Math.floor(y - this.$tip.outerHeight() - 5) + "px"
       
    36     });
       
    37 };
       
    38 
       
    39 IriSP.TooltipWidget.prototype.hide = function() {
       
    40     this.$tip.hide();
       
    41 };