mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Copying files from old Googlecode dev branch for tooltip
This commit is contained in:
parent
05e31932a0
commit
7dbf7ecfc1
@ -25,6 +25,7 @@
|
||||
<script type="text/javascript" src="../ui/jquery.ui.slider.js"></script>
|
||||
<script type="text/javascript" src="../ui/jquery.ui.sortable.js"></script>
|
||||
<script type="text/javascript" src="../ui/jquery.ui.tabs.js"></script>
|
||||
<script type="text/javascript" src="../ui/jquery.ui.tooltip.js"></script>
|
||||
<script type="text/javascript" src="../ui/jquery.effects.core.js"></script>
|
||||
<script type="text/javascript" src="../ui/jquery.effects.blind.js"></script>
|
||||
<script type="text/javascript" src="../ui/jquery.effects.bounce.js"></script>
|
||||
@ -268,6 +269,7 @@
|
||||
<dd><a href="progressbar/index.html">Progressbar</a></dd>
|
||||
<dd><a href="slider/index.html">Slider</a></dd>
|
||||
<dd><a href="tabs/index.html">Tabs</a></dd>
|
||||
<dd><a href="tooltip/index.html">Tooltip</a></dd>
|
||||
<dt>Effects</dt>
|
||||
<dd><a href="animate/index.html">Color Animation</a></dd>
|
||||
<dd><a href="toggleClass/index.html">Toggle Class</a></dd>
|
||||
|
48
demos/tooltip/default.html
Normal file
48
demos/tooltip/default.html
Normal file
@ -0,0 +1,48 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>jQuery UI Tooltip - Default demo</title>
|
||||
<link type="text/css" href="../../themes/base/ui.all.css" rel="stylesheet" />
|
||||
<script type="text/javascript" src="../../jquery-1.3.2.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.tooltip.js"></script>
|
||||
<link type="text/css" href="../demos.css" rel="stylesheet" />
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
$("a, input").tooltip();
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
label { display: inline-block; width: 5em; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="demo">
|
||||
|
||||
<p><a href="#" title="That's what this widget is">Tooltips</a> can be attached to any element. When you hover
|
||||
the element with your mouse, the title attribute is displayed in a little box next to the element, just like a native tooltip.
|
||||
</p>
|
||||
<p>But as it's not a native tooltip, it can be styled. Any themes built with
|
||||
<a href="http://themeroller.com" title="ThemeRoller, jQuery UI's theme builder application">ThemeRoller</a>
|
||||
will also style tooltip's accordingly.</p>
|
||||
<p>Tooltip's are also useful for form elements, to show some additional information in the context of each field.</p>
|
||||
<p><label for="age">Your age:</label><input id="age" title="We ask for your age only for statistical purposes." /></p>
|
||||
<p>Click the field to see the tooltip; when you tab out of the field, it gets hidden.</p>
|
||||
|
||||
</div><!-- End demo -->
|
||||
|
||||
|
||||
|
||||
<div class="demo-description">
|
||||
|
||||
<p>Hover the links above or use the tab key to cycle the focus on each element.</p>
|
||||
|
||||
</div><!-- End demo-description -->
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
21
demos/tooltip/index.html
Normal file
21
demos/tooltip/index.html
Normal file
@ -0,0 +1,21 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>jQuery UI Tooltip Demos</title>
|
||||
<link type="text/css" href="../demos.css" rel="stylesheet" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="demos-nav">
|
||||
<h4>Examples</h4>
|
||||
<ul>
|
||||
<li class="demo-config-on"><a href="default.html">Default functionality</a></li>
|
||||
<!--
|
||||
<li><a href="foo.html">Foo</a></li>
|
||||
<li><a href="bar.html">Bar</a></li>
|
||||
-->
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -43,6 +43,7 @@
|
||||
<li><a href="progressbar/progressbar.html">Progressbar</a></li>
|
||||
<li><a href="slider/slider.html">Slider</a></li>
|
||||
<li><a href="tabs/tabs.html">Tabs</a></li>
|
||||
<li><a href="tooltip/tooltip.html">Tooltip</a></li>
|
||||
</ul>
|
||||
|
||||
</body>
|
||||
|
2
tests/visual/tooltip/ajaxcontent.php
Normal file
2
tests/visual/tooltip/ajaxcontent.php
Normal file
@ -0,0 +1,2 @@
|
||||
<?php sleep(1); ?>
|
||||
<strong>Hello</strong> world!
|
213
tests/visual/tooltip/callout.html
Normal file
213
tests/visual/tooltip/callout.html
Normal file
@ -0,0 +1,213 @@
|
||||
<!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/ui.all.css" type="text/css">
|
||||
<script type="text/javascript" src="../../../jquery-1.3.2.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.tooltip.js"></script>
|
||||
<script type="text/javascript">
|
||||
$.widget("ui.callout", {
|
||||
_init: function() {
|
||||
this.element.append('<div class="ui-tooltip-pointer ui-widget-content"><div class="ui-tooltip-pointer-inner" style="border-right-color:rgb(255, 255, 255)"></div></div>');
|
||||
},
|
||||
pointAt: function(target) {
|
||||
target = $(target);
|
||||
var tx = target.offset().left + target.width() / 2,
|
||||
ty = target.offset().top + target.height() / 2,
|
||||
dx = this.element.offset().left + this.element.width() / 2,
|
||||
dy = this.element.offset().top + this.element.height() / 2;
|
||||
function d(a, b) {
|
||||
return a > b ? a - b : b - a;
|
||||
}
|
||||
this.element.attr("class", this.element.attr("class").replace(/(.+)ui-tooltip-arrow-..(.+)?/, "$1 $2"));
|
||||
if (dx < tx && d(dx, tx) > d(dy, tx)) {
|
||||
this.element.addClass("ui-tooltip-arrow-rc");
|
||||
}
|
||||
if (dx > tx && d(dx, tx) > d(dy, ty)) {
|
||||
this.element.addClass("ui-tooltip-arrow-lc");
|
||||
}
|
||||
if (dy > ty && d(dx, tx) < d(dy, ty)) {
|
||||
this.element.addClass("ui-tooltip-arrow-tc");
|
||||
}
|
||||
if (dy < ty && d(dx, tx) < d(dy, ty)) {
|
||||
this.element.addClass("ui-tooltip-arrow-bc");
|
||||
}
|
||||
|
||||
// fix inner borders
|
||||
$('.ui-tooltip-pointer-inner', this.element).each(function(){
|
||||
var pt = $(this).parent().parent();
|
||||
var bColor = pt.css('backgroundColor');
|
||||
$(this).css({
|
||||
borderLeftColor: '',
|
||||
borderRightColor: '',
|
||||
borderTopColor: '',
|
||||
borderBottomColor: ''
|
||||
});
|
||||
if(pt.is('.ui-tooltip-arrow-rb,.ui-tooltip-arrow-rc,.ui-tooltip-arrow-rt')){ $(this).css('border-left-color', bColor); }
|
||||
else if(pt.is('.ui-tooltip-arrow-br,.ui-tooltip-arrow-bc,.ui-tooltip-arrow-bl')){ $(this).css('border-top-color', bColor); }
|
||||
else if(pt.is('.ui-tooltip-arrow-lb,.ui-tooltip-arrow-lc,.ui-tooltip-arrow-lt')){ $(this).css('border-right-color', bColor); }
|
||||
else { $(this).css('border-bottom-color', bColor); }
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$(function() {
|
||||
$.ui.tooltip.prototype.options.show = function(event, ui) {
|
||||
$(this).tooltip("widget").callout("pointAt", ui.target);
|
||||
}
|
||||
|
||||
function enable() {
|
||||
// default
|
||||
$("#context1, form input").tooltip();
|
||||
|
||||
// custom class, replaces ui-widget-content
|
||||
$("#context2").tooltip({
|
||||
tooltipClass: "ui-widget-header"
|
||||
});
|
||||
$("#right1").tooltip({
|
||||
tooltipClass: "ui-state-error"
|
||||
});
|
||||
|
||||
// synchronous content
|
||||
$("#see-footnote").tooltip({
|
||||
content: function() {
|
||||
return $($(this).attr("href")).html();
|
||||
}
|
||||
});
|
||||
// asynchronous content
|
||||
$("#ajax").tooltip({
|
||||
content: function(response) {
|
||||
$.get("ajaxcontent.html", response);
|
||||
}
|
||||
});
|
||||
|
||||
// custom position
|
||||
$("#right2").tooltip({
|
||||
position: {
|
||||
my: "center top",
|
||||
at: "center bottom",
|
||||
offset: "0 10"
|
||||
},
|
||||
tooltipClass: "ui-state-highlight"
|
||||
});
|
||||
|
||||
$(".ui-tooltip").callout();
|
||||
}
|
||||
enable();
|
||||
|
||||
$("#disable").toggle(function() {
|
||||
$("*").tooltip("disable");
|
||||
}, function() {
|
||||
$("*").tooltip("enable");
|
||||
});
|
||||
$("#toggle").toggle(function() {
|
||||
$("*").tooltip("destroy");
|
||||
}, function() {
|
||||
enable();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.ui-tooltip .ui-tooltip-pointer,.ui-tooltip .ui-tooltip-pointer-inner { position:absolute; width:0; height:0; background:none; }
|
||||
|
||||
/*top*/
|
||||
.ui-tooltip-arrow-tr .ui-tooltip-pointer,.ui-tooltip-arrow-tc .ui-tooltip-pointer,.ui-tooltip-arrow-tl .ui-tooltip-pointer { top:-14px; border-top:0; border-bottom-width:14px; }
|
||||
.ui-tooltip-arrow-tr .ui-tooltip-pointer { border-left:18px dotted transparent; border-right:0; right:10px; }
|
||||
.ui-tooltip-arrow-tc .ui-tooltip-pointer { border-left:10px dotted transparent; border-right:10px dotted transparent; left:50%; margin-left:-10px; }
|
||||
.ui-tooltip-arrow-tl .ui-tooltip-pointer { border-left:0; border-right:18px dotted transparent; left:10px; }
|
||||
.ui-tooltip-arrow-tr .ui-tooltip-pointer-inner,.ui-tooltip-arrow-tc .ui-tooltip-pointer-inner,.ui-tooltip-arrow-tl .ui-tooltip-pointer-inner { border-bottom:10px solid #fff; bottom:-14px; }
|
||||
.ui-tooltip-arrow-tr .ui-tooltip-pointer-inner { border-left:12px dotted transparent; border-right:0; right:2px; }
|
||||
.ui-tooltip-arrow-tc .ui-tooltip-pointer-inner { border-left:8px dotted transparent; border-right:8px dotted transparent; left:-8px; }
|
||||
.ui-tooltip-arrow-tl .ui-tooltip-pointer-inner { border-left:0; border-right:12px dotted transparent; left:2px; }
|
||||
|
||||
/*right*/
|
||||
.ui-tooltip-arrow-rb .ui-tooltip-pointer,.ui-tooltip-arrow-rc .ui-tooltip-pointer,.ui-tooltip-arrow-rt .ui-tooltip-pointer { right:-14px; border-right:0; border-left-width:14px; }
|
||||
.ui-tooltip-arrow-rb .ui-tooltip-pointer { border-bottom:0; border-top:18px dotted transparent; bottom:10px; }
|
||||
.ui-tooltip-arrow-rc .ui-tooltip-pointer { border-bottom:10px dotted transparent; border-top:10px dotted transparent; bottom:50%; margin-bottom:-10px; }
|
||||
.ui-tooltip-arrow-rt .ui-tooltip-pointer { border-bottom:18px dotted transparent; border-top:0; top:10px; }
|
||||
.ui-tooltip-arrow-rb .ui-tooltip-pointer-inner,.ui-tooltip-arrow-rc .ui-tooltip-pointer-inner,.ui-tooltip-arrow-rt .ui-tooltip-pointer-inner { border-left:10px solid #fff; left:-14px; }
|
||||
.ui-tooltip-arrow-rb .ui-tooltip-pointer-inner { border-bottom:0; border-top:12px dotted transparent; bottom:2px; }
|
||||
.ui-tooltip-arrow-rc .ui-tooltip-pointer-inner { border-bottom:8px dotted transparent; border-top:8px dotted transparent; bottom:-8px; }
|
||||
.ui-tooltip-arrow-rt .ui-tooltip-pointer-inner { border-bottom:12px dotted transparent; border-top:0; top:2px; }
|
||||
|
||||
/*bottom*/
|
||||
.ui-tooltip-arrow-br .ui-tooltip-pointer,.ui-tooltip-arrow-bc .ui-tooltip-pointer,.ui-tooltip-arrow-bl .ui-tooltip-pointer { bottom:-14px; border-bottom:0; border-top-width:14px; }
|
||||
.ui-tooltip-arrow-br .ui-tooltip-pointer { border-left:18px dotted transparent; border-right:0; right:10px; }
|
||||
.ui-tooltip-arrow-bc .ui-tooltip-pointer { border-left:10px dotted transparent; border-right:10px dotted transparent; left:50%; margin-left:-10px; }
|
||||
.ui-tooltip-arrow-bl .ui-tooltip-pointer { border-left:0; border-right:18px dotted transparent; left:10px; }
|
||||
.ui-tooltip-arrow-br .ui-tooltip-pointer-inner,.ui-tooltip-arrow-bc .ui-tooltip-pointer-inner,.ui-tooltip-arrow-bl .ui-tooltip-pointer-inner { border-top:10px solid #fff; top:-14px; }
|
||||
.ui-tooltip-arrow-br .ui-tooltip-pointer-inner { border-left:12px dotted transparent; border-right:0; right:2px; }
|
||||
.ui-tooltip-arrow-bc .ui-tooltip-pointer-inner { border-left:8px dotted transparent; border-right:8px dotted transparent; left:-8px; }
|
||||
.ui-tooltip-arrow-bl .ui-tooltip-pointer-inner { border-left:0; border-right:12px dotted transparent; left:2px; }
|
||||
|
||||
/*left*/
|
||||
.ui-tooltip-arrow-lb .ui-tooltip-pointer,.ui-tooltip-arrow-lc .ui-tooltip-pointer,.ui-tooltip-arrow-lt .ui-tooltip-pointer { left:-14px; border-left:0; border-right-width:14px; }
|
||||
.ui-tooltip-arrow-lb .ui-tooltip-pointer { border-bottom:0; border-top:18px dotted transparent; bottom:10px; }
|
||||
.ui-tooltip-arrow-lc .ui-tooltip-pointer { border-bottom:10px dotted transparent; border-top:10px dotted transparent; bottom:50%; margin-bottom:-10px; }
|
||||
.ui-tooltip-arrow-lt .ui-tooltip-pointer { border-bottom:18px dotted transparent; border-top:0; top:10px; }
|
||||
.ui-tooltip-arrow-lb .ui-tooltip-pointer-inner,.ui-tooltip-arrow-lc .ui-tooltip-pointer-inner,.ui-tooltip-arrow-lt .ui-tooltip-pointer-inner { border-right:10px solid #fff; right:-14px; }
|
||||
.ui-tooltip-arrow-lb .ui-tooltip-pointer-inner { border-bottom:0; border-top:12px dotted transparent; bottom:2px; }
|
||||
.ui-tooltip-arrow-lc .ui-tooltip-pointer-inner { border-bottom:8px dotted transparent; border-top:8px dotted transparent; bottom:-8px; }
|
||||
</style>
|
||||
</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 style="margin: 2em 0">
|
||||
<a id="see-footnote" href="#footnote">I'm a 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="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>
|
||||
|
||||
<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="footnote">This is <strong>the</strong> footnote, including other elements</div>
|
||||
|
||||
<button id="disable">Toggle disabled</button>
|
||||
<button id="toggle">Toggle widget</button>
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
127
tests/visual/tooltip/tooltip.html
Normal file
127
tests/visual/tooltip/tooltip.html
Normal file
@ -0,0 +1,127 @@
|
||||
<!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.2.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.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 input").tooltip();
|
||||
|
||||
// custom class, replaces ui-widget-content
|
||||
$("#context2").tooltip({
|
||||
tooltipClass: "ui-widget-header"
|
||||
});
|
||||
$("#right1").tooltip({
|
||||
tooltipClass: "ui-state-error"
|
||||
});
|
||||
|
||||
// synchronous content
|
||||
$("#see-footnote").tooltip({
|
||||
content: function() {
|
||||
return $($(this).attr("href")).html();
|
||||
}
|
||||
});
|
||||
// asynchronous content
|
||||
$("#ajax").tooltip({
|
||||
content: function(response) {
|
||||
$.get("ajaxcontent.php", response);
|
||||
return "Loading...";
|
||||
}
|
||||
});
|
||||
|
||||
// custom position
|
||||
$("#right2").tooltip({
|
||||
position: {
|
||||
my: "center top",
|
||||
at: "center bottom",
|
||||
offset: "0 10"
|
||||
},
|
||||
tooltipClass: "ui-state-highlight"
|
||||
});
|
||||
}
|
||||
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 style="margin: 2em 0">
|
||||
<a id="see-footnote" href="#footnote">I'm a 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="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>
|
||||
|
||||
<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="footnote">This is <strong>the</strong> footnote, including other elements</div>
|
||||
|
||||
<button id="disable">Toggle disabled</button>
|
||||
<button id="toggle">Toggle widget</button>
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
1
themes/base/jquery.ui.base.css
vendored
1
themes/base/jquery.ui.base.css
vendored
@ -9,3 +9,4 @@
|
||||
@import url("jquery.ui.resizable.css");
|
||||
@import url("jquery.ui.slider.css");
|
||||
@import url("jquery.ui.tabs.css");
|
||||
@import url("jquery.ui.tooltip.css");
|
||||
|
3
themes/base/jquery.ui.tooltip.css
vendored
Normal file
3
themes/base/jquery.ui.tooltip.css
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
/*Tooltip and Pointer CSS*/
|
||||
.ui-tooltip { padding:8px; width:100px; position:absolute; z-index:9999; }
|
||||
body .ui-tooltip { border-width:2px; }
|
134
ui/jquery.ui.tooltip.js
vendored
Normal file
134
ui/jquery.ui.tooltip.js
vendored
Normal file
@ -0,0 +1,134 @@
|
||||
/*
|
||||
* jQuery UI Tooltip @VERSION
|
||||
*
|
||||
* Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
|
||||
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
||||
* and GPL (GPL-LICENSE.txt) licenses.
|
||||
*
|
||||
* http://docs.jquery.com/UI/Tooltip
|
||||
*
|
||||
* Depends:
|
||||
* jquery.ui.core.js
|
||||
* jquery.ui.widget.js
|
||||
* jquery.ui.position.js
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
var increments = 0;
|
||||
|
||||
$.widget("ui.tooltip", {
|
||||
options: {
|
||||
tooltipClass: "ui-widget-content",
|
||||
content: function() {
|
||||
return $(this).attr("title");
|
||||
},
|
||||
position: {
|
||||
my: "left center",
|
||||
at: "right center",
|
||||
offset: "15 0"
|
||||
}
|
||||
},
|
||||
_init: function() {
|
||||
var self = this;
|
||||
this.tooltip = $("<div></div>")
|
||||
.attr("id", "ui-tooltip-" + increments++)
|
||||
.attr("role", "tooltip")
|
||||
.attr("aria-hidden", "true")
|
||||
.addClass("ui-tooltip ui-widget ui-corner-all")
|
||||
.addClass(this.options.tooltipClass)
|
||||
.appendTo(document.body)
|
||||
.hide();
|
||||
this.tooltipContent = $("<div></div>")
|
||||
.addClass("ui-tooltip-content")
|
||||
.appendTo(this.tooltip);
|
||||
this.opacity = this.tooltip.css("opacity");
|
||||
this.element
|
||||
.bind("focus.tooltip mouseover.tooltip", function(event) {
|
||||
self.show($(event.target));
|
||||
})
|
||||
.bind("blur.tooltip mouseout.tooltip", function(event) {
|
||||
self.close();
|
||||
});
|
||||
},
|
||||
|
||||
enable: function() {
|
||||
this.options.disabled = false;
|
||||
},
|
||||
|
||||
disable: function() {
|
||||
this.options.disabled = true;
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
this.tooltip.remove();
|
||||
$.Widget.prototype.destroy.apply(this, arguments);
|
||||
},
|
||||
|
||||
widget: function() {
|
||||
return this.tooltip;
|
||||
},
|
||||
|
||||
show: function(target) {
|
||||
// already visible? possible when both focus and mouseover events occur
|
||||
if (this.current && this.current[0] == target[0])
|
||||
return;
|
||||
var self = this;
|
||||
this.current = target;
|
||||
this.currentTitle = target.attr("title");
|
||||
var content = this.options.content.call(target[0], function(response) {
|
||||
if (self.current == target)
|
||||
self.open(target, response);
|
||||
});
|
||||
if (content) {
|
||||
self.open(target, content);
|
||||
}
|
||||
},
|
||||
|
||||
open: function(target, content) {
|
||||
if (!content)
|
||||
return;
|
||||
|
||||
target.attr("title", "");
|
||||
|
||||
if (this.options.disabled)
|
||||
return;
|
||||
|
||||
this.tooltipContent.html(content);
|
||||
this.tooltip.position($.extend(this.options.position, {
|
||||
of: target
|
||||
}));
|
||||
|
||||
this.tooltip.attr("aria-hidden", "false");
|
||||
target.attr("aria-describedby", this.tooltip.attr("id"));
|
||||
|
||||
if (this.tooltip.is(":animated"))
|
||||
this.tooltip.stop().show().fadeTo("normal", this.opacity);
|
||||
else
|
||||
this.tooltip.is(':visible') ? this.tooltip.fadeTo("normal", this.opacity) : this.tooltip.fadeIn();
|
||||
|
||||
this._trigger("show", null, { target: target });
|
||||
},
|
||||
|
||||
close: function() {
|
||||
if (!this.current)
|
||||
return;
|
||||
|
||||
var current = this.current.attr("title", this.currentTitle);
|
||||
this.current = null;
|
||||
|
||||
if (this.options.disabled)
|
||||
return;
|
||||
|
||||
current.removeAttr("aria-describedby");
|
||||
this.tooltip.attr("aria-hidden", "true");
|
||||
|
||||
if (this.tooltip.is(':animated'))
|
||||
this.tooltip.stop().fadeTo("normal", 0);
|
||||
else
|
||||
this.tooltip.stop().fadeOut();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
})(jQuery);
|
Loading…
Reference in New Issue
Block a user