aboutsummaryrefslogtreecommitdiffstats
path: root/tests/visual/tooltip/tooltip.html
blob: fb2690a54d88d5a1368467854e1e6b476e96c823 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<!DOCTYPE html>
<html lang="en">
<head>
	<title>Tooltip Visual Test: Default</title>
	<link rel="stylesheet" href="../visual.css" type="text/css" />
	<link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css">
	<script type="text/javascript" src="../../../jquery-1.4.4.js"></script>
	<script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script>
	<script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script>
	<script type="text/javascript" src="../../../ui/jquery.ui.position.js"></script>
	<script type="text/javascript" src="../../../ui/jquery.ui.button.js"></script>
	<script type="text/javascript" src="../../../ui/jquery.ui.tooltip.js"></script>
	<script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script>
	<script type="text/javascript">
	$(function() {
		$.fn.themeswitcher && $('<div/>').css({
			position: "absolute",
			right: 10,
			top: 10
		}).appendTo(document.body).themeswitcher();
		
		function enable() {
			// default
			$("#context1, form, #childish").tooltip();
			
			// custom class, replaces ui-widget-content
			$("#context2").tooltip().each(function() {
				$(this).tooltip("widget").addClass("ui-widget-header");
			})
			$("#right1").tooltip().tooltip("widget").addClass("ui-state-error");
			
			// synchronous content
			$("#footnotes").tooltip({
				items: "[href^=#]",
				content: function() {
					return $($(this).attr("href")).html();
				}
			});
			// asynchronous content
			$("#ajax").tooltip({
				content: function(response) {
					$.get("ajaxcontent.php", response);
					return "Loading...";
				}
			});
			// asynchronous content with caching
			var content;
			$("#ajax2").tooltip({
				content: function(response) {
					if (content) {
						return content;
					}
					$.ajax({
						url: "ajaxcontent.php",
						cache: false,
						success: function(result) {
							content = result;
							response(result);
						}
					});
					return "Loading...";
				}
			});
			
			// custom position
			$("#right2").tooltip({
				position: {
					my: "center top",
					at: "center bottom",
					offset: "0 10"
				}
			}).tooltip("widget").addClass("ui-state-highlight");
			
			$("#button1").button();
			$("#button2").button({
				icons: {
					primary: "ui-icon-wrench"
				}
			});
			$("#button3, #button4").button({
				icons: {
					primary: "ui-icon-wrench"
				},
				text: false
			});
			$("#buttons").tooltip({
				position: {
					my: "center bottom",
					at: "center top",
					offset: "0 -5"
				}
			});
		}
		enable();
		
		$("#disable").toggle(function() {
			$("*").tooltip("disable");
		}, function() {
			$("*").tooltip("enable");
		});
		$("#toggle").toggle(function() {
			$("*").tooltip("destroy");
		}, function() {
			enable();
		});
	});
	</script>
</head>
<body>

<div style="width:300px">
	<ul id="context1" class="ui-widget ui-widget-header">
		<li><a href="#" title="Tooltip text 1">Anchor 1</a></li>
		<li><a href="#" title="Tooltip text 2">Anchor 2</a></li>
		<li><a href="#" title="Tooltip text 3">Anchor 3</a></li>
		<li><a href="#" title="Tooltip text 4 more Tooltip text Tooltip text ">Anchor 4</a></li>
		<li><a href="#" title="Tooltip text 5 more Tooltip text Tooltip text ">Anchor 5</a></li>
		<li><a href="#" title="Tooltip text 6 more Tooltip text Tooltip text ">Anchor 6</a></li>
	</ul>

	<div id="right1" style="position: absolute; right: 1em" title="right aligned element">
		collision detection should kick in around here
	</div>
	
	<div id="footnotes" style="margin: 2em 0">
		<a href="#footnote1">I'm a link to a footnote.</a>
		<a href="#footnote2">I'm another link to a footnote.</a>
	</div>
	
	<div id="right2" style="position: absolute; right: 1em" title="right aligned element with custom position">
		right aligned with custom position
	</div>
	
	<div id="ajax" style="width: 100px;" class="ui-widget-content" title="never be seen">
		gets its content via ajax
	</div>
	<div id="ajax2" style="width: 100px;" class="ui-widget-content" title="never be seen">
		gets its content via ajax, caches the response
	</div>
	
	<div id="context2" class="ui-widget ui-widget-content">
		<span title="something" style="border:1px solid blue">span</span>
		<div title="something else" style="border:1px solid red;">
			div
			<span title="something more" style="border:1px solid green;">nested span</span>
		</div>
	</div>
	
	<div id="childish" class="ui-widget ui-widget-content" style="margin: 2em 0; border: 1px solid black;" title="element with child elements">
		Text in <strong>bold</strong>.
	</div>
	
	<form style="margin: 2em 0;">
		<div>
			<label for="first">First Name:</label>
			<input id="first" title="Your first name is optional" />
		</div>
		<div>
			<label for="last">Last Name:</label>
			<input id="last" title="Your last name is optional" />
		</div>
	</form>
	
	<div id="buttons">
		<button id="button1" title="Button Tooltip">Button Label</button>
		<button id="button2" title="Icon Button">Button with Icon</button>
		<button id="button3">Icon Only Button 1</button>
		<button id="button4">Icon Only Button 2</button>
	</div>
	
	<div id="footnote1">This is <strong>the</strong> footnote, including other elements</div>
	<div id="footnote2">This is <strong>the other</strong> footnote, including other elements</div>
	
	<button id="disable">Toggle disabled</button>
	<button id="toggle">Toggle widget</button>
</div>

<div style="height: 2000px"></div>

</body>
</html>