front_idill/src/player/metadataplayer/Tooltip.js
author bastiena
Mon, 24 Sep 2012 15:19:49 +0200
changeset 123 57a65edde708
parent 31 2c7fc855eba8
permissions -rw-r--r--
Front IDILL: non tmpl config files removed.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
     1
/* this widget displays a small tooltip */
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
     2
IriSP.Widgets.Tooltip = function(Popcorn, config, Serializer) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
     3
    IriSP.Widgets.Widget.call(this, Popcorn, config, Serializer);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
     4
};
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
     5
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
     6
IriSP.Widgets.Tooltip.prototype = new IriSP.Widgets.Widget();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
     7
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
     8
IriSP.Widgets.Tooltip.prototype.template = '<div class="Ldt-Tooltip"><div class="Ldt-Tooltip-Color"></div><div class="Ldt-Tooltip-Text"></div></div>';
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
     9
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    10
IriSP.Widgets.Tooltip.prototype.draw = function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    11
    _this = this;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    12
    this.$.html(this.template);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    13
    this.$.parent().css({
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    14
        "position" : "relative"
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    15
    });
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    16
    this.$tip = this.$.find(".Ldt-Tooltip");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    17
    this.$.mouseover(function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    18
        _this.$tip.hide();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    19
    });
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    20
    this.hide();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    21
};
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    22
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    23
IriSP.Widgets.Tooltip.prototype.show = function(x, y, text, color) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    24
    
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    25
    if (typeof color !== "undefined") {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    26
        this.$.find(".Ldt-Tooltip-Color").show().css("background-color", color);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    27
    } else {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    28
        this.$.find(".Ldt-Tooltip-Color").hide();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    29
    }
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    30
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    31
    this.$.find(".Ldt-Tooltip-Text").html(text);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    32
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    33
    this.$tip.show();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    34
    this.$tip.css({
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    35
        "left" : Math.floor(x - this.$tip.outerWidth() / 2) + "px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    36
        "top" : Math.floor(y - this.$tip.outerHeight()) + "px"
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    37
    });
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    38
};
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    39
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    40
IriSP.Widgets.Tooltip.prototype.hide = function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    41
    this.$tip.hide();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    42
};