src/widgets/Tooltip.js
changeset 1021 7253d4d06f0d
parent 987 7b65bf78873a
child 1072 ac1eacb3aa33
--- a/src/widgets/Tooltip.js	Fri Oct 25 01:32:13 2013 +0200
+++ b/src/widgets/Tooltip.js	Thu Jan 02 16:54:22 2014 +0100
@@ -28,7 +28,7 @@
     this.$tip = this.$.find(".Ldt-Tooltip-Tip");
     this.$sw = this.$.find(".Ldt-Tooltip-Border-SW");
     this.$se = this.$.find(".Ldt-Tooltip-Border-SE");
-    this.__halfWidth = Math.floor(this.$.find(".Ldt-Tooltip-Main").width()/2);
+    this.__halfWidth = Math.floor(( this.$.find(".Ldt-Tooltip-Main").width() || 192)/2);
     this.__borderWidth = this.$.find(".Ldt-Tooltip-Border-Left").width();
     this.__tipDelta = this.__halfWidth - Math.floor(this.$tip.width()/2);
     this.__maxShift = this.__tipDelta - this.__borderWidth;
@@ -41,7 +41,21 @@
 IriSP.Widgets.Tooltip.prototype.show = function(x, y, text, color) {
     
     if (typeof color !== "undefined") {
-        this.$.find(".Ldt-Tooltip-Color").show().css("background-color", color);
+    	// one color or array of colors
+    	if (typeof color === "string") {
+    		this.$.find(".Ldt-Tooltip-Color").html("");
+    		this.$.find(".Ldt-Tooltip-Color").show().css("background-color", color);
+    		this.$.find(".Ldt-Tooltip-Color").show().css("height", "");
+    	}
+    	else{
+    		var d = this.$.find(".Ldt-Tooltip-Color");
+    		d.html("");
+    		d.show();
+    		for(var i=0; i<color.length; i++){
+    			d.append('<div style="float: left; height: 10px; width: 10px; background-color: ' + color[i] + '">')
+    		}
+    		this.$.find(".Ldt-Tooltip-Color").css("height", (color.length * 10) + "px");
+    	}
     } else {
         this.$.find(".Ldt-Tooltip-Color").hide();
     }