1 /* this widget displays a small tooltip */ |
1 /* this widget displays a small tooltip */ |
2 IriSP.TooltipWidget = function(Popcorn, config, Serializer) { |
2 define(["IriSP", "widgets", "util"], function() { |
3 IriSP.Widget.call(this, Popcorn, config, Serializer); |
3 IriSP.TooltipWidget = function(Popcorn, config, Serializer) { |
4 }; |
4 IriSP.Widget.call(this, Popcorn, config, Serializer); |
|
5 }; |
5 |
6 |
6 |
7 |
7 IriSP.TooltipWidget.prototype = new IriSP.Widget(); |
8 IriSP.TooltipWidget.prototype = new IriSP.Widget(); |
8 |
9 |
9 IriSP.TooltipWidget.prototype.draw = function() { |
10 IriSP.TooltipWidget.prototype.draw = function() { |
10 var templ = Mustache.to_html(IriSP.tooltipWidget_template); |
11 var templ = Mustache.to_html(IriSP.tooltipWidget_template); |
|
12 |
|
13 this.selector.append(templ); |
|
14 this.hide(); |
11 |
15 |
12 this.selector.append(templ); |
16 }; |
13 this.hide(); |
|
14 |
|
15 }; |
|
16 |
17 |
17 IriSP.TooltipWidget.prototype.show = function(text, color, x, y) { |
18 IriSP.TooltipWidget.prototype.show = function(text, color, x, y) { |
18 if (this.selector.find(".tiptext").text() == text) |
19 if (this.selector.find(".tiptext").text() == text) |
19 return; |
20 return; |
20 |
21 |
21 this.selector.find(".tipcolor").css("background-color", color); |
22 this.selector.find(".tipcolor").css("background-color", color); |
22 this.selector.find(".tiptext").text(text); |
23 this.selector.find(".tiptext").text(text); |
23 this.selector.find(".tip").css("left", x).css("top", y); |
24 this.selector.find(".tip").css("left", x).css("top", y); |
24 }; |
25 }; |
25 |
26 |
26 IriSP.TooltipWidget.prototype.hide = function() { |
27 IriSP.TooltipWidget.prototype.hide = function() { |
27 this.selector.find(".tip").css("left", -10000).css("top", -100000); |
28 this.selector.find(".tip").css("left", -10000).css("top", -100000); |
28 }; |
29 }; |
|
30 }); |