Subversion Repositories Applications.papyrus

Rev

Rev 1318 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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