1 /* this widget displays a small tooltip */ |
1 /* this widget displays a small tooltip */ |
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 = ""; |
|
6 this._hideTimeout = -1; |
5 }; |
7 }; |
6 |
8 |
7 |
9 |
8 IriSP.TooltipWidget.prototype = new IriSP.Widget(); |
10 IriSP.TooltipWidget.prototype = new IriSP.Widget(); |
9 |
11 |
18 IriSP.TooltipWidget.prototype.clear = function() { |
20 IriSP.TooltipWidget.prototype.clear = function() { |
19 this.selector.find(".tiptext").text(""); |
21 this.selector.find(".tiptext").text(""); |
20 }; |
22 }; |
21 |
23 |
22 IriSP.TooltipWidget.prototype.show = function(text, color, x, y) { |
24 IriSP.TooltipWidget.prototype.show = function(text, color, x, y) { |
23 if (this._shown === true || this.selector.find(".tiptext").text() == text) |
25 if (this._shown === true || this._displayedText == text) |
24 return; |
26 return; |
25 |
27 |
|
28 // cancel the timeout for the previously displayed element. |
|
29 if (this._hideTimeout != -1) { |
|
30 window.clearTimeout(this._hideTimeout); |
|
31 this._hideTimeout = -1; |
|
32 console.log(text === this._displayedText); |
|
33 } |
|
34 debugger; |
|
35 |
26 this.selector.find(".tipcolor").css("background-color", color); |
36 this.selector.find(".tipcolor").css("background-color", color); |
|
37 this._displayedText = text; |
27 this.selector.find(".tiptext").text(text); |
38 this.selector.find(".tiptext").text(text); |
28 this.selector.find(".tip").css("left", x).css("top", y); |
39 //this.selector.find(".tip").css("left", x).css("top", y); |
29 |
40 this.selector.find(".tip").css("left", x).css("top", "-160px"); |
|
41 this.selector.find(".tip").show(); |
30 this._shown = true; |
42 this._shown = true; |
31 }; |
43 }; |
32 |
44 |
33 IriSP.TooltipWidget.prototype.hide = function() { |
45 IriSP.TooltipWidget.prototype.hide = function() { |
34 this.clear(); |
46 this._hideTimeout = window.setTimeout(IriSP.wrap(this, function() { |
35 this.selector.find(".tip").css("left", -10000).css("top", -100000); |
47 this.selector.find(".tip").hide(); |
|
48 this._shown = false; }), 1000); |
36 |
49 |
37 this._shown = false; |
|
38 }; |
50 }; |