src/widgets/Tooltip.js
changeset 1021 7253d4d06f0d
parent 987 7b65bf78873a
child 1072 ac1eacb3aa33
equal deleted inserted replaced
1018:de1e7cf6bfc4 1021:7253d4d06f0d
    26     });
    26     });
    27     this.$tooltip = this.$.find(".Ldt-Tooltip");
    27     this.$tooltip = this.$.find(".Ldt-Tooltip");
    28     this.$tip = this.$.find(".Ldt-Tooltip-Tip");
    28     this.$tip = this.$.find(".Ldt-Tooltip-Tip");
    29     this.$sw = this.$.find(".Ldt-Tooltip-Border-SW");
    29     this.$sw = this.$.find(".Ldt-Tooltip-Border-SW");
    30     this.$se = this.$.find(".Ldt-Tooltip-Border-SE");
    30     this.$se = this.$.find(".Ldt-Tooltip-Border-SE");
    31     this.__halfWidth = Math.floor(this.$.find(".Ldt-Tooltip-Main").width()/2);
    31     this.__halfWidth = Math.floor(( this.$.find(".Ldt-Tooltip-Main").width() || 192)/2);
    32     this.__borderWidth = this.$.find(".Ldt-Tooltip-Border-Left").width();
    32     this.__borderWidth = this.$.find(".Ldt-Tooltip-Border-Left").width();
    33     this.__tipDelta = this.__halfWidth - Math.floor(this.$tip.width()/2);
    33     this.__tipDelta = this.__halfWidth - Math.floor(this.$tip.width()/2);
    34     this.__maxShift = this.__tipDelta - this.__borderWidth;
    34     this.__maxShift = this.__tipDelta - this.__borderWidth;
    35     this.$.mouseover(function() {
    35     this.$.mouseover(function() {
    36         _this.$tooltip.hide();
    36         _this.$tooltip.hide();
    39 };
    39 };
    40 
    40 
    41 IriSP.Widgets.Tooltip.prototype.show = function(x, y, text, color) {
    41 IriSP.Widgets.Tooltip.prototype.show = function(x, y, text, color) {
    42     
    42     
    43     if (typeof color !== "undefined") {
    43     if (typeof color !== "undefined") {
    44         this.$.find(".Ldt-Tooltip-Color").show().css("background-color", color);
    44     	// one color or array of colors
       
    45     	if (typeof color === "string") {
       
    46     		this.$.find(".Ldt-Tooltip-Color").html("");
       
    47     		this.$.find(".Ldt-Tooltip-Color").show().css("background-color", color);
       
    48     		this.$.find(".Ldt-Tooltip-Color").show().css("height", "");
       
    49     	}
       
    50     	else{
       
    51     		var d = this.$.find(".Ldt-Tooltip-Color");
       
    52     		d.html("");
       
    53     		d.show();
       
    54     		for(var i=0; i<color.length; i++){
       
    55     			d.append('<div style="float: left; height: 10px; width: 10px; background-color: ' + color[i] + '">')
       
    56     		}
       
    57     		this.$.find(".Ldt-Tooltip-Color").css("height", (color.length * 10) + "px");
       
    58     	}
    45     } else {
    59     } else {
    46         this.$.find(".Ldt-Tooltip-Color").hide();
    60         this.$.find(".Ldt-Tooltip-Color").hide();
    47     }
    61     }
    48 
    62 
    49     this.$.find(".Ldt-Tooltip-Text").html(text);
    63     this.$.find(".Ldt-Tooltip-Text").html(text);