| author | veltr |
| Mon, 05 Mar 2012 17:34:48 +0100 | |
| branch | popcorn-port |
| changeset 827 | 1dc2f85c3b89 |
| parent 685 | 973d9a495d11 |
| child 828 | bcf0c2bdcb8e |
| permissions | -rw-r--r-- |
|
289
c0e399fbf3fb
due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents:
231
diff
changeset
|
1 |
/* this widget displays a small tooltip */ |
|
c0e399fbf3fb
due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents:
231
diff
changeset
|
2 |
IriSP.TooltipWidget = function(Popcorn, config, Serializer) { |
|
c0e399fbf3fb
due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents:
231
diff
changeset
|
3 |
IriSP.Widget.call(this, Popcorn, config, Serializer); |
| 474 | 4 |
this._shown = false; |
| 477 | 5 |
this._displayedText = ""; |
6 |
this._hideTimeout = -1; |
|
|
827
1dc2f85c3b89
BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents:
685
diff
changeset
|
7 |
console.log(config.container); |
|
289
c0e399fbf3fb
due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents:
231
diff
changeset
|
8 |
}; |
|
c0e399fbf3fb
due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents:
231
diff
changeset
|
9 |
|
|
c0e399fbf3fb
due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents:
231
diff
changeset
|
10 |
|
|
c0e399fbf3fb
due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents:
231
diff
changeset
|
11 |
IriSP.TooltipWidget.prototype = new IriSP.Widget(); |
|
c0e399fbf3fb
due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents:
231
diff
changeset
|
12 |
|
|
c0e399fbf3fb
due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents:
231
diff
changeset
|
13 |
IriSP.TooltipWidget.prototype.draw = function() { |
|
c0e399fbf3fb
due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents:
231
diff
changeset
|
14 |
var templ = Mustache.to_html(IriSP.tooltipWidget_template); |
|
827
1dc2f85c3b89
BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents:
685
diff
changeset
|
15 |
// position the widget absolutely relative to document. --- NOOOO !!!! |
|
1dc2f85c3b89
BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents:
685
diff
changeset
|
16 |
this.selector.css({ |
|
1dc2f85c3b89
BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents:
685
diff
changeset
|
17 |
"position": "absolute", |
|
1dc2f85c3b89
BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents:
685
diff
changeset
|
18 |
"top": 0, |
|
1dc2f85c3b89
BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents:
685
diff
changeset
|
19 |
"left": 0 |
|
1dc2f85c3b89
BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents:
685
diff
changeset
|
20 |
}); |
|
1dc2f85c3b89
BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents:
685
diff
changeset
|
21 |
this.selector.parent().css({ |
|
1dc2f85c3b89
BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents:
685
diff
changeset
|
22 |
"position": "relative" |
|
1dc2f85c3b89
BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents:
685
diff
changeset
|
23 |
}); |
|
289
c0e399fbf3fb
due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents:
231
diff
changeset
|
24 |
this.selector.append(templ); |
|
c0e399fbf3fb
due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents:
231
diff
changeset
|
25 |
this.hide(); |
|
c0e399fbf3fb
due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents:
231
diff
changeset
|
26 |
|
|
c0e399fbf3fb
due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents:
231
diff
changeset
|
27 |
}; |
|
c0e399fbf3fb
due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents:
231
diff
changeset
|
28 |
|
|
336
8da13562cfea
segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents:
289
diff
changeset
|
29 |
IriSP.TooltipWidget.prototype.clear = function() { |
| 685 | 30 |
this.selector.find(".tiptext").html(""); |
|
336
8da13562cfea
segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents:
289
diff
changeset
|
31 |
}; |
|
8da13562cfea
segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents:
289
diff
changeset
|
32 |
|
|
289
c0e399fbf3fb
due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents:
231
diff
changeset
|
33 |
IriSP.TooltipWidget.prototype.show = function(text, color, x, y) { |
| 478 | 34 |
|
| 579 | 35 |
if (this._displayedText == text && this._shown) |
|
289
c0e399fbf3fb
due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents:
231
diff
changeset
|
36 |
return; |
| 579 | 37 |
|
|
289
c0e399fbf3fb
due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents:
231
diff
changeset
|
38 |
this.selector.find(".tipcolor").css("background-color", color); |
| 477 | 39 |
this._displayedText = text; |
|
827
1dc2f85c3b89
BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents:
685
diff
changeset
|
40 |
this.selector.find(".tiptext").html(text); |
| 646 | 41 |
|
|
827
1dc2f85c3b89
BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents:
685
diff
changeset
|
42 |
var _tip = this.selector.find(".tip"); |
|
1dc2f85c3b89
BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents:
685
diff
changeset
|
43 |
_tip.show(); |
|
1dc2f85c3b89
BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents:
685
diff
changeset
|
44 |
_tip.css({ |
|
1dc2f85c3b89
BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents:
685
diff
changeset
|
45 |
"left": Math.floor(x - _tip.outerWidth() / 2)+"px", |
|
1dc2f85c3b89
BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents:
685
diff
changeset
|
46 |
"top": Math.floor(y - _tip.outerHeight())+"px" |
|
1dc2f85c3b89
BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents:
685
diff
changeset
|
47 |
}); |
| 474 | 48 |
this._shown = true; |
|
289
c0e399fbf3fb
due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents:
231
diff
changeset
|
49 |
}; |
|
c0e399fbf3fb
due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents:
231
diff
changeset
|
50 |
|
| 478 | 51 |
IriSP.TooltipWidget.prototype.hide = function() { |
52 |
this.selector.find(".tip").hide(); |
|
53 |
this._shown = false; |
|
| 487 | 54 |
}; |