src/js/widgets/tooltipWidget.js
author veltr
Fri, 20 Apr 2012 19:13:11 +0200
branchnew-model
changeset 874 38b65761a7d5
parent 830 18ca612e9ff0
permissions -rw-r--r--
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split

/* this widget displays a small tooltip */
IriSP.TooltipWidget = function(Popcorn, config, Serializer) {
    IriSP.Widget.call(this, Popcorn, config, Serializer);
};

IriSP.TooltipWidget.prototype = new IriSP.Widget();

IriSP.TooltipWidget.prototype.draw = function() {
    var _html = Mustache.to_html(IriSP.tooltipWidget_template),
        _this = this;
    this.$.parent().css({
        "position" : "relative"
    });
    this.$.append(_html);
    this.$tip = this.$.find(".Ldt-Tooltip");
    this.$.mouseover(function() {
        _this.$tip.hide();
    });
    this.hide();
};

IriSP.TooltipWidget.prototype.show = function(x, y, text, color) {
    
    if (typeof color !== "undefined") {
        this.$.find(".Ldt-Tooltip-Color").show().css("background-color", color);
    } else {
        this.$.find(".Ldt-Tooltip-Color").hide();
    }
    
    this.$.find(".Ldt-Tooltip-Text").html(text);

    this.$tip.show();
    this.$tip.css({
        "left" : Math.floor(x - this.$tip.outerWidth() / 2) + "px",
        "top" : Math.floor(y - this.$tip.outerHeight() - 5) + "px"
    });
};

IriSP.TooltipWidget.prototype.hide = function() {
    this.$tip.hide();
};