2 IriSP.TooltipWidget = function(Popcorn, config, Serializer) { |
2 IriSP.TooltipWidget = function(Popcorn, config, Serializer) { |
3 IriSP.Widget.call(this, Popcorn, config, Serializer); |
3 IriSP.Widget.call(this, Popcorn, config, Serializer); |
4 this._shown = false; |
4 this._shown = false; |
5 this._displayedText = ""; |
5 this._displayedText = ""; |
6 this._hideTimeout = -1; |
6 this._hideTimeout = -1; |
|
7 console.log(config.container); |
7 }; |
8 }; |
8 |
9 |
9 |
10 |
10 IriSP.TooltipWidget.prototype = new IriSP.Widget(); |
11 IriSP.TooltipWidget.prototype = new IriSP.Widget(); |
11 |
12 |
12 IriSP.TooltipWidget.prototype.draw = function() { |
13 IriSP.TooltipWidget.prototype.draw = function() { |
13 var templ = Mustache.to_html(IriSP.tooltipWidget_template); |
14 var templ = Mustache.to_html(IriSP.tooltipWidget_template); |
14 // position the widget absolutely relative to document. |
15 // position the widget absolutely relative to document. --- NOOOO !!!! |
15 this.selector.css("position", "static"); |
16 this.selector.css({ |
|
17 "position": "absolute", |
|
18 "top": 0, |
|
19 "left": 0 |
|
20 }); |
|
21 this.selector.parent().css({ |
|
22 "position": "relative" |
|
23 }); |
16 this.selector.append(templ); |
24 this.selector.append(templ); |
17 this.hide(); |
25 this.hide(); |
18 |
26 |
19 }; |
27 }; |
20 |
28 |
27 if (this._displayedText == text && this._shown) |
35 if (this._displayedText == text && this._shown) |
28 return; |
36 return; |
29 |
37 |
30 this.selector.find(".tipcolor").css("background-color", color); |
38 this.selector.find(".tipcolor").css("background-color", color); |
31 this._displayedText = text; |
39 this._displayedText = text; |
32 this.selector.find(".tiptext").html(text); |
40 this.selector.find(".tiptext").html(text); |
33 |
41 |
34 if (x < 0) |
42 var _tip = this.selector.find(".tip"); |
35 x = 0; |
43 _tip.show(); |
36 if (y < 0) |
44 _tip.css({ |
37 y = 0; |
45 "left": Math.floor(x - _tip.outerWidth() / 2)+"px", |
38 |
46 "top": Math.floor(y - _tip.outerHeight())+"px" |
39 this.selector.find(".tip").css("left", x).css("top", y); |
47 }); |
40 this.selector.find(".tip").show(); |
|
41 this._shown = true; |
48 this._shown = true; |
42 }; |
49 }; |
43 |
50 |
44 IriSP.TooltipWidget.prototype.hide = function() { |
51 IriSP.TooltipWidget.prototype.hide = function() { |
45 this.selector.find(".tip").hide(); |
52 this.selector.find(".tip").hide(); |