From 6204e1a3c4197d4c612e786337ee371295364ee2 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Thu, 8 Apr 2010 23:21:47 +0200 Subject: The accidental merge of tooltip into master was reverted in master, that revert got merged back into tooltip; now reverting that revert to get the tooltip stuff back, should then make it easy to merge into master once tooltip is done --- tests/visual/tooltip/ajaxcontent.php | 2 + tests/visual/tooltip/callout.html | 213 +++++++++++++++++++++++++++++++++++ tests/visual/tooltip/tooltip.html | 149 ++++++++++++++++++++++++ 3 files changed, 364 insertions(+) create mode 100644 tests/visual/tooltip/ajaxcontent.php create mode 100644 tests/visual/tooltip/callout.html create mode 100644 tests/visual/tooltip/tooltip.html (limited to 'tests/visual/tooltip') diff --git a/tests/visual/tooltip/ajaxcontent.php b/tests/visual/tooltip/ajaxcontent.php new file mode 100644 index 000000000..a689a734d --- /dev/null +++ b/tests/visual/tooltip/ajaxcontent.php @@ -0,0 +1,2 @@ + +Hello 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 index 000000000..3ef694987 --- /dev/null +++ b/tests/visual/tooltip/callout.html @@ -0,0 +1,213 @@ + + + + Tooltip Visual Test: Default + + + + + + + + + + + + + +
+ + +
+ collision detection should kick in around here +
+ +
+ I'm a link to a footnote. +
+ +
+ right aligned with custom position +
+ +
+ gets its content via ajax +
+ +
+ span +
+ div + nested span +
+
+ +
+
+ + +
+
+ + +
+
+ +
This is the footnote, including other elements
+ + + +
+ + + + diff --git a/tests/visual/tooltip/tooltip.html b/tests/visual/tooltip/tooltip.html new file mode 100644 index 000000000..3f1ae3878 --- /dev/null +++ b/tests/visual/tooltip/tooltip.html @@ -0,0 +1,149 @@ + + + + Tooltip Visual Test: Default + + + + + + + + + + + + + +
+ + +
+ collision detection should kick in around here +
+ +
+ I'm a link to a footnote. +
+ +
+ right aligned with custom position +
+ +
+ gets its content via ajax +
+ +
+ span +
+ div + nested span +
+
+ +
+ Text in bold. +
+ +
+
+ + +
+
+ + +
+
+ + + + + +
This is the footnote, including other elements
+ + + +
+ + + + -- cgit v1.2.3 From 9f56913dcc247b6aad4cea752d744ebf7775f794 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Sat, 15 May 2010 16:37:52 +0200 Subject: Tooltip: Enhanced visual test to include a few more buttons and a high element to get a scrollbar --- tests/visual/tooltip/tooltip.html | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'tests/visual/tooltip') diff --git a/tests/visual/tooltip/tooltip.html b/tests/visual/tooltip/tooltip.html index 3f1ae3878..022093bc7 100644 --- a/tests/visual/tooltip/tooltip.html +++ b/tests/visual/tooltip/tooltip.html @@ -55,18 +55,25 @@ tooltipClass: "ui-state-highlight" }); - $("#button1").button().tooltip(); + var positionOnTop = { + position: { + my: "center bottom", + at: "center top", + offset: "0 -5" + } + }; + $("#button1").button().tooltip(positionOnTop); $("#button2").button({ icons: { primary: "ui-icon-wrench" } - }).tooltip(); - $("#button3").button({ + }).tooltip(positionOnTop); + $("#button3, #button4").button({ icons: { primary: "ui-icon-wrench" }, text: false - }).tooltip(); + }).tooltip(positionOnTop); } enable(); @@ -136,7 +143,8 @@ - + +
This is the footnote, including other elements
@@ -144,6 +152,7 @@ +
-- cgit v1.2.3 From 732a485676a1dcbefc16fdb9d26774b622410138 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Thu, 21 Oct 2010 21:03:48 +0200 Subject: Tooltip: Adding another ajax example to visual testcase. Fixing async response handling (taking IE cached response quirk into account) and simplifying fade animations a ton. --- tests/visual/tooltip/tooltip.html | 21 +++++++++++++++++++++ ui/jquery.ui.tooltip.js | 21 ++++++++------------- 2 files changed, 29 insertions(+), 13 deletions(-) (limited to 'tests/visual/tooltip') diff --git a/tests/visual/tooltip/tooltip.html b/tests/visual/tooltip/tooltip.html index 022093bc7..7b931b155 100644 --- a/tests/visual/tooltip/tooltip.html +++ b/tests/visual/tooltip/tooltip.html @@ -44,6 +44,24 @@ 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({ @@ -117,6 +135,9 @@
gets its content via ajax
+
+ gets its content via ajax, caches the response +
span diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index 32d5afeee..8341131ca 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -82,9 +82,12 @@ $.widget("ui.tooltip", { 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(event, target, response); + // IE may instantly serve a cached response, need to give it a chance to finish with _show before that + setTimeout(function() { + // ignore async responses that come in after the tooltip is already hidden + if (self.current == target) + self._show(event, target, response); + }, 13); }); if (content) { self._show(event, target, content); @@ -111,10 +114,7 @@ $.widget("ui.tooltip", { 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.tooltip.stop(false, true).fadeIn(); this._trigger( "open", event ); }, @@ -132,12 +132,7 @@ $.widget("ui.tooltip", { current.removeAttr("aria-describedby"); this.tooltip.attr("aria-hidden", "true"); - if (this.tooltip.is(':animated')) - this.tooltip.stop().fadeTo("normal", 0, function() { - $(this).hide().css("opacity", ""); - }); - else - this.tooltip.stop().fadeOut(); + this.tooltip.stop(false, true).fadeOut(); this._trigger( "close", event ); } -- cgit v1.2.3 From bdd815e8dcdeace8be6dd8005ef443bc5ea20548 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Tue, 26 Oct 2010 15:36:43 +0200 Subject: Tooltip: Demo and tests update --- tests/unit/tooltip/tooltip_options.js | 9 +++++++++ tests/visual/tooltip/tooltip.html | 15 ++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) (limited to 'tests/visual/tooltip') diff --git a/tests/unit/tooltip/tooltip_options.js b/tests/unit/tooltip/tooltip_options.js index 41873ab5b..99d582489 100644 --- a/tests/unit/tooltip/tooltip_options.js +++ b/tests/unit/tooltip/tooltip_options.js @@ -23,6 +23,15 @@ test("content: return string", function() { same( $(".ui-tooltip").text(), "customstring" ); }); +test("content: return jQuery", function() { + $("#tooltipped1").tooltip({ + content: function() { + return $("
").html("customstring"); + } + }).tooltip("open"); + same( $(".ui-tooltip").text(), "customstring" ); +}); + test("content: callback string", function() { stop(); $("#tooltipped1").tooltip({ diff --git a/tests/visual/tooltip/tooltip.html b/tests/visual/tooltip/tooltip.html index 7b931b155..1e2832e34 100644 --- a/tests/visual/tooltip/tooltip.html +++ b/tests/visual/tooltip/tooltip.html @@ -24,12 +24,10 @@ $("#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" - }); + $("#context2 [title]").tooltip().each(function() { + $(this).tooltip("widget").addClass("ui-widget-header"); + }) + $("#right1").tooltip().tooltip("widget").addClass("ui-state-error"); // synchronous content $("#see-footnote").tooltip({ @@ -69,9 +67,8 @@ my: "center top", at: "center bottom", offset: "0 10" - }, - tooltipClass: "ui-state-highlight" - }); + } + }).tooltip("widget").addClass("ui-state-highlight"); var positionOnTop = { position: { -- cgit v1.2.3 From 48a5977d3325869abd7b7ba835eb8ac331fd6eb5 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Tue, 26 Oct 2010 17:07:22 +0200 Subject: Tooltip: Implementing event delegation support. --- demos/tooltip/ajax/content1.html | 1 + demos/tooltip/ajax/content2.html | 1 + demos/tooltip/custom-animation.html | 2 +- demos/tooltip/default.html | 2 +- demos/tooltip/delegation-mixbag.html | 73 ++++++++++++++++++++++++++++++++++ demos/tooltip/index.html | 1 + demos/tooltip/tracking.html | 2 +- tests/unit/tooltip/tooltip_defaults.js | 1 + tests/unit/tooltip/tooltip_events.js | 4 +- tests/unit/tooltip/tooltip_options.js | 5 +++ tests/visual/tooltip/tooltip.html | 45 +++++++++++---------- ui/jquery.ui.tooltip.js | 7 ++-- 12 files changed, 116 insertions(+), 28 deletions(-) create mode 100644 demos/tooltip/ajax/content1.html create mode 100644 demos/tooltip/ajax/content2.html create mode 100644 demos/tooltip/delegation-mixbag.html (limited to 'tests/visual/tooltip') diff --git a/demos/tooltip/ajax/content1.html b/demos/tooltip/ajax/content1.html new file mode 100644 index 000000000..a1401b26d --- /dev/null +++ b/demos/tooltip/ajax/content1.html @@ -0,0 +1 @@ +

This content was loaded via ajax.

\ No newline at end of file diff --git a/demos/tooltip/ajax/content2.html b/demos/tooltip/ajax/content2.html new file mode 100644 index 000000000..f4132d731 --- /dev/null +++ b/demos/tooltip/ajax/content2.html @@ -0,0 +1 @@ +

This other content was loaded via ajax.

\ No newline at end of file diff --git a/demos/tooltip/custom-animation.html b/demos/tooltip/custom-animation.html index 585360d7c..1353e3b91 100644 --- a/demos/tooltip/custom-animation.html +++ b/demos/tooltip/custom-animation.html @@ -11,7 +11,7 @@ + + + +
+ + + + + +
+
This is the footnote, including other elements
+
This is the other footnote, including other elements
+
+
+ + + +
+ +

Show how to combine different event delegated tooltips into a single instance, by customizing the items and content options.

+ +
+ + + + + diff --git a/demos/tooltip/index.html b/demos/tooltip/index.html index e55575d4c..6bc9c1e5c 100644 --- a/demos/tooltip/index.html +++ b/demos/tooltip/index.html @@ -13,6 +13,7 @@
  • Forms with tooltips
  • Track the mouse
  • Custom animation
  • +
  • Delegation Mixbag
  • diff --git a/demos/tooltip/tracking.html b/demos/tooltip/tracking.html index 9af4d0d09..286f01209 100644 --- a/demos/tooltip/tracking.html +++ b/demos/tooltip/tracking.html @@ -11,7 +11,7 @@