Skip to content

Commit e0611de

Browse files
committed
Merge branch 'tooltip' into devpreview
2 parents 008def0 + 99900d5 commit e0611de

24 files changed

+991
-28
lines changed

demos/autocomplete/combobox.html

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<script type="text/javascript" src="../../ui/jquery.ui.button.js"></script>
1111
<script type="text/javascript" src="../../ui/jquery.ui.position.js"></script>
1212
<script type="text/javascript" src="../../ui/jquery.ui.autocomplete.js"></script>
13+
<script type="text/javascript" src="../../ui/jquery.ui.tooltip.js"></script>
1314
<link type="text/css" href="../demos.css" rel="stylesheet" />
1415
<style type="text/css">
1516
/* TODO shouldn't be necessary */
@@ -41,8 +42,12 @@
4142
delay: 0,
4243
change: function(event, ui) {
4344
if (!ui.item) {
44-
// remove invalid value, as it didn't match anything
45-
$(this).val("");
45+
var value = this.value;
46+
// remove invalid value, as it didn't match anything, and display a hint
47+
$(this).val("").attr("title", value + " didn't match any item").tooltip("open");
48+
setTimeout(function() {
49+
input.tooltip("close").attr("title", "");
50+
}, 2500);
4651
return false;
4752
}
4853
select.val(ui.item.id);
@@ -54,7 +59,7 @@
5459
minLength: 0
5560
})
5661
.addClass("ui-widget ui-widget-content ui-corner-left");
57-
$("<button>&nbsp;</button>")
62+
var button = $("<button>&nbsp;</button>")
5863
.attr("tabIndex", -1)
5964
.attr("title", "Show All Items")
6065
.insertAfter(input)
@@ -75,6 +80,13 @@
7580
input.autocomplete("search", "");
7681
input.focus();
7782
});
83+
84+
input.tooltip({
85+
position: {
86+
offset: (button.width() + 5) + " 0"
87+
},
88+
tooltipClass: "ui-state-highlight"
89+
});
7890
}
7991
});
8092

demos/button/splitbutton.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949

5050
<div class="demo-description">
5151

52-
<p>An example of a split button built with two buttons: A plan button with just text, one with only a primary icon
52+
<p>An example of a split button built with two buttons: A plain button with just text, one with only a primary icon
5353
and no text. Both are grouped together in a set.</p>
5454

5555
</div><!-- End demo-description -->

demos/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<script type="text/javascript" src="../ui/jquery.ui.slider.js"></script>
2626
<script type="text/javascript" src="../ui/jquery.ui.sortable.js"></script>
2727
<script type="text/javascript" src="../ui/jquery.ui.tabs.js"></script>
28+
<script type="text/javascript" src="../ui/jquery.ui.tooltip.js"></script>
2829
<script type="text/javascript" src="../ui/jquery.effects.core.js"></script>
2930
<script type="text/javascript" src="../ui/jquery.effects.blind.js"></script>
3031
<script type="text/javascript" src="../ui/jquery.effects.bounce.js"></script>
@@ -268,6 +269,7 @@
268269
<dd><a href="progressbar/index.html">Progressbar</a></dd>
269270
<dd><a href="slider/index.html">Slider</a></dd>
270271
<dd><a href="tabs/index.html">Tabs</a></dd>
272+
<dd><a href="tooltip/index.html">Tooltip</a></dd>
271273
<dt>Effects</dt>
272274
<dd><a href="animate/index.html">Color Animation</a></dd>
273275
<dd><a href="toggleClass/index.html">Toggle Class</a></dd>

demos/tooltip/default.html

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<title>jQuery UI Tooltip - Default demo</title>
5+
<link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" />
6+
<script type="text/javascript" src="../../jquery-1.4.2.js"></script>
7+
<script type="text/javascript" src="../../ui/jquery.ui.core.js"></script>
8+
<script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script>
9+
<script type="text/javascript" src="../../ui/jquery.ui.position.js"></script>
10+
<script type="text/javascript" src="../../ui/jquery.ui.tooltip.js"></script>
11+
<link type="text/css" href="../demos.css" rel="stylesheet" />
12+
<script type="text/javascript">
13+
$(function() {
14+
$("a, input").tooltip();
15+
});
16+
</script>
17+
<style>
18+
label { display: inline-block; width: 5em; }
19+
</style>
20+
</head>
21+
<body>
22+
23+
<div class="demo">
24+
25+
<p><a href="#" title="That's what this widget is">Tooltips</a> can be attached to any element. When you hover
26+
the element with your mouse, the title attribute is displayed in a little box next to the element, just like a native tooltip.
27+
</p>
28+
<p>But as it's not a native tooltip, it can be styled. Any themes built with
29+
<a href="http://themeroller.com" title="ThemeRoller, jQuery UI's theme builder application">ThemeRoller</a>
30+
will also style tooltip's accordingly.</p>
31+
<p>Tooltip's are also useful for form elements, to show some additional information in the context of each field.</p>
32+
<p><label for="age">Your age:</label><input id="age" title="We ask for your age only for statistical purposes." /></p>
33+
<p>Click the field to see the tooltip; when you tab out of the field, it gets hidden.</p>
34+
35+
</div><!-- End demo -->
36+
37+
38+
39+
<div class="demo-description">
40+
41+
<p>Hover the links above or use the tab key to cycle the focus on each element.</p>
42+
43+
</div><!-- End demo-description -->
44+
45+
46+
47+
</body>
48+
</html>

demos/tooltip/forms.html

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<title>jQuery UI Tooltip - Default demo</title>
5+
<link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" />
6+
<script type="text/javascript" src="../../jquery-1.4.2.js"></script>
7+
<script type="text/javascript" src="../../ui/jquery.ui.core.js"></script>
8+
<script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script>
9+
<script type="text/javascript" src="../../ui/jquery.ui.position.js"></script>
10+
<script type="text/javascript" src="../../ui/jquery.ui.tooltip.js"></script>
11+
<script type="text/javascript" src="../../ui/jquery.ui.button.js"></script>
12+
<link type="text/css" href="../demos.css" rel="stylesheet" />
13+
<script type="text/javascript">
14+
$(function() {
15+
$("[title]").tooltip();
16+
$("<button/>").text("Show help").button().toggle(function() {
17+
$(":ui-tooltip").tooltip("open");
18+
}, function() {
19+
$(":ui-tooltip").tooltip("close");
20+
}).appendTo("form");
21+
});
22+
</script>
23+
<style>
24+
label { display: inline-block; width: 5em; }
25+
.ui-icon { display: inline-block; }
26+
fieldset div {
27+
margin-bottom: 2em;
28+
}
29+
.ui-tooltip { width: 210px; }
30+
</style>
31+
</head>
32+
<body>
33+
34+
<div class="demo">
35+
36+
<form>
37+
<fieldset>
38+
<div>
39+
<label for="firstname">Firstname</label>
40+
<input id="firstname" name="firstname" />
41+
<span title="Please provide your firstname." class="ui-state-default ui-corner-all ui-icon ui-icon-help">?</span>
42+
</div>
43+
<div>
44+
<label for="lastname">Lastname</label>
45+
<input id="lastname" name="lastname" />
46+
<span title="Please provide also your lastname." class="ui-state-default ui-corner-all ui-icon ui-icon-help">?</span>
47+
</div>
48+
<div>
49+
<label for="address">Address</label>
50+
<input id="address" name="address" />
51+
<span title="Your home or work address." class="ui-state-default ui-corner-all ui-icon ui-icon-help">?</span>
52+
</div>
53+
</fieldset>
54+
</form>
55+
56+
</div><!-- End demo -->
57+
58+
59+
60+
<div class="demo-description">
61+
62+
<p>Hover the questionmark-buttons or use the button below to display the help texts all at once. Click again to hide them.</p>
63+
64+
<p>A fixed width is defined in CSS to make the tooltips look consistent when displayed all at once.</p>
65+
66+
</div><!-- End demo-description -->
67+
68+
69+
70+
</body>
71+
</html>

demos/tooltip/index.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<title>jQuery UI Tooltip Demos</title>
5+
<link type="text/css" href="../demos.css" rel="stylesheet" />
6+
</head>
7+
<body>
8+
9+
<div class="demos-nav">
10+
<h4>Examples</h4>
11+
<ul>
12+
<li class="demo-config-on"><a href="default.html">Default functionality</a></li>
13+
<li><a href="forms.html">Forms with tooltips</a></li>
14+
<li><a href="tracking.html">Track the mouse</a></li>
15+
</ul>
16+
</div>
17+
18+
</body>
19+
</html>

demos/tooltip/tracking.html

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<title>jQuery UI Tooltip - Default demo</title>
5+
<link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" />
6+
<script type="text/javascript" src="../../jquery-1.4.2.js"></script>
7+
<script type="text/javascript" src="../../ui/jquery.ui.core.js"></script>
8+
<script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script>
9+
<script type="text/javascript" src="../../ui/jquery.ui.position.js"></script>
10+
<script type="text/javascript" src="../../ui/jquery.ui.tooltip.js"></script>
11+
<link type="text/css" href="../demos.css" rel="stylesheet" />
12+
<script type="text/javascript">
13+
$(function() {
14+
$("a, input").tooltip({
15+
open: function() {
16+
var tooltip = $(this).tooltip("widget");
17+
$(document).mousemove(function(event) {
18+
tooltip.position({
19+
my: "left center",
20+
at: "right center",
21+
offset: "25 25",
22+
of: event
23+
});
24+
})
25+
// trigger once to override element-relative positioning
26+
.mousemove();
27+
},
28+
close: function() {
29+
$(document).unbind("mousemove");
30+
}
31+
});
32+
});
33+
</script>
34+
<style>
35+
label { display: inline-block; width: 5em; }
36+
</style>
37+
</head>
38+
<body>
39+
40+
<div class="demo">
41+
42+
<p><a href="#" title="That's what this widget is">Tooltips</a> can be attached to any element. When you hover
43+
the element with your mouse, the title attribute is displayed in a little box next to the element, just like a native tooltip.
44+
</p>
45+
<p>But as it's not a native tooltip, it can be styled. Any themes built with
46+
<a href="http://themeroller.com" title="ThemeRoller, jQuery UI's theme builder application">ThemeRoller</a>
47+
will also style tooltip's accordingly.</p>
48+
<p>Tooltip's are also useful for form elements, to show some additional information in the context of each field.</p>
49+
<p><label for="age">Your age:</label><input id="age" title="We ask for your age only for statistical purposes." /></p>
50+
<p>Click the field to see the tooltip; when you tab out of the field, it gets hidden.</p>
51+
52+
</div><!-- End demo -->
53+
54+
55+
56+
<div class="demo-description">
57+
58+
<p>Here the tooltips are positioned relative to the mouse, and follow the mouse while it moves above the element.</p>
59+
60+
</div><!-- End demo-description -->
61+
62+
63+
64+
</body>
65+
</html>

tests/unit/index.html

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,6 @@
1919
}
2020
</style>
2121

22-
<script type="text/javascript" src="../../jquery-1.4.2.js"></script>
23-
<script type="text/javascript" src="../../ui/jquery.ui.core.js"></script>
24-
<script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script>
25-
<script type="text/javascript" src="../../ui/jquery.ui.mouse.js"></script>
26-
<script type="text/javascript" src="../../ui/jquery.ui.accordion.js"></script>
27-
<script type="text/javascript" src="../../ui/jquery.ui.autocomplete.js"></script>
28-
<script type="text/javascript" src="../../ui/jquery.ui.button.js"></script>
29-
<script type="text/javascript" src="../../ui/jquery.ui.datepicker.js"></script>
30-
<script type="text/javascript" src="../../ui/jquery.ui.dialog.js"></script>
31-
<script type="text/javascript" src="../../ui/jquery.ui.draggable.js"></script>
32-
<script type="text/javascript" src="../../ui/jquery.ui.droppable.js"></script>
33-
<script type="text/javascript" src="../../ui/jquery.ui.progressbar.js"></script>
34-
<script type="text/javascript" src="../../ui/jquery.ui.resizable.js"></script>
35-
<script type="text/javascript" src="../../ui/jquery.ui.selectable.js"></script>
36-
<script type="text/javascript" src="../../ui/jquery.ui.slider.js"></script>
37-
<script type="text/javascript" src="../../ui/jquery.ui.sortable.js"></script>
38-
<script type="text/javascript" src="../../ui/jquery.ui.tabs.js"></script>
39-
40-
<script type="text/javascript" src="../../external/jquery.cookie.js"></script>
41-
<script type="text/javascript" src="../jquery.simulate.js"></script>
42-
4322
</head>
4423
<body>
4524

@@ -69,6 +48,7 @@ <h2>Widgets</h2>
6948
<li><a href="progressbar/progressbar.html">Progressbar</a></li>
7049
<li><a href="slider/slider.html">Slider</a></li>
7150
<li><a href="tabs/tabs.html">Tabs</a></li>
51+
<li><a href="tooltip/tooltip.html">Tooltip</a></li>
7252
</ul>
7353

7454
<h2>Utilities</h2>

tests/unit/tooltip/tooltip.html

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>jQuery UI Tooltip Test Suite</title>
6+
7+
<link type="text/css" href="../../../themes/base/jquery.ui.tooltip.css" rel="stylesheet" />
8+
9+
<script type="text/javascript" src="../../../jquery-1.4.2.js"></script>
10+
<script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script>
11+
<script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script>
12+
<script type="text/javascript" src="../../../ui/jquery.ui.tooltip.js"></script>
13+
14+
<link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/>
15+
<script type="text/javascript" src="../../../external/qunit.js"></script>
16+
<script type="text/javascript" src="../../jquery.simulate.js"></script>
17+
<script type="text/javascript" src="../testsuite.js"></script>
18+
19+
<script type="text/javascript" src="tooltip_core.js"></script>
20+
<script type="text/javascript" src="tooltip_defaults.js"></script>
21+
<script type="text/javascript" src="tooltip_events.js"></script>
22+
<script type="text/javascript" src="tooltip_methods.js"></script>
23+
<script type="text/javascript" src="tooltip_options.js"></script>
24+
<script type="text/javascript" src="tooltip_tickets.js"></script>
25+
26+
</head>
27+
<body>
28+
29+
<h1 id="qunit-header">jQuery UI Tooltip Test Suite</h1>
30+
<h2 id="qunit-banner"></h2>
31+
<h2 id="qunit-userAgent"></h2>
32+
<ol id="qunit-tests">
33+
</ol>
34+
35+
<div id="main" style="position: absolute; top: -10000px; left: -10000px;">
36+
<div>
37+
<a id="tooltipped1" href="#" title="anchortitle">anchor</a>
38+
<input title="inputtitle" />
39+
</div>
40+
</div>
41+
42+
</body>
43+
</html>

tests/unit/tooltip/tooltip_core.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* tooltip_core.js
3+
*/
4+
5+
6+
(function($) {
7+
8+
module("tooltip: core");
9+
10+
11+
})(jQuery);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* tooltip_defaults.js
3+
*/
4+
5+
var tooltip_defaults = {
6+
disabled: false,
7+
content: $.ui.tooltip.prototype.options.content,
8+
tooltipClass: "ui-widget-content",
9+
position: {
10+
my: "left center",
11+
at: "right center",
12+
offset: "15 0"
13+
}
14+
};
15+
16+
commonWidgetTests('tooltip', { defaults: tooltip_defaults });

0 commit comments

Comments
 (0)