1318 |
alexandre_ |
1 |
/*
|
|
|
2 |
Copyright (c) 2004-2006, The Dojo Foundation
|
|
|
3 |
All Rights Reserved.
|
|
|
4 |
|
|
|
5 |
Licensed under the Academic Free License version 2.1 or above OR the
|
|
|
6 |
modified BSD license. For more information on Dojo licensing, see:
|
|
|
7 |
|
|
|
8 |
http://dojotoolkit.org/community/licensing.shtml
|
|
|
9 |
*/
|
|
|
10 |
|
1422 |
alexandre_ |
11 |
|
|
|
12 |
|
1318 |
alexandre_ |
13 |
dojo.provide("dojo.widget.Tooltip");
|
|
|
14 |
dojo.require("dojo.widget.ContentPane");
|
|
|
15 |
dojo.require("dojo.widget.PopupContainer");
|
|
|
16 |
dojo.require("dojo.uri.Uri");
|
|
|
17 |
dojo.require("dojo.widget.*");
|
|
|
18 |
dojo.require("dojo.event.*");
|
|
|
19 |
dojo.require("dojo.html.style");
|
|
|
20 |
dojo.require("dojo.html.util");
|
|
|
21 |
dojo.widget.defineWidget("dojo.widget.Tooltip", [dojo.widget.ContentPane, dojo.widget.PopupContainerBase], {caption:"", showDelay:500, hideDelay:100, connectId:"", templateCssString:".dojoTooltip {\n\tborder: solid black 1px;\n\tbackground: beige;\n\tcolor: black;\n\tposition: absolute;\n\tfont-size: small;\n\tpadding: 2px 2px 2px 2px;\n\tz-index: 10;\n\tdisplay: block;\n}\n", templateCssPath:dojo.uri.moduleUri("dojo.widget", "templates/TooltipTemplate.css"), fillInTemplate:function (args, frag) {
|
|
|
22 |
if (this.caption != "") {
|
|
|
23 |
this.domNode.appendChild(document.createTextNode(this.caption));
|
|
|
24 |
}
|
|
|
25 |
this._connectNode = dojo.byId(this.connectId);
|
|
|
26 |
dojo.widget.Tooltip.superclass.fillInTemplate.call(this, args, frag);
|
|
|
27 |
this.addOnLoad(this, "_loadedContent");
|
|
|
28 |
dojo.html.addClass(this.domNode, "dojoTooltip");
|
|
|
29 |
var source = this.getFragNodeRef(frag);
|
|
|
30 |
dojo.html.copyStyle(this.domNode, source);
|
|
|
31 |
this.applyPopupBasicStyle();
|
|
|
32 |
}, postCreate:function (args, frag) {
|
|
|
33 |
dojo.event.connect(this._connectNode, "onmouseover", this, "_onMouseOver");
|
|
|
34 |
dojo.widget.Tooltip.superclass.postCreate.call(this, args, frag);
|
|
|
35 |
}, _onMouseOver:function (e) {
|
|
|
36 |
this._mouse = {x:e.pageX, y:e.pageY};
|
|
|
37 |
if (!this._tracking) {
|
|
|
38 |
dojo.event.connect(document.documentElement, "onmousemove", this, "_onMouseMove");
|
|
|
39 |
this._tracking = true;
|
|
|
40 |
}
|
|
|
41 |
this._onHover(e);
|
|
|
42 |
}, _onMouseMove:function (e) {
|
|
|
43 |
this._mouse = {x:e.pageX, y:e.pageY};
|
|
|
44 |
if (dojo.html.overElement(this._connectNode, e) || dojo.html.overElement(this.domNode, e)) {
|
|
|
45 |
this._onHover(e);
|
|
|
46 |
} else {
|
|
|
47 |
this._onUnHover(e);
|
|
|
48 |
}
|
|
|
49 |
}, _onHover:function (e) {
|
|
|
50 |
if (this._hover) {
|
|
|
51 |
return;
|
|
|
52 |
}
|
|
|
53 |
this._hover = true;
|
|
|
54 |
if (this._hideTimer) {
|
|
|
55 |
clearTimeout(this._hideTimer);
|
|
|
56 |
delete this._hideTimer;
|
|
|
57 |
}
|
|
|
58 |
if (!this.isShowingNow && !this._showTimer) {
|
|
|
59 |
this._showTimer = setTimeout(dojo.lang.hitch(this, "open"), this.showDelay);
|
|
|
60 |
}
|
|
|
61 |
}, _onUnHover:function (e) {
|
|
|
62 |
if (!this._hover) {
|
|
|
63 |
return;
|
|
|
64 |
}
|
|
|
65 |
this._hover = false;
|
|
|
66 |
if (this._showTimer) {
|
|
|
67 |
clearTimeout(this._showTimer);
|
|
|
68 |
delete this._showTimer;
|
|
|
69 |
}
|
|
|
70 |
if (this.isShowingNow && !this._hideTimer) {
|
|
|
71 |
this._hideTimer = setTimeout(dojo.lang.hitch(this, "close"), this.hideDelay);
|
|
|
72 |
}
|
|
|
73 |
if (!this.isShowingNow) {
|
|
|
74 |
dojo.event.disconnect(document.documentElement, "onmousemove", this, "_onMouseMove");
|
|
|
75 |
this._tracking = false;
|
|
|
76 |
}
|
|
|
77 |
}, open:function () {
|
|
|
78 |
if (this.isShowingNow) {
|
|
|
79 |
return;
|
|
|
80 |
}
|
|
|
81 |
dojo.widget.PopupContainerBase.prototype.open.call(this, this._mouse.x, this._mouse.y, null, [this._mouse.x, this._mouse.y], "TL,TR,BL,BR", [10, 15]);
|
|
|
82 |
}, close:function () {
|
|
|
83 |
if (this.isShowingNow) {
|
|
|
84 |
if (this._showTimer) {
|
|
|
85 |
clearTimeout(this._showTimer);
|
|
|
86 |
delete this._showTimer;
|
|
|
87 |
}
|
|
|
88 |
if (this._hideTimer) {
|
|
|
89 |
clearTimeout(this._hideTimer);
|
|
|
90 |
delete this._hideTimer;
|
|
|
91 |
}
|
|
|
92 |
dojo.event.disconnect(document.documentElement, "onmousemove", this, "_onMouseMove");
|
|
|
93 |
this._tracking = false;
|
|
|
94 |
dojo.widget.PopupContainerBase.prototype.close.call(this);
|
|
|
95 |
}
|
|
|
96 |
}, _position:function () {
|
|
|
97 |
this.move(this._mouse.x, this._mouse.y, [10, 15], "TL,TR,BL,BR");
|
|
|
98 |
}, _loadedContent:function () {
|
|
|
99 |
if (this.isShowingNow) {
|
|
|
100 |
this._position();
|
|
|
101 |
}
|
|
|
102 |
}, checkSize:function () {
|
|
|
103 |
}, uninitialize:function () {
|
|
|
104 |
this.close();
|
|
|
105 |
dojo.event.disconnect(this._connectNode, "onmouseover", this, "_onMouseOver");
|
|
|
106 |
}});
|
|
|
107 |
|