]> source.dussan.org Git - jquery-ui.git/commitdiff
The accidental merge of tooltip into master was reverted in master, that revert got...
authorjzaefferer <joern.zaefferer@gmail.com>
Thu, 8 Apr 2010 21:21:47 +0000 (23:21 +0200)
committerjzaefferer <joern.zaefferer@gmail.com>
Thu, 8 Apr 2010 21:21:47 +0000 (23:21 +0200)
14 files changed:
demos/index.html
demos/tooltip/default.html [new file with mode: 0644]
demos/tooltip/forms.html [new file with mode: 0644]
demos/tooltip/index.html [new file with mode: 0644]
demos/tooltip/tracking.html [new file with mode: 0644]
tests/visual/compound/tabs_tooltips.html [new file with mode: 0644]
tests/visual/compound/widgets_in_dialog.html
tests/visual/index.html
tests/visual/tooltip/ajaxcontent.php [new file with mode: 0644]
tests/visual/tooltip/callout.html [new file with mode: 0644]
tests/visual/tooltip/tooltip.html [new file with mode: 0644]
themes/base/jquery.ui.base.css
themes/base/jquery.ui.tooltip.css [new file with mode: 0644]
ui/jquery.ui.tooltip.js [new file with mode: 0644]

index db3e2bf836fa91778dd25ea3a13b12fcc5265175..c9f690921a5a0df3da82e3b2f5c4d6a1d1269905 100644 (file)
@@ -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>
                                        <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>
diff --git a/demos/tooltip/default.html b/demos/tooltip/default.html
new file mode 100644 (file)
index 0000000..22dac4f
--- /dev/null
@@ -0,0 +1,48 @@
+<!doctype html>
+<html lang="en">
+<head>
+       <title>jQuery UI Tooltip - Default demo</title>
+       <link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" />
+       <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>
+       <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>
diff --git a/demos/tooltip/forms.html b/demos/tooltip/forms.html
new file mode 100644 (file)
index 0000000..626161d
--- /dev/null
@@ -0,0 +1,69 @@
+<!doctype html>
+<html lang="en">
+<head>
+       <title>jQuery UI Tooltip - Default demo</title>
+       <link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" />
+       <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="../../ui/jquery.ui.button.js"></script>
+       <link type="text/css" href="../demos.css" rel="stylesheet" />
+       <script type="text/javascript">
+       $(function() {
+               $("[title]").tooltip();
+               $("<button/>").text("Show help").button().toggle(function() {
+                       $(":ui-tooltip").tooltip("open");
+               }, function() {
+                       $(":ui-tooltip").tooltip("close");
+               }).appendTo("form");
+       });
+       </script>
+       <style>
+               label { display: inline-block; width: 5em; }
+               .ui-icon { display: inline-block; }
+               fieldset div {
+                       margin-bottom: 2em;
+               }
+               .ui-tooltip { width: 200px; }
+       </style>
+</head>
+<body>
+
+<div class="demo">
+
+       <form>
+               <fieldset>
+                       <div>
+                               <label for="firstname">Firstname</label>
+                               <input id="firstname" name="firstname" />
+                               <span title="Please provide your firstname." class="ui-state-default ui-corner-all ui-icon ui-icon-help">?</span>
+                       </div>
+                       <div>
+                               <label for="lastname">Lastname</label>
+                               <input id="lastname" name="lastname" />
+                               <span title="Please provide also your lastname." class="ui-state-default ui-corner-all ui-icon ui-icon-help">?</span>
+                       </div>
+                       <div>
+                               <label for="address">Address</label>
+                               <input id="address" name="address" />
+                               <span title="Your home or work address." class="ui-state-default ui-corner-all ui-icon ui-icon-help">?</span>
+                       </div>
+               </fieldset>
+       </form>
+
+</div><!-- End demo -->
+
+
+
+<div class="demo-description">
+
+<p>Hover the questionmark-buttons or use the button below to display the help texts all at once. Click again to hide them.</p>
+
+</div><!-- End demo-description -->
+
+
+
+</body>
+</html>
diff --git a/demos/tooltip/index.html b/demos/tooltip/index.html
new file mode 100644 (file)
index 0000000..ed5cd10
--- /dev/null
@@ -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>
diff --git a/demos/tooltip/tracking.html b/demos/tooltip/tracking.html
new file mode 100644 (file)
index 0000000..9af4d0d
--- /dev/null
@@ -0,0 +1,65 @@
+<!doctype html>
+<html lang="en">
+<head>
+       <title>jQuery UI Tooltip - Default demo</title>
+       <link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" />
+       <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>
+       <link type="text/css" href="../demos.css" rel="stylesheet" />
+       <script type="text/javascript">
+       $(function() {
+               $("a, input").tooltip({
+                       open: function() {
+                               var tooltip = $(this).tooltip("widget");
+                               $(document).mousemove(function(event) {
+                                       tooltip.position({
+                                               my: "left center",
+                                               at: "right center",
+                                               offset: "25 25",
+                                               of: event
+                                       });
+                               })
+                               // trigger once to override element-relative positioning
+                               .mousemove();
+                       },
+                       close: function() {
+                               $(document).unbind("mousemove");
+                       }
+               });
+       });
+       </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>Here the tooltips are positioned relative to the mouse, and follow the mouse while it moves above the element.</p>
+
+</div><!-- End demo-description -->
+
+
+
+</body>
+</html>
diff --git a/tests/visual/compound/tabs_tooltips.html b/tests/visual/compound/tabs_tooltips.html
new file mode 100644 (file)
index 0000000..00046fe
--- /dev/null
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+       <meta charset="UTF-8" />
+       <title>Compound Visual Test : Tabs in Tabs</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="../../../ui/jquery.ui.tabs.js"></script>
+       <script type="text/javascript">
+       $(function() {
+               $("#tabs").tabs();
+               $("a").tooltip();
+       });
+       </script>
+</head>
+<body>
+
+<div id="tabs">
+       <ul>
+               <li><a href="#tabs-1" title="first tab tooltip">First</a></li>
+               <li><a href="#tabs-2" title="second tab tooltip">Second</a></li>
+       </ul>
+       <div id="tabs-1">
+               <a href="#" title="title content">label</a>
+       </div>
+       <div id="tabs-2">
+               <a href="#" title="other title content">other label</a>
+       </div>
+</div>
+
+</body>
+</html>
index 7551efd8d4cb939eaed4fdbd6cae1dd5b2fe6fe5..e2eb366b43735de60221b09ef1e0a5c2ca41add3 100644 (file)
        <script type="text/javascript" src="../../../ui/jquery.ui.progressbar.js"></script>
        <script type="text/javascript" src="../../../ui/jquery.ui.slider.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">
        $(function() {
+               $("[title]").tooltip();
+               
                $("#accordion").accordion();
                $("#autocomplete").autocomplete({
                        source: ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", "python", "c", "scala", "groovy", "haskell", "perl"]
@@ -50,7 +53,7 @@
                        width: 100,
                        height: 75,
                        modal: true
-               })
+               });
        });
        </script>
 </head>
        <input id="datepicker">
        <button>Another button</button>
        <div>
-               <label for="progress">Progress: <input id="progress" /></label>
+               <label for="progress">Progress: <input title="The progress we made so far" id="progress" /></label>
        </div>
        <div id="progressbar">
        </div>
-       <div id="slider"></div>
+       <div id="slider" title="Sliding progress..."></div>
        <div id="tabs">
                <ul>
                        <li><a href="#tabs-1">First</a></li>
index ad46ddf8dff3ebf8022acd36d5f0fb24dd43c572..8f481022541095b77700b05bf22b9580f77fab43 100644 (file)
@@ -20,6 +20,7 @@
        <li><a href="compound/draggable_accordion.html">Draggable Accordion</a></li>
        <li><a href="compound/sortable_accordion_sortable_tabs.html">Accordion within Tabs, both Sortable</a></li>
        <li><a href="compound/tabs_tabs.html">Tabs contains Tabs</a></li>
+       <li><a href="compound/tabs_tooltips.html">Tabs with Tooltips</a></li>
        <li><a href="compound/widgets_in_dialog.html">All Widgets within a Dialog</a></li>
 </ul>
 
@@ -43,6 +44,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>
diff --git a/tests/visual/tooltip/ajaxcontent.php b/tests/visual/tooltip/ajaxcontent.php
new file mode 100644 (file)
index 0000000..a689a73
--- /dev/null
@@ -0,0 +1,2 @@
+<?php sleep(1); ?>
+<strong>Hello</strong> world!
\ No newline at end of file
diff --git a/tests/visual/tooltip/callout.html b/tests/visual/tooltip/callout.html
new file mode 100644 (file)
index 0000000..3ef6949
--- /dev/null
@@ -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>
diff --git a/tests/visual/tooltip/tooltip.html b/tests/visual/tooltip/tooltip.html
new file mode 100644 (file)
index 0000000..3f1ae38
--- /dev/null
@@ -0,0 +1,149 @@
+<!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.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 a, form input, #childish").tooltip();
+                       
+                       // custom class, replaces ui-widget-content
+                       $("#context2 [title]").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"
+                       });
+                       
+                       $("#button1").button().tooltip();
+                       $("#button2").button({
+                               icons: {
+                                       primary: "ui-icon-wrench"
+                               }
+                       }).tooltip();
+                       $("#button3").button({
+                               icons: {
+                                       primary: "ui-icon-wrench"
+                               },
+                               text: false
+                       }).tooltip();
+               }
+               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>
+       
+       <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>
+       
+       <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</button>
+       
+       <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>
index eed06a2772f53a64c58b08ed485a32a5887ba2cb..b6a74984bf093d8d56a22ed0a9d75af0c45d070c 100644 (file)
@@ -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");
diff --git a/themes/base/jquery.ui.tooltip.css b/themes/base/jquery.ui.tooltip.css
new file mode 100644 (file)
index 0000000..6d8e988
--- /dev/null
@@ -0,0 +1,14 @@
+/* Tooltip
+----------------------------------*/
+.ui-tooltip {
+       padding:8px; width:100px; position:absolute; z-index:9999;
+       -o-box-shadow: 0 0 5px #aaa;
+       -moz-box-shadow: 0 0 5px #aaa;
+       -webkit-box-shadow: 0 0 5px #aaa;
+       box-shadow: 0 0 5px #aaa;
+}
+/* Fades and background-images don't work well together in IE6, drop the image */
+* html .ui-tooltip {
+       background-image: none;
+}
+body .ui-tooltip { border-width:2px; }
diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js
new file mode 100644 (file)
index 0000000..166bff4
--- /dev/null
@@ -0,0 +1,145 @@
+/*
+ * 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($) {
+
+// role=application on body required for screenreaders to correctly interpret aria attributes
+if( !$(document.body).is('[role]') ){
+       $(document.body).attr('role','application');
+} 
+
+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 mouseenter.tooltip", function(event) {
+                               self.open();
+                       })
+                       .bind("blur.tooltip mouseleave.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;
+       },
+       
+       open: function() {
+               var target = this.element;
+               // 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) {
+                       // ignore async responses that come in after the tooltip is already hidden
+                       if (self.current == target)
+                               self._show(target, response);
+               });
+               if (content) {
+                       self._show(target, content);
+               }
+       },
+       
+       _show: function(target, content) {
+               if (!content)
+                       return;
+               
+               target.attr("title", "");
+               
+               if (this.options.disabled)
+                       return;
+                       
+               this.tooltipContent.html(content);
+               this.tooltip.css({
+                       top: 0,
+                       left: 0
+               }).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( "open" );
+       },
+       
+       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();
+               
+               this._trigger( "close" );
+       }
+       
+});
+
+})(jQuery);
\ No newline at end of file