src/js/widgets/tooltipWidget.js
branchnew-model
changeset 874 38b65761a7d5
parent 830 18ca612e9ff0
--- a/src/js/widgets/tooltipWidget.js	Thu Apr 19 19:20:41 2012 +0200
+++ b/src/js/widgets/tooltipWidget.js	Fri Apr 20 19:13:11 2012 +0200
@@ -1,57 +1,41 @@
 /* this widget displays a small tooltip */
 IriSP.TooltipWidget = function(Popcorn, config, Serializer) {
-  IriSP.Widget.call(this, Popcorn, config, Serializer);
-  this._shown = false;
-  this._displayedText = "";
-  this._hideTimeout = -1;
+    IriSP.Widget.call(this, Popcorn, config, Serializer);
 };
 
-
 IriSP.TooltipWidget.prototype = new IriSP.Widget();
 
 IriSP.TooltipWidget.prototype.draw = function() {
-  var templ = Mustache.to_html(IriSP.tooltipWidget_template);
-  // position the widget absolutely relative to document. --- NOOOO !!!!
-  this.selector.css({
-      "position": "absolute",
-      "top": 0,
-      "left": 0
-  });
-  this.selector.parent().css({
-      "position": "relative"
-  });
-  this.selector.append(templ);
-  var _this = this;
-  this.selector.mouseover(function() {
-      _this.hide();
-  });
-  this.hide();
-
-};
-
-IriSP.TooltipWidget.prototype.clear = function() {
-	this.selector.find(".tiptext").html("");
+    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(text, color, x, y) {
-
-  if (this._displayedText == text && this._shown)
-    return;
+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.selector.find(".tipcolor").css("background-color", color);
-  this._displayedText = text;
-  this.selector.find(".tiptext").html(text);
-  
-  var _tip = this.selector.find(".tip");
-  _tip.show();
-  _tip.css({
-      "left": Math.floor(x - _tip.outerWidth() / 2)+"px",
-      "top": Math.floor(y - _tip.outerHeight())+"px"
-  });
-  this._shown = true;
+    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.selector.find(".tip").hide();
-  this._shown = false;  
-};
\ No newline at end of file
+IriSP.TooltipWidget.prototype.hide = function() {
+    this.$tip.hide();
+};